-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add PKCE support #93
Add PKCE support #93
Conversation
8dad963
to
d6209df
Compare
I started adding tests for The first stab at this stops at |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @Kehrlann! Please see initial review comments.
...a/org/springframework/security/oauth2/server/authorization/PkceCodeChallengeMethodNames.java
Outdated
Show resolved
Hide resolved
...y/oauth2/server/authorization/authentication/OAuth2AuthorizationCodeAuthenticationToken.java
Outdated
Show resolved
Hide resolved
...ecurity/oauth2/server/authorization/authentication/OAuth2AccessTokenAuthenticationToken.java
Outdated
Show resolved
Hide resolved
.../org/springframework/security/oauth2/server/authorization/web/OAuth2TokenEndpointFilter.java
Outdated
Show resolved
Hide resolved
f57faa0
to
24f6068
Compare
The PR is ready for review. Still to be decided: how do we identify public clients in
|
Thoughts on letting all clients (public and confidential) that use authorization code also use PKCE (confidential will have both secret & PKCE), but only require PKCE for public clients. (those without client secrets) like in spring-projects/spring-security#6548 ? |
With the current proposed implementation, confidential clients may send PKCE parameters. However, those parameters will not be validated. Not sure if we should put this in v1 ? It makes sense to validate whatever PKCE params confidential clients send, especially if we're allowing confidential clients to do it in spring-security. |
Rebased on top of master. For info, I have only checked the build & ran the tests on conflicting commits. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the updates @Kehrlann! I left a few comments inline.
Also, can you please squash the commits on next update.
Thanks.
...ingframework/security/oauth2/server/authorization/web/OAuth2AuthorizationEndpointFilter.java
Outdated
Show resolved
Hide resolved
...ingframework/security/oauth2/server/authorization/web/OAuth2AuthorizationEndpointFilter.java
Outdated
Show resolved
Hide resolved
...ingframework/security/oauth2/server/authorization/web/OAuth2AuthorizationEndpointFilter.java
Outdated
Show resolved
Hide resolved
...ingframework/security/oauth2/server/authorization/web/OAuth2AuthorizationEndpointFilter.java
Outdated
Show resolved
Hide resolved
.../org/springframework/security/oauth2/server/authorization/web/OAuth2TokenEndpointFilter.java
Show resolved
Hide resolved
...auth2/server/authorization/authentication/OAuth2AuthorizationCodeAuthenticationProvider.java
Outdated
Show resolved
Hide resolved
...auth2/server/authorization/authentication/OAuth2AuthorizationCodeAuthenticationProvider.java
Outdated
Show resolved
Hide resolved
...auth2/server/authorization/authentication/OAuth2AuthorizationCodeAuthenticationProvider.java
Show resolved
Hide resolved
...ecurity/oauth2/server/authorization/authentication/OAuth2AccessTokenAuthenticationToken.java
Outdated
Show resolved
Hide resolved
...auth2/server/authorization/authentication/OAuth2AuthorizationCodeAuthenticationProvider.java
Outdated
Show resolved
Hide resolved
b418fe0
to
3c13385
Compare
Included all corrections, squashed. There's still one open question, and we should be almost good to go. |
Thanks for the great work @Kehrlann ! This is now in master! FYI, I added a polish commit with some minor updates. Also, I discovered an issue when reviewing the integration test Apologies, as I missed this during the review process. I decided to go ahead an apply the change. Take a look at the commit 5c31fb1 and let me know if you have any questions. Thanks again for all the great work! |
This is a first stab at PKCE implementation - see #45 . The idea is to validate the structure of how to achieve PKCE validation, and then start iterating from there.
Notes:
org.springframework.security.oauth2.client.web.DefaultOAuth2AuthorizationRequestResolver#createHash
. We might want to make that public in spring-security at some point ?TODOs:
Authorization endpoint
registeredClient.clientSecret
is blank)OAuth2AuthorizationEndpointFilter
Token endpoint
code_verifier
for both "plain" and "S256" methods (for public clients)code_challenge_method
is null, default to plainOAuth2AuthorizationCodeAuthenticationProvider
(null checks, try-catches)OAuth2AuthorizationCodeAuthenticationProvider.authenticate
, authenticate public client - See RFC 6749 - 3.2.1. Token Endpoint > Client Authentication [1]Integration tests
[1] In the "authorization_code" "grant_type" request to the token endpoint, an unauthenticated client MUST send its "client_id" to prevent itself from inadvertently accepting a code intended for a client with a different "client_id". This protects the client from substitution of the authentication code. (It provides no additional security for the protected resource.)