Final Class Yiisoft\Auth\Jwt\TokenRepository
| Inheritance | Yiisoft\Auth\Jwt\TokenRepository |
|---|---|
| Implements | Yiisoft\Auth\Jwt\TokenRepositoryInterface |
Token repository is getting a list of claims for a token.
The token JWS is being verified before doing so.
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\Auth\Jwt\TokenRepository | |
| getClaims() | Yiisoft\Auth\Jwt\TokenRepository |
Method Details
See also https://tools.ietf.org/html/rfc7515.
| public mixed __construct ( Yiisoft\Auth\Jwt\KeyFactoryInterface $keyFactory, \Jose\Component\Core\AlgorithmManager $algorithmManager, \Jose\Component\Signature\Serializer\JWSSerializerManager $serializerManager ) | ||
| $keyFactory | Yiisoft\Auth\Jwt\KeyFactoryInterface |
A factory to create a JSON Web Key. |
| $algorithmManager | \Jose\Component\Core\AlgorithmManager |
Algorithms manager for signing JSON Web Signature. |
| $serializerManager | \Jose\Component\Signature\Serializer\JWSSerializerManager |
JSON Web Signature serializer manager. |
public function __construct(
private readonly KeyFactoryInterface $keyFactory,
private readonly AlgorithmManager $algorithmManager,
private readonly JWSSerializerManager $serializerManager
) {
}
| public array|null getClaims ( string $token, string|null &$format = null ) | ||
| $token | string | |
| $format | string|null | |
public function getClaims(string $token, ?string &$format = null): ?array
{
try {
$jws = $this->serializerManager->unserialize($token, $format);
} catch (\InvalidArgumentException) {
return null;
}
$jwk = $this->keyFactory->create();
foreach ($this->algorithmManager->list() as $index => $_algorithm) {
/** @var int $index */
if ($this->verifyToken($jws, $jwk, $index)) {
/** @var array<array-key, mixed>|null */
return Json::decode($jws->getPayload() ?? '');
}
}
return null;
}
Signup or Login in order to comment.