-
Notifications
You must be signed in to change notification settings - Fork 4k
Support for PKCE in server as per OAUTH PKCE RFC #675
Support for PKCE in server as per OAUTH PKCE RFC #675
Conversation
Is there any plan to merge this into the master ? I've tried a local merge and there is no conflict and unit tests are all green. The draft-ietf-oauth-native-apps now indicates that PKCE MUST be implemented for public native apps : https://tools.ietf.org/html/draft-ietf-oauth-native-apps-12#section-6 making this pull request even more interesting. Thanks. |
Should this PR be assigned to a specific person? |
Thanks for the PR @marcolenzo. We are focusing our efforts in the new OAuth2/OIDC support in Spring Security 5. |
@jgrandja Will there be PKCE support in Spring Security 5? If not, what would be the best way to authorize mobile apps to call REST API using OAuth2? |
@osgafarov Yes, we will provide support for PKCE in Spring Security 5, however, that will be a while still. Our current focus is in re-writing the client and that is what will go GA later this November. We're planning a 5.1 shortly afterward which will include the Resource Server support and then will start working on the Authorization Server side of things. So the Authorization Server support probably won't be out until mid 2018. |
Thanks @jgrandja for your answer. Will follow the development of the Spring Security 5. |
I would suggest that instead of changing the code do it in a filter, like csrf() - so it would be pkce(). |
@marcolenzo have you got an example (or advice) for implementing this without library changes (or minimal changes that can be applied with aop or replacing simple classes)? Edit: |
@OrangeDog did you have the chance to revise the content of the PR itself? https://github.com/spring-projects/spring-security-oauth/pull/675/files An alternative option that does not fiddle with the internals of the library is to port the logic I introduced into a filter as suggested by @ghost #675 (comment) |
Having a closer look this doesn't follow the RFC:
The error "invalid_code_verifier" is not part of the standard. |
You should probably also use constant-time comparisons, not import static java.nio.charset.StandardCharsets.US_ASCII;
import java.security.MessageDigest;
import java.util.Base64;
// ...
MessageDigest md = MessageDigest.getInstance("SHA-256");
Base64.Encoder b64 = Base64.getUrlEncoder().withoutPadding();
byte[] expected = b64.encode(md.digest(verifier.getBytes(US_ASCII)));
return MessageDigest.isEqual(expected, challenge.getBytes(US_ASCII)); |
I implemented the OAUTH PKCE as per RFC 7636 https://www.rfc-editor.org/rfc/rfc7636.txt
I tried to be as less intrusive as possible on the existent code. I was wondering if I had to add the
code_challenge
andcode_challenge_method
parameters in theAuthorizationRequest
but I eventually opted not to and to rely on the existent maps.This should complete implementation for issue #655