Guard
interface Guard
Defines the contract for an authentication guard. A guard owns the notion of "who is authenticated right now" for a single request, resolving the current user from the underlying session and delegating user retrieval and credential checks to a UserProvider. Implementations are responsible for reading and writing authentication state (session, and optionally remember-me persistence) so that callers interact with a Principal rather than with storage details directly.
Methods
Determines whether a user is currently authenticated.
Retrieves the currently authenticated user. Implementations typically resolve the user once per request and cache the result.
Retrieves the identifier of the currently authenticated user without requiring the full user object to be used by the caller.
Validates a set of credentials without logging the user in or modifying any authentication state.
Resolves a user by identifier and logs them in.
Logs the current user out, clearing authentication state for the request and removing any persisted remember-me token.
Details
at line 21
bool
check()
Determines whether a user is currently authenticated.
at line 30
Principal|null
user()
Retrieves the currently authenticated user. Implementations typically resolve the user once per request and cache the result.
at line 39
mixed
id()
Retrieves the identifier of the currently authenticated user without requiring the full user object to be used by the caller.
at line 49
bool
validate(array $credentials)
Validates a set of credentials without logging the user in or modifying any authentication state.
at line 61
void
login(Principal $user, bool $remember = false)
Logs the given user in, establishing authentication state for the current request and subsequent ones. When $remember is true, implementations should also persist a remember-me token.
at line 70
Principal|null
loginUsingId(mixed $id)
Resolves a user by identifier and logs them in.
at line 78
void
logout()
Logs the current user out, clearing authentication state for the request and removing any persisted remember-me token.