Skip to content

Commit

Permalink
Merge pull request #150 from chris-doehring/feature/jwt-4-compatibility
Browse files Browse the repository at this point in the history
Add compatibility for lcobucci/jwt 4.x
  • Loading branch information
dusterio authored Dec 8, 2020
2 parents 14fcdb4 + 72429b9 commit 79bd71f
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/Http/Controllers/AccessTokenController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 with the Laravel Passport version used');
}

$token = $this->tokens->find($tokenId);
if (!$token instanceof Token) {
return $response;
}

if ($token->client->firstParty() && LumenPassport::$allowMultipleTokens) {
// We keep previous tokens for password clients
Expand Down

0 comments on commit 79bd71f

Please sign in to comment.