AuthManager class final

Multi-guard authentication manager (Laravel AuthManager).

Guards are registered at boot (withAuth); every query goes through the guard named explicitly, the one activated by auth:a,b middleware for this request, or the configured default.

Constructors

AuthManager(AuthConfig config, {String? appKey, JwtDenylist? jwtDenylist})

Properties

config → AuthConfig
final
defaultGuard → String
Default guard name (AUTH_GUARD, or shouldUse).
no setter
guardNames → Iterable<String>
no setter
hashCode → int
The hash code for this object.
no setterinherited
jwtDenylist → JwtDenylist?
The denylist of jwt guards that are not given one: shared by every isolate when the application builds it (CacheJwtDenylist).
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

check({String? guard}) → Future<bool>
defaultJwtCodec() → JwtCodec
Builds the codec described by config.
forgetUser({String? guard}) → void
guard([String? name]) → Guard<Authenticatable>
The guard called name, or the request-active/default guard.
guest({String? guard}) → Future<bool>
hasGuard(String name) → bool
id({String? guard}) → Future<Object?>
issueJwt(Authenticatable user, {Duration? ttl, Map<String, Object?> claims = const <String, Object?>{}, String? guard}) → Future<String>
Issues a JWT for user.
issueToken(Authenticatable user, String name, {List<String> abilities = const <String>['*'], DateTime? expiresAt, String? guard}) → Future<NewAccessToken>
Issues a personal access token ($user->createToken()).
jwt<T extends Authenticatable>(String name, UserProvider<T> provider, {JwtCodec? codec, Duration? ttl, JwtDenylist? denylist}) → JwtGuard<T>
Registers a JwtGuard; the codec defaults to the JWT_* settings (HS256 with JWT_SECRET or APP_KEY, or EdDSA with JWT_PUBLIC_KEY).
jwtGuard([String? name]) → JwtGuard<Authenticatable>
The JWT guard named name, or the first registered one.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
once(Map<String, Object?> credentials, {String? guard}) → Future<bool>
Authenticates the current request only (no token/session).
onceUsingId<T extends Authenticatable>(Object id, {String? guard}) → Future<T?>
Authenticates the current request as the user with id.
register(String name, Guard<Authenticatable> guard) → void
Registers a custom guard.
retrieveByCredentials<T extends Authenticatable>(Map<String, Object?> credentials, {String? guard}) → Future<T?>
Looks up and validates credentials; returns the user when they match.
setUser(Authenticatable user, {String? guard}) → void
shouldUse(String name) → void
Changes the process-wide default guard (boot time).
token<T extends Authenticatable>(String name, UserProvider<T> provider, {Duration? expiration, String? table}) → TokenGuard<T>
Registers a Sanctum-style TokenGuard.
tokenGuard([String? name]) → TokenGuard<Authenticatable>
The token guard named name, or the first registered one.
toString() → String
A string representation of this object.
inherited
useForRequest(String name) → void
Makes name the default guard for the current request/scope only.
user<T extends Authenticatable>({String? guard}) → Future<T?>
validate(Map<String, Object?> credentials, {String? guard}) → Future<bool>
Validates credentials without authenticating the request.
viaRequest<T extends Authenticatable>(String name, FutureOr<T?> resolver(Request request), {UserProvider<T>? provider}) → ClosureGuard<T>
Registers a closure guard (Auth::viaRequest).

Operators

operator ==(Object other) → bool
The equality operator.
inherited