Skip to content

Commit

Permalink
fix: firebase jwt decode for 5.5+ (#402)
Browse files Browse the repository at this point in the history
  • Loading branch information
bshaffer authored May 16, 2022
1 parent 5b18956 commit d96d3e1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/AccessToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Exception;
use Firebase\JWT\ExpiredException;
use Firebase\JWT\JWT;
use Firebase\JWT\Key;
use Firebase\JWT\SignatureInvalidException;
use Google\Auth\Cache\MemoryCacheItemPool;
use Google\Auth\HttpHandler\HttpClientCache;
Expand Down Expand Up @@ -257,13 +258,12 @@ private function verifyRs256($token, array $certs, $audience = null, $issuer = n
]);

// create an array of key IDs to certs for the JWT library
$keys[$cert['kid']] = $rsa->getPublicKey();
$keys[$cert['kid']] = new Key($rsa->getPublicKey(), 'RS256');
}

$payload = $this->callJwtStatic('decode', [
$token,
$keys,
['RS256']
]);

if ($audience) {
Expand Down
10 changes: 5 additions & 5 deletions tests/AccessTokenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function testVerify(
$this->cache->reveal()
);

$token->mocks['decode'] = function ($token, $publicKey, $allowedAlgs) use ($payload, $exception) {
$token->mocks['decode'] = function ($token, $keys) use ($payload, $exception) {
$this->assertEquals($this->token, $token);

if ($exception) {
Expand Down Expand Up @@ -307,9 +307,9 @@ public function testRetrieveCertsFromLocationLocalFile()
$this->cache->reveal()
);

$token->mocks['decode'] = function ($token, $publicKey, $allowedAlgs) {
$token->mocks['decode'] = function ($token, $keys) {
$this->assertEquals($this->token, $token);
$this->assertEquals(['RS256'], $allowedAlgs);
$this->assertEquals('RS256', array_pop($keys)->getAlgorithm());

return (object) $this->payload;
};
Expand Down Expand Up @@ -431,9 +431,9 @@ public function testRetrieveCertsFromLocationRemote()
$this->cache->reveal()
);

$token->mocks['decode'] = function ($token, $publicKey, $allowedAlgs) {
$token->mocks['decode'] = function ($token, $keys) {
$this->assertEquals($this->token, $token);
$this->assertEquals(['RS256'], $allowedAlgs);
$this->assertEquals('RS256', array_pop($keys)->getAlgorithm());

return (object) $this->payload;
};
Expand Down

0 comments on commit d96d3e1

Please sign in to comment.