Skip to content

Commit

Permalink
Merge pull request #671 from oauthlib/670-pkce-requestinfo
Browse files Browse the repository at this point in the history
Fix 670. AuthCode API must return the new PKCE attribute
  • Loading branch information
JonathanHuot committed May 7, 2019
2 parents b6b4d9f + 5899512 commit 18425dd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions oauthlib/oauth2/rfc6749/grant_types/authorization_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,12 +405,15 @@ def validate_authorization_request(self, request):
raise errors.MissingCodeChallengeError(request=request)

if request.code_challenge is not None:
request_info["code_challenge"] = request.code_challenge

# OPTIONAL, defaults to "plain" if not present in the request.
if request.code_challenge_method is None:
request.code_challenge_method = "plain"

if request.code_challenge_method not in self._code_challenge_methods:
raise errors.UnsupportedCodeChallengeMethodError(request=request)
request_info["code_challenge_method"] = request.code_challenge_method

# OPTIONAL. The scope of the access request as described by Section 3.3
# https://tools.ietf.org/html/rfc6749#section-3.3
Expand Down
6 changes: 4 additions & 2 deletions tests/oauth2/rfc6749/grant_types/test_authorization_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,10 @@ def test_pkce_default_method(self):
self.mock_validator.is_pkce_required.return_value = required
self.request.code_challenge = "present"
_, ri = self.auth.validate_authorization_request(self.request)
self.assertIsNotNone(ri["request"].code_challenge_method)
self.assertEqual(ri["request"].code_challenge_method, "plain")
self.assertIn("code_challenge", ri)
self.assertIn("code_challenge_method", ri)
self.assertEqual(ri["code_challenge"], "present")
self.assertEqual(ri["code_challenge_method"], "plain")

def test_pkce_wrong_method(self):
for required in [True, False]:
Expand Down

0 comments on commit 18425dd

Please sign in to comment.