Skip to content

Commit 506c488

Browse files
authored
fix: bad firebase call (#2245)
1 parent cb5250c commit 506c488

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/AccessToken/Verify.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
use Firebase\JWT\ExpiredException as ExpiredExceptionV3;
2222
use Firebase\JWT\SignatureInvalidException;
23+
use Firebase\JWT\Key;
2324
use GuzzleHttp\Client;
2425
use GuzzleHttp\ClientInterface;
2526
use InvalidArgumentException;
@@ -99,11 +100,15 @@ public function verifyIdToken($idToken, $audience = null)
99100
$certs = $this->getFederatedSignOnCerts();
100101
foreach ($certs as $cert) {
101102
try {
102-
$payload = $this->jwt->decode(
103-
$idToken,
104-
$this->getPublicKey($cert),
105-
array('RS256')
106-
);
103+
$args = [$idToken];
104+
$publicKey = $this->getPublicKey($cert);
105+
if (class_exists(Key::class)) {
106+
$args[] = new Key($publicKey, 'RS256');
107+
} else {
108+
$args[] = $publicKey;
109+
$args[] = ['RS256'];
110+
}
111+
$payload = \call_user_func_array([$this->jwt, 'decode'], $args);
107112

108113
if (property_exists($payload, 'aud')) {
109114
if ($audience && $payload->aud != $audience) {

0 commit comments

Comments
 (0)