TokenClaims
Validated claims from a bearer/JWT/OIDC token, plus the ClientType derived from them by a ClientTypeResolverInterface.
Immutable value object; produced by a token validator, consumed by UserProviderInterface::loadByToken().
Synopsis
Section titled “Synopsis”final class TokenClaims
| Since | 1.0.0 |
| Source | Security/Auth/TokenClaims.php |
Constructor
Section titled “Constructor”__construct()
Section titled “__construct()”public function __construct(string $subject, array<string, mixed> $claims, ClientType $clientType): mixed
Human vs. machine, per RFC 9068.
| Parameter | Type | Description |
|---|---|---|
$subject | string | The token’s sub claim. |
$claims | array``<``string``, ``mixed``> | The full, already-validated claim set. |
$clientType | ClientType | Human vs. machine, per RFC 9068. |
Returns mixed
Methods
Section titled “Methods”| Method | Description |
|---|---|
getClaim(string $name, mixed $default = null): mixed | |
getClaims(): array<string, mixed> | |
getClientType(): ClientType | |
getSubject(): string | |
isService(): bool |
getClaim()
Section titled “getClaim()”public function getClaim(string $name, mixed $default = null): mixed
The value to return if $name is absent.
| Parameter | Type | Description |
|---|---|---|
$name | string | The claim name (e.g. sub, scope, aud). |
$default | mixed | The value to return if $name is absent. |
Returns mixed — The raw value of a single claim, or $default if absent.
getClaims()
Section titled “getClaims()”public function getClaims(): array<string, mixed>
Returns array``<``string``, ``mixed``> — The full, already-validated claim set.
getClientType()
Section titled “getClientType()”public function getClientType(): ClientType
Returns ClientType — Human vs. machine, per RFC 9068.
getSubject()
Section titled “getSubject()”public function getSubject(): string
Returns string — The token’s sub claim.
isService()
Section titled “isService()”public function isService(): bool
Returns bool — True if getClientType() is ClientType::Service, otherwise false.