-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error description by BearerTokenAccessDeniedHandler is misleading #7089
Comments
@edouardhue, I think this makes sense. Since the RFC says "The request requires higher privileges than provided by the access token.", I think an error message of "The token provided has insufficient privileges for this request" would be more accurate. The existing message is also a potential source of confusion since the spec allows for missing scopes to be included in the error message whereas the existing message includes provided scopes. Could you provide a PR for the change, both on the reactive and servlet bearer token denial handlers? |
Sure, gimme a few days! |
@jzheaux Reading again https://tools.ietf.org/html/rfc6750#section-3, I think the
Instead, it lists the scopes extracted from the token. Plus, at section 3.1, the rfc states that in the case of
It is then misleading to respond with the scopes from the token, as an user would understand that its token actually has all the required scopes. I suggest totally removing the |
Error messages sent by BearerTokenAccessDeniedHandler included information about the scopes of the rejected token instead of the scopes required by the resource. * Removal of token scopes from error_description attribute. * Removal of scope attribute from WWW-Authenticate response header. Fixes spring-projectsgh-7089
Error messages sent by BearerTokenAccessDeniedHandler included information about the scopes of the rejected token instead of the scopes required by the resource. * Removal of token scopes from error_description attribute. * Removal of scope attribute from WWW-Authenticate response header. Fixes spring-projectsgh-7089
Summary
The error description for the insufficient_scope case in BearerTokenAccessDeniedHandler assumes that the denial is caused by an insufficient scope, while it could have many other causes. It is misleading and should be reworded.
Actual Behavior
The error description in
org.springframework.security.oauth2.server.resource.web.access.BearerTokenAccessDeniedHandler
for error codeinsufficient_scope
states that "The token provided has insufficient scope [%s] for this request".Expected Behavior
RFC 6750 describes this error code with :
An implementation could grant other authorities based on other claims from the token, or from any other source. Access could be denied because of insufficient role, origin... or any other insufficient privilege. Thus, the error description should not assume that the scope is always insufficient.
It could be reworded as : "The token provided has insufficient privileges for this request". This would fix #6280 by the way.
Configuration
Not applicable.
Version
spring-security-oauth2-resource-server-5.1.5.RELEASE
The text was updated successfully, but these errors were encountered: