Start

Docker:

Setup test realm:

  • Login as default admin account
    • user:bitnami
  • Create realm: SpringBootKeycloak

Run application

  • Commandline gradle bootRun
  • Go to http://localhost:8081/posts.
    • You will be redirected to Keycloak's login page.
    • Login as user1
    • You will redirected back and given access
  • Go to http://localhost:8081/posts/admin.
    • You will be redirected to Keycloak's login page.
    • Login as user1 (which does not have the admin role)
    • You will redirected to Forbidden (403) page
  • Logout:
  • For non-GET requests, you need to get the access token via the Keycloak REST API:
    • Go to: localhost:8180/realms/SpringBootKeycloak/protocol/openid-connect/token
    • See this article on how to get the access token

Issues

Ref: