-
Notifications
You must be signed in to change notification settings - Fork 6k
Add ClientRegistration.clientSettings.requireProofKey to Enable PKCE #16382
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
Closed
Tracked by
#16378
Labels
in: oauth2
An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose)
type: enhancement
A general enhancement
Comments
7 tasks
kse-music
added a commit
to kse-music/spring-security
that referenced
this issue
Jan 9, 2025
Closes spring-projectsgh-16382 Signed-off-by: DingHao <[email protected]>
kse-music
added a commit
to kse-music/spring-security
that referenced
this issue
Jan 9, 2025
Closes spring-projectsgh-16382 Signed-off-by: DingHao <[email protected]>
kse-music
added a commit
to kse-music/spring-security
that referenced
this issue
Jan 10, 2025
Closes spring-projectsgh-16382 Signed-off-by: DingHao <[email protected]>
kse-music
added a commit
to kse-music/spring-security
that referenced
this issue
Jan 17, 2025
Closes spring-projectsgh-16382 Signed-off-by: DingHao <[email protected]>
Closing in favor of the pull request gh-16386 |
rwinch
pushed a commit
that referenced
this issue
Jan 17, 2025
Closes gh-16382 Signed-off-by: DingHao <[email protected]>
rwinch
added a commit
that referenced
this issue
Jan 17, 2025
When requireProofKey=true, DefaultServerOAuth2AuthorizationRequestResolver enables PKCE support. Issue gh-16382
rwinch
added a commit
that referenced
this issue
Jan 17, 2025
This ensures that ClientRegistration.Builder.ClientSettings cannot be null. This has a slight advantage in terms of null safety to making this check happen in the build method since the Builder does not have a null field either. Issue gh-16382
rwinch
added a commit
that referenced
this issue
Jan 17, 2025
rwinch
added a commit
that referenced
this issue
Jan 17, 2025
This adds AuthorizationGrantType.toString() which makes debuging easier. In particular, it will help when performing unit tests which validate the AuthorizationGrantType. Issue gh-16382
rwinch
added a commit
that referenced
this issue
Jan 17, 2025
PKCE is only valid for AuthorizationGrantType.AUTHORIZATION_CODE so the code should validate this. Issue gh-16382
rwinch
added a commit
that referenced
this issue
Jan 17, 2025
rwinch
added a commit
that referenced
this issue
Jan 17, 2025
Initially it was proposed to put ClientSettings as a top level class, but to be consistent with ProviderDetails, this commit moves ClientSettings to be an inner class of ClientRegistration Issue gh-16382 # Conflicts: # oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/registration/ClientSettings.java
kwondh5217
pushed a commit
to kwondh5217/spring-security
that referenced
this issue
Feb 4, 2025
Closes spring-projectsgh-16382 Signed-off-by: DingHao <[email protected]> Signed-off-by: Daeho Kwon <[email protected]>
kwondh5217
pushed a commit
to kwondh5217/spring-security
that referenced
this issue
Feb 4, 2025
When requireProofKey=true, DefaultServerOAuth2AuthorizationRequestResolver enables PKCE support. Issue spring-projectsgh-16382 Signed-off-by: Daeho Kwon <[email protected]>
kwondh5217
pushed a commit
to kwondh5217/spring-security
that referenced
this issue
Feb 4, 2025
This ensures that ClientRegistration.Builder.ClientSettings cannot be null. This has a slight advantage in terms of null safety to making this check happen in the build method since the Builder does not have a null field either. Issue spring-projectsgh-16382 Signed-off-by: Daeho Kwon <[email protected]>
kwondh5217
pushed a commit
to kwondh5217/spring-security
that referenced
this issue
Feb 4, 2025
Issue spring-projectsgh-16382 Signed-off-by: Daeho Kwon <[email protected]>
kwondh5217
pushed a commit
to kwondh5217/spring-security
that referenced
this issue
Feb 4, 2025
This adds AuthorizationGrantType.toString() which makes debuging easier. In particular, it will help when performing unit tests which validate the AuthorizationGrantType. Issue spring-projectsgh-16382 Signed-off-by: Daeho Kwon <[email protected]>
kwondh5217
pushed a commit
to kwondh5217/spring-security
that referenced
this issue
Feb 4, 2025
PKCE is only valid for AuthorizationGrantType.AUTHORIZATION_CODE so the code should validate this. Issue spring-projectsgh-16382 Signed-off-by: Daeho Kwon <[email protected]>
kwondh5217
pushed a commit
to kwondh5217/spring-security
that referenced
this issue
Feb 4, 2025
Issue spring-projectsgh-16382 Signed-off-by: Daeho Kwon <[email protected]>
kwondh5217
pushed a commit
to kwondh5217/spring-security
that referenced
this issue
Feb 4, 2025
Initially it was proposed to put ClientSettings as a top level class, but to be consistent with ProviderDetails, this commit moves ClientSettings to be an inner class of ClientRegistration Issue spring-projectsgh-16382 # Conflicts: # oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/registration/ClientSettings.java Signed-off-by: Daeho Kwon <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
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.clientSettings.requireProofKey=(true|false)
(default is false) similar to what was proposed in gh-12219.UPDATE After speaking with @jgrandja offline, he suggested the property
ClientRegistration.clientSettings.requireProofKey=(true|false)
to align with Autorization Server'sRegisteredClient.[clientSettings](https://github.com/spring-projects/spring-authorization-server/blob/1.4.1/oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/client/RegisteredClient.java#L73).requireProofKey
. In this case, we can introduce theClientSettings
in the same package asClientRegistration
and it does NOT need to be backed by aMap
or extendAbstractSettings
. If needed, we can later introduceAbstractSettings
and back it by aMap
at that point.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: