Skip to content

Commit

Permalink
fix: check kid before using as array index
Browse files Browse the repository at this point in the history
  • Loading branch information
bshaffer authored Nov 1, 2022
1 parent ddfaddc commit bad1b04
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/JWT.php
Original file line number Diff line number Diff line change
Expand Up @@ -425,14 +425,15 @@ private static function getKey(
return $keyOrKeyArray;
}

if (empty($kid)) {
throw new UnexpectedValueException('"kid" empty, unable to lookup correct key');
}

if ($keyOrKeyArray instanceof CachedKeySet) {
// Skip "isset" check, as this will automatically refresh if not set
return $keyOrKeyArray[$kid];
}

if (empty($kid)) {
throw new UnexpectedValueException('"kid" empty, unable to lookup correct key');
}
if (!isset($keyOrKeyArray[$kid])) {
throw new UnexpectedValueException('"kid" invalid, unable to lookup correct key');
}
Expand Down

0 comments on commit bad1b04

Please sign in to comment.