Created
February 4, 2020 14:29
-
-
Save cedricziel/976bf30985562b73ab63845e74c436d5 to your computer and use it in GitHub Desktop.
Simple setup for keycloak and docker.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* 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/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
rm -R https | |
mkdir https | |
openssl req -nodes -new -x509 -keyout https/tls.key -out https/tls.crt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 protected] -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