AuthGateService<TContext> class

Framework-agnostic gate evaluation service.

Constructors

AuthGateService({AuthGateRegistry<TContext>? registry, AuthPrincipal? principalResolver(TContext context)?})
Creates a service using registry or a new registry when omitted.

Properties

hashCode int
The hash code for this object.
no setterinherited
principalResolver AuthPrincipal? Function(TContext context)?
Optional resolver used when can is called without an explicit principal.
final
registry AuthGateRegistry<TContext>
Backing registry for ability callbacks.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

addObserver(AuthGateObserver<TContext> observer) → void
Adds observer to the evaluation notification list.
all(Iterable<String> abilities, {required TContext context, AuthPrincipal? principal, Object? payload}) Future<bool>
Returns whether every ability in abilities allows the request.
any(Iterable<String> abilities, {required TContext context, AuthPrincipal? principal, Object? payload}) Future<bool>
Returns whether any ability in abilities allows the request.
authorize(String ability, {required TContext context, AuthPrincipal? principal, Object? payload, String? message}) Future<void>
Authorizes ability or throws an AuthGateViolation when denied.
can(String ability, {required TContext context, AuthPrincipal? principal, Object? payload}) Future<bool>
Evaluates ability and returns whether it is allowed.
firstDenied(Iterable<String> abilities, {required TContext context, AuthPrincipal? principal, AuthGatePayloadResolver<TContext>? payloadResolver, String? message}) Future<AuthGateViolation<TContext>?>
Returns the first denied ability as a violation, if any.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
register(String ability, AuthGateCallback<TContext> callback) → void
Registers callback under ability.
registerAll(Map<String, AuthGateCallback<TContext>> entries) → void
Registers each callback in entries using the registry rules.
removeObserver(AuthGateObserver<TContext> observer) → void
Removes observer from the evaluation notification list.
toString() String
A string representation of this object.
inherited
unregister(String ability) → void
Removes ability when it is registered.

Operators

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