kelvinmo/simplejwt

Undefined variable: $kid, JWE.php:134 when using JWE SymmetricKey

Closed this issue · 1 comments

Hi,

Yesterday I completed a JWE integration and noted that there is an error in simplejwt/src/SimpleJWT/JWE.php:134

$agreed_key = $key_enc->deriveKey($keys, $headers, $kid);

The variable $kid is not defined in this scope, it doesn't get defined untill line number 149, causing either an error or a notice, depending on the system. Default in Laravel it will throw a nasty error.

I had to remove , $kid in order to get it working with the following code:

$set = new KeySet();
$key = new SymmetricKey('HIDDEN_KEY', 'bin');
$set->add($key);

$token = $_GET['orderKey'];

try {
       $jwe = JWE::decrypt($token, $set, 'dir');
       $data = $jwe->getPlaintext();
       $data = json_decode($data);

       print_r($data);
} catch (InvalidTokenException $e) {
       print_r($e);
}

This issue seems similar to #13 , however a little bit different.

Can you test the issue-19 branch (as mentioned in PR #20) to see whether this fixes the issue.