AngelAuth<User> class

Handles authentication within an Angel application.

Constructors

AngelAuth({String? jwtKey, required FutureOr<String> serializer(User), required FutureOr<User> deserializer(String), num jwtLifeSpan = -1, bool allowCookie = true, bool allowTokenInQuery = true, bool enforceIp = true, String? cookieDomain, String cookiePath = '/', bool secureCookies = true, String reviveTokenEndpoint = '/auth/token'})
jwtLifeSpan - should be in milliseconds.

Properties

allowCookie bool
If true (default), then JWT's will be stored and retrieved from a token cookie.
final
allowTokenInQuery bool
If true (default), then users can include a JWT in the query string as token.
final
cookieDomain String?
A domain to restrict emitted cookies to.
final
cookiePath String
A path to restrict emitted cookies to.
final
deserializer FutureOr<User> Function(String)
Deserializes a unique identifier into its associated identity. In most cases, this is a user object or model instance.
getter/setter pair
enforceIp bool
If true (default), then JWT's will be considered invalid if used from a different IP than the first user's it was issued to.
final
hashCode int
The hash code for this object.
no setterinherited
hmac → Hmac
The Hmac being used to encode JWT's.
no setter
onLogin Stream<User>
Fires the result of deserializer whenever a user signs in to the application.
no setter
onLogout Stream<User>
Fires req.user, which is usually the result of deserializer, whenever a user signs out of the application.
no setter
reviveTokenEndpoint String
The endpoint to mount reviveJwt at. If null, then no revival route is mounted. Default: /auth/token.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
secureCookies bool
Whether emitted cookies should have the secure and HttpOnly flags, as well as being restricted to a specific domain.
final
serializer FutureOr<String> Function(User)
Serializes a user into a unique identifier associated only with one identity.
getter/setter pair
strategies Map<String, AuthStrategy<User>>
A set of AuthStrategy instances used to authenticate users.
getter/setter pair

Methods

authenticate(dynamic type, [AngelAuthOptions<User>? opt]) → RequestHandler
Attempts to authenticate a user using one or more strategies.
configureServer(Angel app) Future<void>
Configures an Angel server to decode and validate JSON Web tokens on demand, whenever an instance of User is injected.
getJwt(RequestContext req) String?
Retrieves a JWT from a request, if any was sent at all.
login(AuthToken token, RequestContext req, ResponseContext res) Future
Log a user in on-demand.
loginById(String userId, RequestContext req, ResponseContext res) Future
Log a user in on-demand.
logout([AngelAuthOptions<User>? options]) → RequestHandler
Log an authenticated user out.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
protectCookie(Cookie cookie) Cookie
Applies security protections to a cookie.
toString() String
A string representation of this object.
inherited

Operators

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