Skip to content

Commit 491ab3a

Browse files
authored
bugfix: 'kid' not in given key list
if 'kid' value is not found in the given key map, should throw an exception. Instead, it was outputting a php warning for using an undefined index, resulting in a null key.
1 parent 3aa3d97 commit 491ab3a

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/JWT.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ public static function decode($jwt, $key, $allowed_algs = array())
9898
}
9999
if (is_array($key) || $key instanceof \ArrayAccess) {
100100
if (isset($header->kid)) {
101+
if(!isset($key[$header->kid])) {
102+
throw new UnexpectedValueException('"kid" not found in key map, unable to lookup correct key');
103+
}
101104
$key = $key[$header->kid];
102105
} else {
103106
throw new UnexpectedValueException('"kid" empty, unable to lookup correct key');

0 commit comments

Comments
 (0)