diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php index 5d8afeaf..b3c8d618 100644 --- a/.php-cs-fixer.php +++ b/.php-cs-fixer.php @@ -2,7 +2,7 @@ require __DIR__.'/vendor/autoload.php'; -return (new \MattAllan\LaravelCodeStyle\Config()) +return (new \Jubeki\LaravelCodeStyle\Config()) ->setFinder( \PhpCsFixer\Finder::create() ->exclude(['bootstrap', 'docker', 'public', 'resources', 'storage']) diff --git a/composer.json b/composer.json index 2e7a5886..eb8f94d4 100644 --- a/composer.json +++ b/composer.json @@ -21,12 +21,12 @@ } ], "require": { - "firebase/php-jwt": "^5.2", + "firebase/php-jwt": "^5.5|^6.0", "guzzlehttp/guzzle": "^7.0", "phpseclib/phpseclib": "^2.0" }, "require-dev": { - "matt-allan/laravel-code-style": "dev-main", + "jubeki/laravel-code-style": "^1.0", "mockery/mockery": "^1.4", "nesbot/carbon": "^2.43", "phpunit/phpunit": "^9.5" diff --git a/src/LtiMessageLaunch.php b/src/LtiMessageLaunch.php index 4a680dc4..38c0d6ef 100644 --- a/src/LtiMessageLaunch.php +++ b/src/LtiMessageLaunch.php @@ -286,13 +286,15 @@ private function getPublicKey() foreach ($publicKeySet['keys'] as $key) { if ($key['kid'] == $this->jwt['header']['kid']) { try { - return openssl_pkey_get_details( - JWK::parseKeySet([ - 'keys' => [$key], - ])[$key['kid']] - ); + $keySet = JWK::parseKeySet([ + 'keys' => [$key], + ]); } catch (\Exception $e) { - return false; + // Do nothing + } + + if (isset($keySet[$key['kid']])) { + return $keySet[$key['kid']]; } } } @@ -385,7 +387,7 @@ private function validateJwtSignature() // Validate JWT signature try { - JWT::decode($this->request['id_token'], $public_key['key'], ['RS256']); + JWT::decode($this->request['id_token'], $public_key, ['RS256']); } catch (ExpiredException $e) { // Error validating signature. throw new LtiException(static::ERR_INVALID_SIGNATURE);