AbstractAuthIdentity. This ensures that your authorization logic can always rely on an identity object being present, eliminating the need for null checks.
AbstractAuthIdentity
The base class for all identities. It defines the contract for checking authentication status and granted scopes.Methods
isAuthenticated(): bool: Returnstrueif the requester is authenticated.getGrantedScopes(): ScopeInterface[]: Returns an array of scopes granted to this identity.isScopeGranted(ScopeInterface $scope): bool: Helper method to check if a specific scope is present.
UserAuthIdentity
Represents a successfully authenticated user.Usage
Typically created by an Authenticator after validating a token.Additional Methods
getUserId(): string: Returns the unique identifier for the user (e.g., thesubclaim from a JWT).getClaims(): array: Returns all metadata/claims associated with the user.getClaim(string $name): Retrieves a specific claim by name.
GuestAuthIdentity
Represents an anonymous or non-authenticated requester.Usage
By default, every request is initialized with an emptyGuestAuthIdentity.
Public Scopes
You can initialize aGuestAuthIdentity with default scopes. This is useful for “Public but scoped” endpoints where you want to grant certain permissions to everyone.