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

token-key-access property is not working

Open bassemZohdy opened this issue 10 years ago • 4 comments

while I'm permit all for token key in Authorization server as putting below in application.properties:

security.oauth2.authorization.check-token-access=permitAll()
security.oauth2.authorization.token-key-access=permitAll()

I got 401 Unauthorized in resource server also when I'm trying to access it using curl.

using version 1.3.3.RELEASE

bassemZohdy avatar Mar 03 '16 03:03 bassemZohdy

I found the problem, it is in OAuth project in TokenKeyEndpoint class, there is condition as :

        if ((principal == null || principal instanceof AnonymousAuthenticationToken) && !converter.isPublic()) {
            throw new AccessDeniedException("You need to authenticate to see a shared key");
        }

it is checking if key .isPublic() and if it is not it is throwing AccessDeniedException then you get 401 with not descriptive message.

bassemZohdy avatar Mar 03 '16 12:03 bassemZohdy

@bassemZohdy i'm also having this problem in v1.3.3

n0mer avatar Mar 29 '16 06:03 n0mer

The TokenKeyEndpoint class is not part of Spring Boot so if the problem lies there we'll need to move this issue.

/cc @dsyer

philwebb avatar Mar 29 '16 19:03 philwebb

It's not an issue as far as I can see. The exception says precisely why it was thrown: the key is not public, so it can't be revealed.

dsyer avatar Mar 29 '16 21:03 dsyer