Closed spkingr closed 6 months ago
Apparently, you're not using spring-addons-starter-oidc
and haven't read the tutorials. This is an issue tracker for spring-addons, not a forum. I answered this problem many times on Stackoverflow already, go there
Apparently, you're not using
spring-addons-starter-oidc
and haven't read the tutorials. This is an issue tracker for spring-addons, not a forum. I answered this problem many times on Stackoverflow already, go there
Sorry, and that's the greatest and much detailed tutorial i ever seen about OAuth2 + Spring, thanks!
Describe the bug
I have a resource server and client springboot 3 project with spring security 6, and the KeyCloak 23.0.6 as the authorization server, the code is simple and can run with login/logout without problem, but after login with OAuth2, the authentication token lacks of custom roles which I setup in KeyCloak console, I can see them in the original JWT token when decoded:
So I created the custom JwtDecoder or other custom claims parser related configurations or beans including these below:
But all the code fails without doubt running in my web browser test, all the authentication results I can get are filled with just the default roles like:
OIDC_USER, SCOPE_email, SCOPE_openid
and so on, no custom ones within theresource_access.{custom_client}.roles
field specified.I found your answer in stackflow:
https://stackoverflow.com/questions/58205510/spring-security-mapping-oauth2-claims-with-roles-to-secure-resource-server-endp
, and find your repo here to look for your help, hope you can give me some ideas, thanks in advance!Code sample
The main code:
Thanks again!