From 1c2e2e1b6fb03b47424fd0b8e9705a4a1edff84a Mon Sep 17 00:00:00 2001 From: Chris Doehring Date: Mon, 7 Dec 2020 13:33:37 +0100 Subject: [PATCH 1/2] Add compatibility for `lcobucci/jwt` `^4.0` --- src/Http/Controllers/AccessTokenController.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Http/Controllers/AccessTokenController.php b/src/Http/Controllers/AccessTokenController.php index 3898261..2d46a34 100644 --- a/src/Http/Controllers/AccessTokenController.php +++ b/src/Http/Controllers/AccessTokenController.php @@ -41,8 +41,20 @@ public function issueToken(ServerRequestInterface $request) $payload = json_decode($response->getBody()->__toString(), true); if (isset($payload['access_token'])) { - $tokenId = $this->jwt->parse($payload['access_token'])->getClaim('jti'); + /* @deprecated the jwt property will be removed in a future Laravel Passport release */ + $token = $this->jwt->parse($payload['access_token']); + if (method_exists($token, 'getClaim')) { + $tokenId = $token->getClaim('jti'); + } else if (method_exists($token, 'claims')) { + $tokenId = $token->claims()->get('jti'); + } else { + throw new \RuntimeException('This package is not compatible to the used Laravel Passport version.'); + } + $token = $this->tokens->find($tokenId); + if (!$token instanceof Token) { + return $response; + } if ($token->client->firstParty() && LumenPassport::$allowMultipleTokens) { // We keep previous tokens for password clients From 72429b9b258b6d5653b4cc7a1b5f8a2c5dfb6269 Mon Sep 17 00:00:00 2001 From: Denis Mysenko Date: Tue, 8 Dec 2020 12:32:45 +1100 Subject: [PATCH 2/2] Update AccessTokenController.php --- src/Http/Controllers/AccessTokenController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Http/Controllers/AccessTokenController.php b/src/Http/Controllers/AccessTokenController.php index 2d46a34..5a78e24 100644 --- a/src/Http/Controllers/AccessTokenController.php +++ b/src/Http/Controllers/AccessTokenController.php @@ -48,7 +48,7 @@ public function issueToken(ServerRequestInterface $request) } else if (method_exists($token, 'claims')) { $tokenId = $token->claims()->get('jti'); } else { - throw new \RuntimeException('This package is not compatible to the used Laravel Passport version.'); + throw new \RuntimeException('This package is not compatible with the Laravel Passport version used'); } $token = $this->tokens->find($tokenId);