-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Check user code expiry and invalidity #1997
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
base: main
Are you sure you want to change the base?
Check user code expiry and invalidity #1997
Conversation
Fixes spring-projectsgh-1894 and spring-projectsgh-1977 Signed-off-by: Antoine Lauzon <[email protected]>
27af228
to
31d5ac3
Compare
Would it not be better to just check |
if (this.logger.isTraceEnabled()) { | ||
this.logger.trace("User code is expired"); | ||
} | ||
throw new OAuth2AuthenticationException(OAuth2ErrorCodes.INVALID_GRANT); |
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.
Is it worth providing more context on the error..
throw new OAuth2AuthenticationException(OAuth2ErrorCodes.INVALID_GRANT); | |
OAuth2Error error = new OAuth2Error(OAuth2ErrorCodes.INVALID_GRANT, "User code is expired.", null); | |
throw new OAuth2AuthenticationException(error); |
if (this.logger.isTraceEnabled()) { | ||
this.logger.trace("User code is invalided"); | ||
} | ||
throw new OAuth2AuthenticationException(OAuth2ErrorCodes.INVALID_GRANT); |
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.
Is it worth providing more context on the error..
throw new OAuth2AuthenticationException(OAuth2ErrorCodes.INVALID_GRANT); | |
OAuth2Error error = new OAuth2Error(OAuth2ErrorCodes.INVALID_GRANT, "User code is invalidated.", null); | |
throw new OAuth2AuthenticationException(error); |
It ensures that a user code is neither expired nor invalidated during the verification step. See gh-1894 and gh-1977 for more details.
Notes:
invalidat_grant
appears to be the expected error code (see RFC 6749, Section 5.2). It might be useful to distinguish these exceptions though (e.g. by using subclasses of OAuth2AuthenticationException).