-
Notifications
You must be signed in to change notification settings - Fork 6k
Improve Bearer Token Error Handling #7826
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
InvalidBearerTokenException
extends OAuth2AuthenticationException
, yet there still isn't a fall-back for catching the OAuth2AuthenticationException
in the AuthenticationEventPublisher
. Should OAuth2AuthenticationException
be converted to an abstract class?
In the ticket, you said:
By this, I interpret your intent to be |
@sdavids13 Can you describe other scenarios that you'd like to event on? This PR is certainly something that we can iterate on. |
Yes, I think this PR fits the bill with what I need/requested. I was merely concerned that someone might inadvertently use the
I would think for all of those problems we would want to know if someone is attempting to authenticate but being denied for any one of those reasons. As of right now, I think this PR results in a better out-of-box experience and addressed my primary issue, my only fear is that we aren't catching all events which we may want to audit. But, at the same time, we could merge this PR, and backlog a different ticket which may ask those other questions as to which other events should be audited. |
b1c610c
to
6ee8dd6
Compare
Updated NimbusJwtDecoder and NimbusReactiveJwtDecoder to throw. Updated JwtAuthenticationProvider and JwtReactiveAuthenticationManager to catch. Fixes spring-projectsgh-7885
Merged to |
This PR improves how Resource Server handles Bearer Token errors.
Specifically:
InvalidBearerTokenException
toDefaultAuthenticationEventPublisher
.These are in the same PR because Resource Server cannot currently determine whether or not a JWT processing error is really an invalid token, and I'd like to address that before registering that exception with
DefaultAuthenticationEventPublisher
.