-
Notifications
You must be signed in to change notification settings - Fork 6k
Allow configurable JwtDecoder for ID Token verification #5751
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
Allow configurable JwtDecoder for ID Token verification #5751
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.
I agree that it isn't ideal to have the jose dependency here. Perhaps the better approach is allowing the user to configure the AuthenticationProvider instead.
@Override | ||
public JwtDecoder apply(ClientRegistration clientRegistration) { | ||
JwtDecoder jwtDecoder = this.jwtDecoders.get(clientRegistration.getRegistrationId()); | ||
if (jwtDecoder == null) { |
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.
Since you are using ConcurrentHashMap, is it better to use computeIfAbsent
instead of get
?
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 that catch @jzheaux! Yes, we should use computeIfAbsent
. I'll apply that update.
Sure this is another option to consider. However, given where we are with the release, this won't make it into 5.1. We'll come back to this after 5.1 is out. |
7aea988
to
ef77930
Compare
@rwinch I decided to go with the I'm wondering if we should consider declaring a new type for this? It's just that public interface IdTokenDecoders {
JwtDecoder getDecoder(ClientRegistration clientRegistration);
} |
ef77930
to
bf833cc
Compare
I think you are right we need a custom interface. However, I think we should consider a different name. Perhaps |
I feel The reason I'm thinking I think |
I see your point about it being client specific, but I still don't like the name. The Id Token is not part of the input or the output of the only method on the interface. Do we anticipate needing something similar for the resource server? If so, perhaps we make the input generic and stick with something like |
Very likely, probably with the multi-tenancy feature we still need to get to
I like this option and provides us the flexibility. I'll go with this |
bf833cc
to
a08c12b
Compare
@rwinch I added the new |
@@ -32,6 +32,7 @@ | |||
return OAuth2AuthorizationRequest.authorizationCode() | |||
.authorizationUri("https://example.com/login/oauth/authorize") | |||
.clientId(clientId) | |||
.scope("openid") |
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.
Did you verify this isn't going to break any existing test assumptions? We probably shouldn't modify this as we don't know what impact this is having on existing tests. It may invalidate a test that has different expectations of the scopes.
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.
I did validate that this does not trigger any failed tests. However, it's probably safer to avoid this change and keep the changes isolated to the test that requires the openid
scope. I'll make this change.
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.
@rwinch I pushed the update for this
This PR resolves gh-5717
@rwinch There is an issue with the changes in this PR.
Given the following that allows for setting a custom
JwtDecoder
factory:This introduces the
oauth2-jose
dependency foroauth2Login
which is not ideal.I'm not sure what we can do at this point to not include
oauth2-jose
as a required dependency?Maybe you have an idea?