final class ApiIdentity (View source)

Carries the authenticated API principal, its permissions and its verified trust boundary.

The authenticator owns trust assignment. Identity type and scopes remain descriptive and never promote an external identity to internal trust.

Methods

__construct(string $id, string $type, array $scopes = [], string|null $name = null, ApiIdentityTrust $trust = ApiIdentityTrust::External)

Creates an immutable identity from claims already verified by an API authenticator.

string
id()

Returns the stable principal identifier supplied by the authenticator.

string
string
type()

Returns the authenticator-defined identity category without granting trust from its value.

string
array
scopes()

Returns the permissions verified for this identity.

array
string|null
name()

Returns the optional human-readable principal name.

string|null
bool
hasScope(string $scope)

Reports whether the identity owns the exact supplied permission.

bool
ApiIdentityTrust
trust()

Returns the trust boundary established by the authenticator.

ApiIdentityTrust

Details

__construct

__construct(string $id, string $type, array $scopes = [], string|null $name = null, ApiIdentityTrust $trust = ApiIdentityTrust::External)

Creates an immutable identity from claims already verified by an API authenticator.

Omitted trust defaults to external so existing callers cannot acquire internal access implicitly.

Parameters

string $id
string $type
array $scopes
string|null $name
ApiIdentityTrust $trust

Exceptions

InvalidArgumentException

id

string id()

Returns the stable principal identifier supplied by the authenticator.

Return Value

string

type

string type()

Returns the authenticator-defined identity category without granting trust from its value.

Return Value

string

scopes

array scopes()

Returns the permissions verified for this identity.

Return Value

array

name

string|null name()

Returns the optional human-readable principal name.

Return Value

string|null

hasScope

bool hasScope(string $scope)

Reports whether the identity owns the exact supplied permission.

Parameters

string $scope

Return Value

bool

trust

ApiIdentityTrust trust()

Returns the trust boundary established by the authenticator.

Return Value

ApiIdentityTrust