Nexus API Reference

SimplePrincipal
in package
implements Principal

Read onlyYes
FinalYes
Tags
psalm-api

Default Principal implementation — readonly value object carrying id, roles, scopes, and arbitrary claims. The default target for JwtAuthenticator's claims-mapper.

For domain-specific identity (User entity, tenant context), implement Principal directly instead.

Table of Contents

Interfaces

Principal

Methods

__construct()  : mixed
claims()  : array<string, mixed>
hasRole()  : bool
hasScope()  : bool
id()  : string
Stable identifier for the principal — used for logging, audit, MDC.
roles()  : array<int, string>
scopes()  : array<int, string>

Methods

__construct()

public __construct(string $id[, array<int, string> $roles = [] ][, array<int, string> $scopes = [] ][, array<string, mixed> $claims = [] ]) : mixed
Parameters
$id : string
$roles : array<int, string> = []
$scopes : array<int, string> = []
$claims : array<string, mixed> = []

claims()

public claims() : array<string, mixed>
Return values
array<string, mixed>

hasRole()

public hasRole(string $role) : bool
Parameters
$role : string
Return values
bool

hasScope()

public hasScope(string $scope) : bool
Parameters
$scope : string
Return values
bool

id()

Stable identifier for the principal — used for logging, audit, MDC.

public id() : string

Typically a user id, service account name, or "anonymous".

Return values
string

roles()

public roles() : array<int, string>
Return values
array<int, string>

scopes()

public scopes() : array<int, string>
Return values
array<int, string>

        
On this page

Search results