Final Class Yiisoft\Auth\Jwt\TokenRepository
| Inheritance | Yiisoft\ |
|---|---|
| Implements | Yiisoft\ |
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\ |
|
| getClaims() | Yiisoft\ |
Method Details
See also https://tools.ietf.org/html/rfc7515.
| public mixed __construct ( Yiisoft\ | ||
| $keyFactory | Yiisoft\ |
A factory to create a JSON Web Key. |
| $algorithmManager | \ |
Algorithms manager for signing JSON Web Signature. |
| $serializerManager | \ |
JSON Web Signature serializer manager. |
public function __construct(
private readonly KeyFactoryInterface $keyFactory,
private readonly AlgorithmManager $algorithmManager,
private readonly JWSSerializerManager $serializerManager,
) {}
| public ?array getClaims ( string $token, ?string &$format = null ) | ||
| $token | string | |
| $format | ?string | |
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;
}
User Contributed Notes
Leave a comment
Join the conversation to share a note.