-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
OpenID Connect Userinfo not fetched for custom claims #6886
Comments
@furti If you look at the logic in It sounds like you have IMO, it makes sense to have at least Alternatively, you can always supply a custom As an FYI, requesting claims using the "claims" request parameter is not currently supported by I'm going to close this issue as Works as Designed. However, we can re-open and discuss further if the solutions I provided do not work for your setup. |
@jgrandja thanks for your response.
Thats true. We don't need the profile as our identity provider decides on its own what data a application is allowed to get. It is not really needed that an application requests something.
Our Identity Provider simply ignores the requested scopes. Adding the scope makes everything work like it should. But it feels a bit like a Workaround to specify a scope that is known to be ignored anyways.
Thanks for the hint. I think this is a good solution to simply use a custom implementation of the OidcUserService. |
@furti I see your point now. |
@furti Would you be interested in submitting a PR for this? I'm debating on whether making |
@jgrandja I never used the OpenID Client Implementation of Spring Security myself. I'm maintaining our Identity Provider and somebody else had a Problem connecting to us. So I don't think if I'm the right one to submit a PR for this. But I would aim for a combination of both. Making the But for simple usage scenarios the current logic could be preserved by creating a constructor that takes the list of scopes to load the userinfo for. public class OidcUserService implements OAuth2UserService<OidcUserRequest, OidcUser> {
...
private final Set<String> userInfoScopes;
...
public OidcUserService() {
this(OidcScopes.PROFILE, OidcScopes.EMAIL, OidcScopes.ADDRESS, OidcScopes.PHONE)
}
public OidcUserService(String... userInfoScopes) {
this(Arrays.asList(userInfoScopes));
}
public OidcUserService(Collection<String> userInfoScopes) {
this.userInfoScopes = new HashSet<>(userInfoScopes);
}
...
} So it is pretty easy to load the userinfo for different scopes. And maybe change This changes will preserve the current logic and make nearly all scenarios possible that I can think of :) |
No worries @furti and thanks for the suggestions. |
@jgrandja For what it is worth I like the suggestion of allowing the user info scopes to be configurable. |
@rwinch I agree that allowing to configure the accessible scopes is the best option. I added @furti For your use case, you can simply override the default behaviour with |
Nice. Thanks for fixing it that quickly :) |
Summary
@jgrandja
We have a Problem retrieving the Userinfo data for our custom Identity Provider that implements OpenID Connect.
I stumbled accross #4451 and can totally understand why you made the retrieval of the userinfo optional.
But as far as I understand the specification, one can define custom claims https://openid.net/specs/openid-connect-core-1_0.html#AdditionalClaims
And also requesting of claims is optional. A IDP can decide what claims to send when nothing is requested.
https://openid.net/specs/openid-connect-core-1_0.html#ClaimsParameter
Actual Behavior
With the implementation introduced in the issue linked above, it is not possible to retrieve the userinfo without specifying one of the default scopes.
But as said above, requesting a claim is totally optional. And the scope values are not the only way of requesting a claim.
But maybe my interpretation of the Spec is wrong and everything is totally fine :)
Expected Behavior
It should be possible to retrieve the userinfo without specifying a default scope.
Maybe some configurable "UserInfoRetrievalMatcher" interface. The default implementation is the current implementation, but applications can provide a custom implementation to decide if the userinfo should be loaded or not.
The text was updated successfully, but these errors were encountered: