How can I get details from the OAuth2 SSO Principal into my JWT? (instance of OAuth2Authentication getDetails as OAuth2AuthenticationDetails getDecodedDetails returns null)
I have...
- Angular 6 client w/ implicit login as
acmeclient (usingangular-oauth2-oidc) Spring Boot OAuth2 Authorization Server with JWT
TokenServiceconfiguration w/ 3rd party SSO to GitHubAuth server is configured with
acmeasimplicitand GitHub client for SSO- Auth server exposes a
/login/github - Auth server exposes a
/me(protected by ResourceServer config)
When I login...
- Angular app redirects to Auth service login
- Auth service redirects to GitHub
- [User Authenticates]
- GitHub redirects to Auth Service
- Auth Service initiates a session and issues a token
- Auth Service redirects to Angular
- The browser token is a proper JWT
Now, when I communicate with Auth Service /me:
- Directly, I get a
Principalthat contains ALL of the details from GitHub (yay) - Indirectly from the Angular application passing the token via
Authorization: Bearer ...header, I get aPrincipalthat contains bare minimum OAuth client info foracmeclient (ugh)
I've tried a custom TokenEnhancer, but the OAuth2Authentication instance is already the bare minimum with no details. And, when the call is initiated from Angular, it doesn't have the same session cookie as when I call it directly (I don't want to share session - I want to put the details in the JWT).
[Update #1]
I tried a custom JwtAccessTokenConverter and used it in both of the @EnableAuthorizationServer and @EnableResourceServer (secures the /me endpoint) configuration classes. However it didn't work. I still get null details from OAuth2Authentication.
final JwtAccessTokenConverter converter = new JwtAccessTokenConverter();
converter.setAccessTokenConverter(new CustomTokenConverter());