Skip to content

Commit

Permalink
Merge pull request #828 from Sephster/master
Browse files Browse the repository at this point in the history
Fixed ordering so we only hash after base64 encoding
  • Loading branch information
Sephster authored Dec 23, 2017
2 parents f11e4c8 + 1c36b70 commit 0013844
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Grant/AuthCodeGrant.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public function respondToAccessTokenRequest(
case 'S256':
if (
hash_equals(
strtr(rtrim(base64_encode(hash('sha256', $codeVerifier)), '='), '+/', '-_'),
hash('sha256', strtr(rtrim(base64_encode($codeVerifier), '='), '+/', '-_')),
$authCodePayload->code_challenge
) === false
) {
Expand Down
2 changes: 1 addition & 1 deletion tests/Grant/AuthCodeGrantTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ public function testRespondToAccessTokenRequestCodeChallengeS256()
'user_id' => 123,
'scopes' => ['foo'],
'redirect_uri' => 'http://foo/bar',
'code_challenge' => strtr(rtrim(base64_encode(hash('sha256', 'foobar')), '='), '+/', '-_'),
'code_challenge' => hash('sha256', strtr(rtrim(base64_encode('foobar'), '='), '+/', '-_')),
'code_challenge_method' => 'S256',
]
)
Expand Down

0 comments on commit 0013844

Please sign in to comment.