WebGuard class
Web authentication guard
This guard handles authentication for web applications. It supports session-based authentication and can work with various drivers. It's designed for stateful web applications where sessions are maintained.
Constructors
- WebGuard({required AuthConfig config, required AuthDriver driver, required String providerKey, AuthRepository? repository, PasswordVerifier? passwordVerifier, ISessionManager? sessionManager})
- Creates a web guard
- WebGuard.create(String providerKey, AuthDriver driver, {ISessionManager? sessionManager})
-
Factory constructor for easy instantiation
factory
- WebGuard.fromConfig(AuthConfig config, String guardName, {ISessionManager? sessionManager, String? providerKey})
-
Factory constructor with config
factory
Properties
- config → AuthConfig
-
Authentication configuration
finalinherited
- driver → AuthDriver
-
The authentication driver
finalinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- passwordVerifier → PasswordVerifier
-
Password verifier
finalinherited
- providerKey → String
-
The provider key
finalinherited
- repository → AuthRepository
-
Authentication repository
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
attempt(
Map< String, dynamic> credentials) → Future<AuthResponse> -
Authenticates via session (web-specific)
override
-
check(
String sessionId) → Future< bool> -
Checks if user is authenticated via session
override
-
login(
Authenticatable user) → Future< AuthResponse> -
Authenticates a user directly (without password check)
inherited
-
loginWithSessionId(
Authenticatable user, String sessionId) → Future< AuthResponse> - Logs in user and stores in specific session
-
loginWithSessionIdAndRemember(
Authenticatable user, String sessionId, {bool remember = false}) → Future< AuthResponse> - Logs in user with remember me and stores in specific session
-
logout(
String sessionId) → Future< void> -
Logs out user by clearing session
override
-
logoutAll(
dynamic token) → Future< void> -
Logs out the user from all devices (invalidates all tokens)
inherited
-
logoutOthers(
dynamic userId, String currentToken) → Future< void> -
Logs out the user from other devices (invalidates all tokens except current)
inherited
-
logoutWithSessionId(
String sessionId) → Future< void> - Logs out user from specific session
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
refresh(
String refreshToken) → Future< AuthResponse> -
Refreshes an access token
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
user(
String sessionId) → Future< Authenticatable> -
Gets the authenticated user from session
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited