spring-boot icon indicating copy to clipboard operation
spring-boot copied to clipboard

not autowired jwtConverter to endpoints Config OAuth2

Open bassemZohdy opened this issue 10 years ago • 14 comments

In OAuth2AuthorizationServerConfiguration it is setting tokenStore but not jwtConverter so it is not working if I added tokenStore and jwtConverter.

bassemZohdy avatar Oct 04 '16 13:10 bassemZohdy

Sorry, I didn't get that. Can you please share a sample that showcases the problem?

snicoll avatar Oct 04 '16 13:10 snicoll

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());
        }

bassemZohdy avatar Oct 04 '16 13:10 bassemZohdy

@dsyer would this be a sensible addition?

philwebb avatar Oct 11 '16 03:10 philwebb

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.

dsyer avatar Oct 12 '16 08:10 dsyer

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.

bassemZohdy avatar Oct 13 '16 09:10 bassemZohdy

I can upload my case on GitHub for you Yes please, that would be very useful.

philwebb avatar Oct 26 '16 15:10 philwebb

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.

spring-projects-issues avatar Nov 02 '16 15:11 spring-projects-issues

please find the issue in this project https://github.com/bassemZohdy/SpringOAuthIssue-7091 , if you have any question please let me know.

bassemZohdy avatar Nov 07 '16 20:11 bassemZohdy

@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.

mbhave avatar Nov 09 '16 22:11 mbhave

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".

bassemZohdy avatar Nov 10 '16 05:11 bassemZohdy

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.

dsyer avatar Nov 15 '16 15:11 dsyer

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.

bassemZohdy avatar Nov 16 '16 13:11 bassemZohdy

How does that manifest as "not working"? Is it a runtime error? Exception on startup? Is there a failing test?

dsyer avatar Nov 16 '16 19:11 dsyer

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 ?

bassemZohdy avatar Nov 17 '16 03:11 bassemZohdy