AuthGateService<TContext> class
Framework-agnostic gate evaluation service.
Constructors
-
AuthGateService({AuthGateRegistry<
TContext> ? registry, AuthPrincipal? principalResolver(TContext context)?}) -
Creates a service using
registryor 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
observerto the evaluation notification list. -
all(
Iterable< String> abilities, {required TContext context, AuthPrincipal? principal, Object? payload}) → Future<bool> -
Returns whether every ability in
abilitiesallows the request. -
any(
Iterable< String> abilities, {required TContext context, AuthPrincipal? principal, Object? payload}) → Future<bool> -
Returns whether any ability in
abilitiesallows the request. -
Authorizes
abilityor throws an AuthGateViolation when denied. -
can(
String ability, {required TContext context, AuthPrincipal? principal, Object? payload}) → Future< bool> -
Evaluates
abilityand 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
callbackunderability. -
registerAll(
Map< String, AuthGateCallback< entries) → voidTContext> > -
Registers each callback in
entriesusing the registry rules. -
removeObserver(
AuthGateObserver< TContext> observer) → void -
Removes
observerfrom the evaluation notification list. -
toString(
) → String -
A string representation of this object.
inherited
-
unregister(
String ability) → void -
Removes
abilitywhen it is registered.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited