TokenDriver class

Token-based authentication driver

This driver handles simple token authentication with database storage. It generates secure random tokens and stores them in the database with optional expiry times.

Follows SOLID principles with dependency injection and strategy pattern.

Implemented types

Constructors

TokenDriver({required String providerKey, required AuthConfig config, AuthRepository? repository, TokenService? tokenService, TokenGenerator? tokenGenerator, TokenInvalidationStrategyFactory? strategyFactory, Duration? tokenExpiry, Duration? refreshTokenExpiry})
Creates a token driver with dependency injection
TokenDriver.fromConfig(AuthConfig config, String providerKey, {AuthRepository? repository, TokenService? tokenService, TokenGenerator? tokenGenerator, TokenInvalidationStrategyFactory? strategyFactory})
Factory constructor with config and dependency injection
factory

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

authenticate(Map<String, dynamic> credentials, Authenticatable user) Future<AuthResponse>
Attempts to authenticate a user with credentials
override
generateTokens(Authenticatable user) Future<AuthResponse>
Generates tokens for a user
override
invalidateToken(String token) Future<void>
Invalidates a token (single device logout)
override
invalidateTokenWithStrategy(String token, LogoutType logoutType) Future<void>
Invalidates tokens using a specific strategy
override
logoutFromAllDevices(String token) Future<void>
Logout from all devices
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
refreshToken(String refreshToken) Future<AuthResponse>
Refreshes an access token
override
toString() String
A string representation of this object.
inherited
validateTokenFormat(String token) bool
Validates token format
override
verifyToken(String token) Future<Authenticatable>
Verifies an authentication token
override

Operators

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