Skip to content

Commit

Permalink
fix: allowed_algs not properly set for string value (#489)
Browse files Browse the repository at this point in the history
  • Loading branch information
bshaffer authored Oct 17, 2023
1 parent b882500 commit 0042b52
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/OAuth2.php
Original file line number Diff line number Diff line change
Expand Up @@ -1723,7 +1723,7 @@ private function getFirebaseJwtKeys($publicKey, $allowedAlgs)

$allowedAlg = null;
if (is_string($allowedAlgs)) {
$allowedAlg = $allowedAlg;
$allowedAlg = $allowedAlgs;
} elseif (is_array($allowedAlgs)) {
if (count($allowedAlgs) > 1) {
throw new \InvalidArgumentException(
Expand Down
6 changes: 6 additions & 0 deletions tests/OAuth2Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -1250,8 +1250,14 @@ public function testShouldReturnAValidIdToken()
$alg = 'RS256';
$jwtIdToken = JWT::encode($origIdToken, $privateKey, $alg);
$o->setIdToken($jwtIdToken);

// Test with array alg
$roundTrip = $o->verifyIdToken($publicKey, [$alg]);
$this->assertEquals($origIdToken['aud'], $roundTrip->aud);

// Test with string alg
$roundTrip2 = $o->verifyIdToken($publicKey, $alg);
$this->assertEquals($origIdToken['aud'], $roundTrip2->aud);
}
}

Expand Down

0 comments on commit 0042b52

Please sign in to comment.