Skip to content
This repository has been archived by the owner on Mar 28, 2022. It is now read-only.

Commit

Permalink
Automatically cast claims to scalar values in adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
DASPRiD committed Apr 6, 2017
1 parent 9b8406f commit efcc23c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/Jwt/LcobucciAdapter.php
Expand Up @@ -81,7 +81,13 @@ public function getClaims(string $token) : array
throw InvalidTokenException::fromInvalidToken($token);
}

return $tokenInstance->getClaims();
$claims = [];

foreach ($tokenInstance->getClaims() as $key => $claim) {
$claims[$key] = $claim->getValue();
}

return $claims;
}

private function getTokenInstance(string $token) : ?Token
Expand Down
3 changes: 2 additions & 1 deletion test/Jwt/LcobucciAdapterTest.php
Expand Up @@ -8,6 +8,7 @@
use DASPRiD\CsrfGuard\Jwt\LcobucciAdapter;
use DateTimeImmutable;
use InvalidArgumentException;
use Lcobucci\JWT\Claim\Basic;
use Lcobucci\JWT\Claim\GreaterOrEqualsTo;
use Lcobucci\JWT\Parser;
use Lcobucci\JWT\Signature;
Expand Down Expand Up @@ -186,7 +187,7 @@ public function testGetClaimsWithValidToken()
'exp',
(new DateTimeImmutable('2018-01-01 00:00:00 UTC'))->getTimestamp()
),
'baz' => 'bat',
'baz' => new Basic('baz', 'bat'),
],
new Signature('foo_signature')
));
Expand Down

0 comments on commit efcc23c

Please sign in to comment.