Skip to content

Commit f2f74b9

Browse files
Merge pull request #317 from jumbojett/fix/fallback-code_challenge_methods_supported-not-provided
fix: use empty array as fallback if the IdP is not exposing/supportin…
2 parents 7687f03 + 5305713 commit f2f74b9

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/OpenIDConnectClient.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ protected function addAdditionalJwk($jwk) {
492492
* @param string $param
493493
* @param string $default optional
494494
* @throws OpenIDConnectClientException
495-
* @return string
495+
* @return string|array
496496
*
497497
*/
498498
protected function getProviderConfigValue($param, $default = null) {
@@ -682,18 +682,18 @@ private function requestAuthorization() {
682682
}
683683

684684
// If the client supports Proof Key for Code Exchange (PKCE)
685-
$ccm = $this->getCodeChallengeMethod();
686-
if (!empty($ccm) && in_array($this->getCodeChallengeMethod(), $this->getProviderConfigValue('code_challenge_methods_supported'))) {
685+
$codeChallengeMethod = $this->getCodeChallengeMethod();
686+
if (!empty($codeChallengeMethod) && in_array($codeChallengeMethod, $this->getProviderConfigValue('code_challenge_methods_supported', []), true)) {
687687
$codeVerifier = bin2hex(random_bytes(64));
688688
$this->setCodeVerifier($codeVerifier);
689-
if (!empty($this->pkceAlgs[$this->getCodeChallengeMethod()])) {
690-
$codeChallenge = rtrim(strtr(base64_encode(hash($this->pkceAlgs[$this->getCodeChallengeMethod()], $codeVerifier, true)), '+/', '-_'), '=');
689+
if (!empty($this->pkceAlgs[$codeChallengeMethod])) {
690+
$codeChallenge = rtrim(strtr(base64_encode(hash($this->pkceAlgs[$codeChallengeMethod], $codeVerifier, true)), '+/', '-_'), '=');
691691
} else {
692692
$codeChallenge = $codeVerifier;
693693
}
694694
$auth_params = array_merge($auth_params, [
695695
'code_challenge' => $codeChallenge,
696-
'code_challenge_method' => $this->getCodeChallengeMethod()
696+
'code_challenge_method' => $codeChallengeMethod
697697
]);
698698
}
699699

0 commit comments

Comments
 (0)