feat: map Keycloak realm roles to Spring RBAC

This commit is contained in:
donghyeon-ka
2026-07-25 16:35:28 +09:00
parent f566ed192c
commit 3e3de6c4c3
9 changed files with 202 additions and 2 deletions
+16
View File
@@ -0,0 +1,16 @@
# Keycloak realm roles to Spring authorization
`realm_access.roles`의 각 문자열을 `ROLE_` prefix가 붙은 Spring authority로
변환한다. `/api/admin``hasRole("admin-role")` 계약이므로 최종 authority는
`ROLE_admin-role`이다. `hasRole("ROLE_admin-role")`로 쓰면 prefix가 중복된다.
검증은 세 층으로 구성된다.
- converter 단위 테스트: role claim과 claim 부재
- MockMvc: regular 403, admin 200
- 실제 Authorization Code + PKCE login: Keycloak token의 realm role을
Spring Resource Server가 변환해 regular 403/admin 200을 반환
```sh
./scripts/verify-spring-role-mapping.sh
```