- Start the keycloak container with docker
Wait a bit until the keycloak container is up and running. It's ready when
cd docker docker compose up -d cd ..
docker logs -f keycloak_brokering
shows "Running the server in development mode. DO NOT use this configuration in production." - Change the local port if necessary by editing
terraform/_shared/globals/output.tf
output "port" { value = "8103" # only change if you need/want a different port } - Create the realm that acts as an identity provider
cd terraform/idp_realm terraform init terraform apply cd ../..
- Create the realm that is used by the users
cd terraform/user_facing_realm terraform init terraform apply cd ../..
This example uses Postman and the default IP and Port from terraform/_shared/globals/output.tf
.
If you changed those, edit the URLs blow accordingly.
- Create a new request in Postman, GET http://host.docker.internal:8103/realms/user_facing/broker/idp/token
- Setup OAuth 2.0 token for this request with these settings
- Grant Type: Authorization Code
- Callback URL: https://oauth.pstmn.io/v1/callback
- Auth URL: http://host.docker.internal:8103/realms/user_facing/protocol/openid-connect/auth
- Access Token URL: http://host.docker.internal:8103/realms/user_facing/protocol/openid-connect/token
- Client ID: frontend
- Get a token
- Click "Get New Access Token" in Postman
- In the window that opens click the "idp" or "keycloak-idp" button below "Or sign in with"
- Enter Username
user
and Passworduser
and click the "Sign In" button
- Use this token to execute the request to get the original id_token of the identity provider
- Click "Proceed" after successful login
- Click "Use Token" after selecting the new token
- Click "Send" on the actual request
- Open http://host.docker.internal:8103/realms/user_facing/account
- Click "Sign in"
- Click "idp" or "keycloak-idp" in the "Or sign in with" section
- Enter "user" as both username and password and hit enter
And as admin, use "admin/admin" when opening http://localhost:8103/admin/master/console/
"idp" will import the roles of the "idp_realm" into the user attribute "group". "keycloak-idp" will import the roles of the "idp_realm" into realm role assignments of the user.
To see the actual token that transfers the roles from realm "idp_realm" to "user_facing_realm" during the identity brokering check the docker log.