JWTDriver class
JWT authentication driver
This driver handles JWT token generation, verification, and refresh operations. It uses the dart_jsonwebtoken package for JWT operations.
Follows SOLID principles with dependency injection and strategy pattern.
- Implemented types
Constructors
- JWTDriver({required String secret, required AuthConfig config, required String providerKey, Duration accessTokenExpiry = const Duration(hours: 1), Duration refreshTokenExpiry = const Duration(days: 7), TokenGenerator? tokenGenerator, TokenService? tokenService, TokenInvalidationStrategyFactory? strategyFactory})
- Creates a JWT driver with dependency injection
- JWTDriver.fromConfig(AuthConfig config, String providerKey, {TokenGenerator? tokenGenerator, TokenService? tokenService, 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> -
Invalidates all tokens for a user (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