Add ClientRegistration.codeChallengeMethod to Enable PKCE #16382
Labels
for: team-attention
This ticket should be discussed as a team before proceeding
in: oauth2
An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose)
type: enhancement
A general enhancement
PKCE is recommended to prevent CSRF and authorization code injection attacks. We should further simplify enabling PKCE for Confidential Clients.
Current Behavior
The simplest Spring Boot application that requires PKCE is shown below:
Shortcomings
This will be simplified to just a Bean declaration when gh-16380 is implemented, but this still has the following downsides:
For something that is considered a best security practice (rather than an edge case), we must do better.
Solution
I think what makes the most sense is adding a property
ClientRegistration.codeChallengeMethod=S256
(default is null or disabled) similar to what was proposed in gh-12219.Note that this is on the
ClientRegistration
because this is how Spring Security decides which grant type to use. If a single application has multiple grant types for the same provider (or different providers), then it is possible that PKCE is not even valid for a specific registration.This also has the advantage of making it simple for users to define a property using Spring Boot to declaratively enable PKCE with Spring Security.
Previous Discussions
Perhaps this is no longer a problem, but I wanted to bring it up proactively. I know that this was previously declined because:
authorization_code
, so there was hesitation around introducing a PKCE property. I do not find this a valid argument. Spring Security already has properties that are only used for specific grant types and custom validation based upon the grant type. For example, theauthorizationUri
andtokenUri
only make sense for theauthorization_code
grant type and not forclient_credentials
. A property for enabling PKCE is just another property, that is validated differently by the grant type.cc @jgrandja @sjohnr
The text was updated successfully, but these errors were encountered: