-
Notifications
You must be signed in to change notification settings - Fork 1.3k
validate client secret expired or not #862
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
validate client secret expired or not #862
Conversation
@jgrandja Please help to review this PR. thanks! |
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.
Thanks for the PR @doctormacky. Please see review comments.
Also, please add a test in ClientSecretAuthenticationProviderTests
.
@@ -93,6 +95,11 @@ public Authentication authenticate(Authentication authentication) throws Authent | |||
throwInvalidClient(OAuth2ParameterNames.CLIENT_ID); | |||
} | |||
|
|||
Instant expiredAt = registeredClient.getClientSecretExpiresAt(); |
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.
Please move this validation below if (!this.passwordEncoder.matches(clientSecret, registeredClient.getClientSecret()))
@@ -93,6 +95,11 @@ public Authentication authenticate(Authentication authentication) throws Authent | |||
throwInvalidClient(OAuth2ParameterNames.CLIENT_ID); | |||
} | |||
|
|||
Instant expiredAt = registeredClient.getClientSecretExpiresAt(); |
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.
Remove the variable expiredAt
and just use registeredClient.getClientSecretExpiresAt()
@@ -93,6 +95,11 @@ public Authentication authenticate(Authentication authentication) throws Authent | |||
throwInvalidClient(OAuth2ParameterNames.CLIENT_ID); | |||
} | |||
|
|||
Instant expiredAt = registeredClient.getClientSecretExpiresAt(); | |||
if (expiredAt!=null && Instant.now().isAfter(expiredAt)) { |
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.
Add spaces between the comparison expiredAt!=null
so it's consistent with other code
@jgrandja Please help to review it again. thanks. |
@jgrandja Any progress on this PR ? |
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.
Thanks for the updates @doctormacky.
One minor change left and we'll be ready to merge.
Can you also rebase off latest 0.4.x
and squash the commits.
Thanks!
@@ -64,4 +64,20 @@ public static RegisteredClient.Builder registeredPublicClient() { | |||
.scope("scope1") | |||
.clientSettings(ClientSettings.builder().requireProofKey(true).build()); | |||
} | |||
|
|||
public static RegisteredClient.Builder registeredClient4() { |
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.
Please remove this and reuse TestRegisteredClients.registeredClient()
, which returns the Builder
and allows you to update clientSecretExpiresAt()
Thanks for the updates @doctormacky. This is now merged. |
Thanks @jgrandja It's my pleasure. |
validate the client secret is expired or not.
see the details here