Skip to content

Commit

Permalink
bugfix: 'kid' not in given key list
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
stampycode committed Dec 12, 2016
1 parent 3aa3d97 commit 491ab3a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/JWT.php
Expand Up @@ -98,6 +98,9 @@ public static function decode($jwt, $key, $allowed_algs = array())
}
if (is_array($key) || $key instanceof \ArrayAccess) {
if (isset($header->kid)) {
if(!isset($key[$header->kid])) {
throw new UnexpectedValueException('"kid" not found in key map, unable to lookup correct key');
}
$key = $key[$header->kid];
} else {
throw new UnexpectedValueException('"kid" empty, unable to lookup correct key');
Expand Down

0 comments on commit 491ab3a

Please sign in to comment.