-
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
create new field in ClientRegistration (e.g. "alwaysPkce") to enable PKCE for confidential clients #12219
Comments
Thanks for the suggestion, @drahkrub! In general, I think adding additional specific flags/configuration to |
@drahkrub PKCE is only applicable for the This type of configuration/setting would make more sense in the Spring Boot auto-configuration classes and properties. However, I don't feel it's necessary as the configuration is pretty straight forward as per example 1 and example 2. I'm going to close this based on the explanation provided. |
@randomstuff as a follow-up to this comment, I'd like to propose that we enhance Spring Security to support configuring the @Bean
public OAuth2AuthorizationRequestResolver authorizationRequestResolver(
ClientRegistrationRepository clientRegistrationRepository) {
var authorizationRequestResolver =
new DefaultOAuth2AuthorizationRequestResolver(
clientRegistrationRepository,
OAuth2AuthorizationRequestRedirectFilter.DEFAULT_AUTHORIZATION_REQUEST_BASE_URI);
authorizationRequestResolver.setAuthorizationRequestCustomizer(
OAuth2AuthorizationRequestCustomizers.withPkce());
return authorizationRequestResolver;
} I believe the above proposal is the best middle ground, as this enhancement would be in line with other OAuth2-related "simplification" enhancements as well as a general approach in Spring Security to bean-based configuration. As mentioned on the Spring Boot issue, we wouldn't pursue enabling such a configuration via a Spring Boot configuration property, so it would continue to be an application-level requirement to add this configuration. Any thoughts on that? Should we open a new issue for this? Separately, I also wonder if configuring PKCE on a per-client basis is common? If it is (research and feedback required), another enhancement we could look into is providing a delegating implementation of Lastly,
Regarding enabling PKCE for confidential clients by default, this has already been discussed and isn't likely to change unless it becomes required by a relevant specification. |
The thing is I that whether to use PKCE for a given provider looks like some something that really wants to be (per-provider) configuration : it depends on the provider (some provider support it, some don't support it, some might advertise they support it be in reality their support is broken so you wouldn't want to use it, maybe (?) some support it only for public clients). Now, maybe nobody actually would use such a setup in practice 🤷 but I would find it weird.
Yes, I was hinting at the fact that AFAIU, OAauth 2.1 is expected to be REQUIRED:
This is only a draft but if I guess there is a consensus on the fact that PKCE will be required. |
From a defense-in-depth perspective, it would make sense to automatically enable PKCE if is is supported by the AS. Now, what is not clear to me is whether this might lead to some regression for some ASs. For reference, I found that (some versions of) Keycloak could advertise a PAR endpoint ( |
Thanks for replying @randomstuff!
If you haven't already, please take a look at
As mentioned above, I think using delegation on a per-client basis could be worth exploring but this can already be done today as a customization with the existing components. Can you please clarify what enhancement you are recommending?
Can you clarify this point further? How are you proposing that it would be automatically enabled?
The section of OAuth 2.1 you provided makes it clear that it is REQUIRED for public clients, not confidential clients. Spring Security already meets this requirement. Are you seeing it differently than I am?
Making PKCE enabled by default for confidential clients would absolutely be a breaking change, and as such can't be done in a minor release. Pursuing it for a major release would be possible if it is REQUIRED per the spec. |
Yes, I don't read it this way. I would say that the wording means that there is one specific case where you are allowed not to use PKCE (but still should), when all the following are true at the same time:
If we only consider (2), this means that PKCE MUST be used for non-OIDC flows. We might skip it for OIDC flows. For pure OAuth flows (when For (3), we could assume that OIDC authorization servers (OpenID providers) properly support Other (some non-normative) paragraphs which suggest that "really you really really should be using PKCE" are:
(i.e. by default you should be using PKCE, i.e. PKCE should be opt-out) and
I mean, if PKCE support must be enabled through code, only the experts in OAuth will wonder if this is enabled and might enable it. Or maybe people will ultimately find about this after checking an OWASP ASVS check list and might make the extra effort to actually enable it. In many cases, it won't be enabled even if it could because people don't know what this is and what the impact is.
I was thinking about enabling it by default if support is detected through server metadata (
Actually (in the long term), a per-provider property such as
PKCE could be manually enabled by setting
Yes when I was saying that in the long run, I would expect it would be enabled by default, this was possibly in the next major release. (*): For example, |
Oh sorry, I missed (or did not properly parse 😄) the section about per-registration customization. This looks interesting. I'm wondering if there is some way such a setup could use the server metadata (actually more likely to be in |
If I'm understanding you correctly, I see your point that non-OIDC flows appear to always require PKCE -- if OAuth 2.1 were promoted to RFC status.
I think we have to be careful reading too much into the summary and overview information in the spec. The specific details we've discussed in Section 7.5.2 are key. However, I think we're reading them the same way. Regardless, without another way to determine that the AS supports PKCE, it can't simply be enabled due to the potential for breaking deployments, and I think that would be the case even in a major where we can make some breaking changes (though I could be wrong on that point). Which is why...
I like this idea! However, the Lastly, regarding my other comment:
I feel it helps with any of the other enhancements we propose, so that customization options for enabling PKCE can be applied using bean configuration instead of customizing only via the DSL. Do you agree that this would also be a worthwhile enhancement? |
Yes, I agree this would certainly help. |
Thanks so much @randomstuff! I appreciate the conversation immensely. |
For those following this issue as an FYI I have created gh-16382 |
Since #6548 it is possible to enable PKCE for confidential clients - great!
Unfortunately, this can only be configured in a programmatic way.
It would be nice to encode this information ("use PKCE for confidential clients, yes or no") inside the
ClientRegistration
, such that it is handled automatically per client.The current programmatic configuration seems to force the usage of some custom
OAuth2AuthorizationRequestResolver
(which delegates to a customized or uncustomized version ofDefaultOAuth2AuthorizationRequestResolver
) if different confidential clients need different pkce handling.The text was updated successfully, but these errors were encountered: