This example shows how to integrate keycloak auth server 9.0.3 with spring boot
- Start container
docker/keycloak
with commanddocker-compose up
- Start application
./gradlew bootRun
- Query application with commands
curl -ss --data "grant_type=password&client_id=curl&username=joe_admin&password=admin" http://localhost:8081/auth/realms/spring-security-example/protocol/openid-connect/token
curl -H "Authorization: bearer [your-token]" http://localhost:8080/admin
curl -ss --data "grant_type=password&client_id=curl&username=jim_user&password=admin" http://localhost:8081/auth/realms/spring-security-example/protocol/openid-connect/token
curl -H "Authorization: bearer [your-token]" http://localhost:8080/user
Execute commands inside container
docker exec -it springbootkeycloak_keycloak_1 /bin/bash
- Edit
docker/keycloak/setup/setup.sh
- Run this file inside your local keycloak installation bin folder