-
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
scopes_supported metadata should not be used as default in ClientRegistrations #8514
Comments
Thanks for the report @martin-v.
I don't think this makes sense as the client won't request any scopes if the
This is not a workaround. We typically provide defaults, in order to reduce configuration, but also provide the option to override the default. I'm going to close this as works as designed. |
@jgrandja I believe there's a misunderstanding here, but it could very well be mine. When autoconfiguring client registrations in Spring Boot, OAuth2ClientPropertiesRegistrationAdapter#getClientRegistration in turn calls ClientRegistrations#fromIssuerLocation, which gets the supported scopes from the authorization server. Back in OAuth2ClientPropertiesRegistrationAdapter#getClientRegistration, the Builder based on the provider is merged with the Spring Boot properties, which makes the scope property overwrite the scope in the Builder. However, this is only done if the scope property is not null, otherwise the existing value in the Builder is kept and used for further authorization. So, if scope is not set in the Spring Boot properties, the full list of all existing scopes on the authorization server will be requested for all clients, even though each client most likely only supports a subset of the scopes. @martin-v suggests that rather than having the default requested scopes be all scopes available on the whole authorization server, it should be no scopes, meaning the parameter should not be sent at all. As the parameter is optional, this should be OK. Another point to this is that there is currently no way through properties to choose not to include the scopes parameter in the request. Am I the one misunderstanding this? If so, is there a reason for having that default value that I'm not seeing? |
@shelgen Thanks for providing your detailed feedback. After reading over the comments again I realized that my initial analysis was incorrect. As @martin-v suggests:
This is actually correct. Currently, all entries from In most cases, the Apologies for my misunderstanding @martin-v. |
@jgrandja I can implement it but I discovered another problem. I'm no longer sure that leave it empty is the best option. Because I discovered that the OpenID Connect Spec requires a scope.
In my optinion the question is do more user use OAuth 2.0 without OpenID Connect or with? @shelgen yes, if we decide to leave it empty we should not be sent the parameter at all |
@martin-v Good catch. Yes, we should default Thanks for taking this on! |
In #8790 (comment) is a discussion ongoing what is the best solution to fix this issue. Maybe someone here can give us some additional aspects. |
scopes_supported
for scopes to request
Describe the bug
The oauth2-client requests all available scopes on the authorization server by default. That includes also scopes for other clients.
ClientRegistration.getScopes()
copies allscopes_supported
from authorization server metadata into scope config for this client. So the oauth2-client requested on each authorization all of these scopes.As Keycloak has recently fixed a bug now throwing error on invalid scope requests, this bug will occur for more people.
To Reproduce
Assigned Default Client Scopes
andAssigned Optional Client Scopes
of this clientspring.security.oauth2.client.registration.${name}.scope
(This is a workaround to fix the problem)Expected behavior
As
scopes_supported
lists all scopes for all clients on this authorization server it's not a good default.Also, considering that the
scope
parameter is optional.The best default should be just leave it empty.
The text was updated successfully, but these errors were encountered: