Skip to content

Instantly share code, notes, and snippets.

@cedricziel
Created February 4, 2020 14:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save cedricziel/976bf30985562b73ab63845e74c436d5 to your computer and use it in GitHub Desktop.
Save cedricziel/976bf30985562b73ab63845e74c436d5 to your computer and use it in GitHub Desktop.
Simple setup for keycloak and docker.
* run gen_keys.sh
* run keycloak_server.sh
Take a look at kcadm on how to import more diverse data points like idp metadata and client configurations.
Also take a look at the simple import / export stuff at https://hub.docker.com/r/jboss/keycloak/
#!/bin/bash
rm -R https
mkdir https
openssl req -nodes -new -x509 -keyout https/tls.key -out https/tls.crt
#!/bin/bash
HOST="localhost"
PORT=8088
USERNAME="admin"
PASSWORD="admin"
REALM="SAML-DEMO"
docker rm -f test-keycloak
echo "Starting a Keycloak instance..."
docker run --detach \
--publish $PORT:8080 \
--publish 8443:8443 \
-e KEYCLOAK_USER=$USERNAME \
-e KEYCLOAK_PASSWORD=$PASSWORD \
-v $(pwd)/https:/etc/x509/https \
-v $(pwd)/realm_setup.sh:/realm_setup.sh \
--name test-keycloak \
jboss/keycloak:7.0.1
while ! curl -o/dev/null -s -w "%{http_code}\n" http://$HOST:$PORT; do
sleep 2
done
docker exec test-keycloak /realm_setup.sh
#!/bin/bash
USERNAME="admin"
PASSWORD="admin"
REALM="SAML-DEMO"
KCADM=/opt/jboss/keycloak/bin/kcadm.sh
$KCADM config credentials --server http://localhost:8080/auth --realm master --user $USERNAME --password $PASSWORD --client admin-cli
$KCADM create realms -s realm=$REALM -s enabled=true -o
$KCADM create users -r $REALM -s username=testuser -s email=test@test.com -s enabled=true
$KCADM set-password -r $REALM --username testuser --new-password testuser
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment