not autowired jwtConverter to endpoints Config OAuth2
In OAuth2AuthorizationServerConfiguration it is setting tokenStore but not jwtConverter so it is not working if I added tokenStore and jwtConverter.
Sorry, I didn't get that. Can you please share a sample that showcases the problem?
in current OAuth2AuthorizationServerConfiguration you can find:
@Override
public void configure(AuthorizationServerEndpointsConfigurer endpoints)
throws Exception {
if (this.tokenStore != null) {
endpoints.tokenStore(this.tokenStore);
}
if (this.details.getAuthorizedGrantTypes().contains("password")) {
endpoints.authenticationManager(this.authenticationManager);
}
}
and it is missing setting accessTokenConverter like:
if (this.accessTokenConverter!= null) {
endpoints.accessTokenConverter(accessTokenConverter());
}
@dsyer would this be a sensible addition?
Not a straightforward call I think. Typically (and from an opinionated point of view) the TokenStore and AccessTokenConverter are not independent choices. Using JWT there is one "normal" way to set them up and we already do that if the user configures a signing key for the JWT, i.e. if security.oauth2.resource.jwt.* is set.
Actually when I added TokenStore without AccessTokenConverter, token generated not using JWT and it is generated as there is no jwtConverter while am using it to create jwtTokenStore, if it is required I can upload my case on GitHub for you.
I can upload my case on GitHub for you Yes please, that would be very useful.
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
please find the issue in this project https://github.com/bassemZohdy/SpringOAuthIssue-7091 , if you have any question please let me know.
@dsyer I think this might be a sensible change. If I understand correctly, once you've created a jwtTokenStore with an AccessTokenConverter, you shouldn't need to set the accessTokenConverter as is done on this line: https://github.com/bassemZohdy/SpringOAuthIssue-7091/blob/master/src/main/java/com/example/MyOAuth2AuthorizationServerConfiguration.java#L30. I'm not sure if this would be a change in the Boot code or something that the AuthorizationServerEndpointsConfigurer would handle.
Actually at beginning I was expecting that if I just inject converter in jwtTokenStore it should be responsibility of jwtTokenStore to use converter to generate jwt token but then I found that there is setter for converter of endpoint configuration so I suggested this solution, so I think actually it is jwtTokenStore issue but but provided solution is work around "but nice to have as there is still setter for converter".
I think what is missing here is a clear statement of what the problem actually is. You said at the top "it is not working if I added tokenStore and jwtConverter" but didn't explain what you meant.
Sorry if you have any misunderstanding for what I issued, I thought the title is clear "not autowired jwtConverter to endpoints Config OAuth2" and I proved it with project shared, please tell me if you need any more clarification.
the current question are you OK with changes in project shared or are you providing another solution.
How does that manifest as "not working"? Is it a runtime error? Exception on startup? Is there a failing test?
if you run project shared you will find that the token is not jwt but after change I mentioned it is jwt, did you run the project ?