AuthMiddleware class

Authentication middleware for HTTP requests

Constructors

AuthMiddleware({required TokenValidator validator, List<String> publicPaths = const ['/health', '/ping'], List<String> defaultRequiredScopes = const [], bool strictMode = true, List<String> requiredScopes(String method, Map<String, dynamic>? params)?, bool scopeImplies(String granted, String needed)?})

Properties

defaultRequiredScopes → List<String>
final
hashCode → int
The hash code for this object.
no setterinherited
publicPaths → List<String>
final
requiredScopes → List<String> Function(String method, Map<String, dynamic>? params)?
The scopes one request needs, by method and params; null means defaultRequiredScopes. Scopes may depend on the arguments; whatever it returns is challenged in full (one round trip).
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
scopeImplies → bool Function(String granted, String needed)?
Scope hierarchy: whether granted covers needed (a broader scope implying a narrower one). Equal scopes always cover each other.
final
strictMode → bool
final
validator → TokenValidator
final

Methods

authenticate(HttpRequest request, {List<String>? requiredScopes}) → Future<AuthResult?>
Process HTTP request authentication
missingScopes(List<String> granted, Iterable<String> needed) → List<String>
The needed scopes granted does not cover, honouring scopeImplies.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
scopesFor(String method, Map<String, dynamic>? params) → List<String>
The scopes method with params needs.
sendAuthChallenge(HttpRequest request, {String? error, String? errorDescription, String? resourceMetadataUrl, String? scope}) → void
Send authentication challenge response.
sendForbidden(HttpRequest request, {String? reason}) → void
Send forbidden response
toString() → String
A string representation of this object.
inherited

Operators

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