Created
October 3, 2024 09:20
-
-
Save thomasdarimont/d0e0e97e6101980644a58b07f0d9e211 to your computer and use it in GitHub Desktop.
Example for setting up a Keycloak Client via kcadm.sh with the official Keycloak docker image
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
#!/usr/bin/env bash | |
shopt -s expand_aliases | |
alias kcadm="docker run --net=host -i --user=1000:1000 --rm -v $(echo $HOME)/.acme/.keycloak:/opt/keycloak/.keycloak:z --entrypoint /opt/keycloak/bin/kcadm.sh quay.io/keycloak/keycloak:24.0.5" | |
KEYCLOAK_URL=http://localhost:8080/auth | |
KEYCLOAK_ADMIN=admin | |
KEYCLOAK_ADMIN_PASSWORD=admin | |
KEYCLOAK_CLIENT_ID=keycloak-config-cli | |
KEYCLOAK_CLIENT_SECRET=secret | |
echo Login | |
kcadm config credentials \ | |
--config /opt/keycloak/.keycloak/kcadm.config \ | |
--server $KEYCLOAK_URL \ | |
--realm master \ | |
--user "$KEYCLOAK_ADMIN" \ | |
--password "$KEYCLOAK_ADMIN_PASSWORD" | |
echo Create keycloak-config-cli Client | |
kcadm create clients \ | |
--config /opt/keycloak/.keycloak/kcadm.config \ | |
-r master \ | |
-s clientId="$KEYCLOAK_CLIENT_ID" \ | |
-s enabled=true \ | |
-s clientAuthenticatorType=client-secret \ | |
-s secret="$KEYCLOAK_CLIENT_SECRET" \ | |
-s standardFlowEnabled=false \ | |
-s directAccessGrantsEnabled=false \ | |
-s serviceAccountsEnabled=true | |
echo Add realm admin role to Service-Account | |
kcadm add-roles \ | |
--config /opt/keycloak/.keycloak/kcadm.config \ | |
-r master \ | |
--uusername service-account-keycloak-config-cli \ | |
--rolename admin |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment