Skip to content

Instantly share code, notes, and snippets.

@slominskir
Last active March 20, 2023 13:31
Show Gist options
  • Save slominskir/8f78155d4b186a8bf9d9059408eb176e to your computer and use it in GitHub Desktop.
Save slominskir/8f78155d4b186a8bf9d9059408eb176e to your computer and use it in GitHub Desktop.
Setup Keycloak

Host OS Setup

Docker

Just use pre-built image to start with:

FROM quay.io/keycloak/keycloak:latest

RHEL 9

Use a Bash script to download Keycloak, and configure OS. Assumes you create a host.env config file and a /run/keycloak.env file:

wget https://raw.githubusercontent.com/JeffersonLab/smoothness/main/bash/keycloak/rhel9-setup.sh 
chmod +x rhel9-setup.sh
./rhel9-setup.sh host.env

Server Setup

Copy/Edit keycloak.conf file into/at Keycloak conf dir then execute:

./kc.sh build

Note: To configure TLS copy PEM format TLS .crt and .key into the Keycloak conf dir and ensure keycloak.conf references the files.

Initial Admin password

export KEYCLOAK_ADMIN=username
export KEYCLOAK_ADMIN_PASSWORD=password
./kc.sh start --optimized
... wait for successful boot
Ctrl-C
unset KEYCLOAK_ADMIN
unset KEYCLOAK_ADMIN_PASSWORD

Configure Realms

Keycloak supports export/import of JSON realm files. However, scripted kcadm.sh commands are clearer to understand and maintain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment