Skip to content

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().

final class TokenClaims

Since1.0.0
SourceSecurity/Auth/TokenClaims.php

public function __construct(string $subject, array<string, mixed> $claims, ClientType $clientType): mixed

Human vs. machine, per RFC 9068.

ParameterTypeDescription
$subjectstringThe token’s sub claim.
$claimsarray``<``string``, ``mixed``>The full, already-validated claim set.
$clientTypeClientTypeHuman vs. machine, per RFC 9068.

Returns mixed

MethodDescription
getClaim(string $name, mixed $default = null): mixed
getClaims(): array<string, mixed>
getClientType(): ClientType
getSubject(): string
isService(): bool

public function getClaim(string $name, mixed $default = null): mixed

The value to return if $name is absent.

ParameterTypeDescription
$namestringThe claim name (e.g. sub, scope, aud).
$defaultmixedThe value to return if $name is absent.

Returns mixed — The raw value of a single claim, or $default if absent.

public function getClaims(): array<string, mixed>

Returns array``<``string``, ``mixed``> — The full, already-validated claim set.

public function getClientType(): ClientType

Returns ClientType — Human vs. machine, per RFC 9068.

public function getSubject(): string

Returns string — The token’s sub claim.

public function isService(): bool

Returns bool — True if getClientType() is ClientType::Service, otherwise false.