Skip to content

Commit

Permalink
add docblocks for new PKCE methods
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronpk committed Feb 11, 2021
1 parent bad6353 commit 647394d
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/Two/AbstractProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -466,23 +466,39 @@ protected function usesPKCE()
return $this->usesPKCE;
}

/**
* Generates a random string of the right length for the PKCE code verifier.
*
* @return string
*/
protected function getCodeVerifier()
{
return Str::random(96);
}

protected function getCodeChallenge()
/**
* Generates the PKCE code challenge based on the PKCE code verifier in the session.
*
* @return string
*/
protected function getCodeChallenge()
{
$verifier = $this->request->session()->pull('code_verifier');
$hashed = hash('sha256', $verifier, true);

return rtrim(strtr(base64_encode($hashed), '+/', '-_'), '=');
}

protected function getCodeChallengeMethod()
/**
* Returns the hash method used to calculate the PKCE code challenge
*
* @return string
*/
protected function getCodeChallengeMethod()
{
return 'S256';
}

/**
* Set the custom parameters of the request.
*
Expand Down

0 comments on commit 647394d

Please sign in to comment.