Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Save code challenge with authorization code #161

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

Merged

Conversation

@martinssonj
Copy link
Contributor

@martinssonj martinssonj commented Sep 27, 2022

Summary

For getAuthorizationCode it is expected that the code contains a codeChallenge and a codeChallengeMethod but in saveAuthorizationCode it is not saved.

By adding the possibility to save codeChallenge and codeChallengeMethod the PKCE flow now works without any other changes.

Linked issue(s)

#76

Involved parts of the project

Authorization Code Flow with PKCE

Added tests?

Yes

OAuth2 standard

OAuth 2.0 RFC 7636

Reproduction

First authorize

curl --location --request POST 'http://localhost:8081/oauth2/authorize' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'client_id=test' \
--data-urlencode 'scope=openid' \
--data-urlencode 'redirect_uri=http://localhost:5000/callback' \
--data-urlencode 'state=e3e96ed8-889d-4dac-a680-6a47f5efbb14' \
--data-urlencode 'response_type=code' \
--data-urlencode 'username=user@user.com' \
--data-urlencode 'password=password' \
--data-urlencode 'code_challenge=challenge' \
--data-urlencode 'code_challenge_method=plain'

Use code from redirect and create token by:

curl --location --request POST 'http://localhost:8081/oauth2/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'client_id=test' \
--data-urlencode 'grant_type=authorization_code' \
--data-urlencode 'state=e3e96ed8-889d-4dac-a680-6a47f5efbb14' \
--data-urlencode 'response_type=code' \
--data-urlencode 'code_verifier=challenge' \
--data-urlencode 'code_challenge_method=plain' \
--data-urlencode 'code=7590791f34ddd18b7cdc398eee673051397bde3230533cdc24bd472ee472be02' \
--data-urlencode 'redirect_uri=http://localhost:5000/callback'

nekman reacted with thumbs up emoji
Copy link
Member

Thank you so much @martinssonj I will take a look at this 👍

martinssonj reacted with thumbs up emoji

@jankapunkt jankapunkt added this to the v4.3 milestone Oct 31, 2022
@jankapunkt jankapunkt added the compliance 📜 OAuth 2.0 standard compliance label Oct 31, 2022
@jankapunkt jankapunkt merged commit 19f7dc4 into node-oauth:feature-pkce Oct 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@jankapunkt jankapunkt jankapunkt approved these changes

@jorenvandeweyer jorenvandeweyer jorenvandeweyer approved these changes

Assignees

No one assigned

Labels

compliance 📜 OAuth 2.0 standard compliance

Projects

None yet

Milestone

v4.3

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /