Skip to content

feat: keycloak jwt hardening (roles + audience + profiles)#4

Open
egorkuzn wants to merge 2 commits into19Igor:mainfrom
egorkuzn:feat/keycloak-jwt-hardening
Open

feat: keycloak jwt hardening (roles + audience + profiles)#4
egorkuzn wants to merge 2 commits into19Igor:mainfrom
egorkuzn:feat/keycloak-jwt-hardening

Conversation

@egorkuzn
Copy link
Copy Markdown

@egorkuzn egorkuzn commented Apr 24, 2026

What changed:

  • Added Keycloak role mapping from realm_access.roles and resource_access client roles into Spring ROLE authorities.
  • Kept default scope mapping for SCOPE authorities.
  • Added configurable JWT audience validation.
  • Enabled method security to keep handler-level role access model.
  • Split config into local/dev/prod profile files with env-driven settings.
  • Stabilized JwtDecoder initialization for CI/tests without requiring a live Keycloak during context bootstrap.

Issues:

Notes:

  • Handler-level access control remains the source of truth.
  • Local profile has defaults for quick startup.
  • Dev/prod profiles require KC_ISSUER_URI, KC_CLIENT_ID, KC_EXPECTED_AUDIENCES.
  • Verified with dockerized Maven run: mvn test => BUILD SUCCESS.

@egorkuzn
Copy link
Copy Markdown
Author

I checked this repository for OpenAPI/Swagger annotations and spec files before applying security changes. There are no swagger/openapi descriptors in the current codebase.

To keep the existing access model safe, this PR keeps authorization at handler level via method security and does not add path-based role rules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant