Auth class

Helper class for JSON Web Token (JWT) authentication and authorization.

Constructors

Auth(String secret, {Duration tokenTtl = const Duration(hours: 1)})
Creates a new Auth instance with the specified secret and tokenTtl.

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
secret String
The secret key used for signing and verifying tokens.
final
tokenTtl Duration
The duration for which a generated token remains valid.
final

Methods

generateToken(Map<String, dynamic> payload) String
Generates a new signed JWT string containing the provided payload.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
verify() Middleware
Returns a Middleware that verifies the Authorization: Bearer <token> header.

Operators

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