-
I have a filter chain set up for API keys which does something like this: ApiKeyAuthenticationToken authentication = new ApiKeyAuthenticationToken(myDomainUserObject);
SecurityContextHolder.getContext().setAuthentication(authentication);
filterChain.doFilter(request, response); I'd like to do something similar when I'm using the JwtAuthenticationToken provided by the spring-addons-starter-oidc plugin. Is there a simple way to provide a UserDetails service or similar? Thanks in advance |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
With OAuth2, the "user-service" is the authorization server: that's it which is responsible for providing user data as OAuth2 claims (inside a JWT access token or as introspection response payload for resource servers, and as ID token payload or userinfo response payload for clients). On resource servers and clients, you shouldn't be looping to the DB to get user details & authorities and, more importantly, you should not duplicate this authorization server data in your resource server's DB. With As stated in the doc, Note that You can find demos of that in the resource-server_with_oauthentication and resource-server_with_specialized_oauthentication tutorials. As a side note, you might find the |
Beta Was this translation helpful? Give feedback.
-
As always, a fantastic answer - thank you |
Beta Was this translation helpful? Give feedback.
With OAuth2, the "user-service" is the authorization server: that's it which is responsible for providing user data as OAuth2 claims (inside a JWT access token or as introspection response payload for resource servers, and as ID token payload or userinfo response payload for clients). On resource servers and clients, you shouldn't be looping to the DB to get user details & authorities and, more importantly, you should not duplicate this authorization server data in your resource server's DB.
With
oauth2ResourceServer
and a JWT decoder, theAuthentication
instance is returned by aConverter<Jwt, AbstractAuthenticationToken>
. The default implementation isJwtAuthenticationConverter
which bu…