Skip to content

Commit

Permalink
fix: invalid kid exception handling
Browse files Browse the repository at this point in the history
  • Loading branch information
hschoenenberger committed Dec 10, 2024
1 parent 7844c0c commit cf00c5d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Provider/Traits/TokenValidatorTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Firebase\JWT\SignatureInvalidException;
use PrestaShop\OAuth2\Client\Provider\CachedFile;
use PrestaShop\OAuth2\Client\Provider\Exception;
use PrestaShop\OAuth2\Client\Provider\Exception\KidInvalidException;

trait TokenValidatorTrait
{
Expand Down Expand Up @@ -62,8 +61,11 @@ public function verifyToken($token, $refreshJwks = false)
throw new Exception\SignatureInvalidException($e->getMessage());
} catch (\UnexpectedValueException $e) {
// FIXME: check kid header by ourselves
if (!$refreshJwks && $e->getMessage() == '"kid" invalid, unable to lookup correct key') {
return $this->verifyToken($token, true);
if ($e->getMessage() == '"kid" invalid, unable to lookup correct key') {
if (!$refreshJwks) {
return $this->verifyToken($token, true);
}
throw new Exception\KidInvalidException($e->getMessage());
}
throw new Exception\TokenInvalidException($e->getMessage());
} catch (\Throwable $e) {
Expand Down

0 comments on commit cf00c5d

Please sign in to comment.