AuthStateRule class

Matches on authentication state: whether the caller is authenticated, and whether the principal holds required roles.

Inheritance

Constructors

AuthStateRule({bool? requireAuthenticated, Set<String> anyRoles = const {}, Set<String> allRoles = const {}})
Creates an auth-state rule.
const
AuthStateRule.anonymous()
Matches only anonymous callers.
const
AuthStateRule.authenticated()
Matches any authenticated caller.
const
AuthStateRule.hasAnyRole(Set<String> roles)
Matches callers holding any of roles.
AuthStateRule.hasRole(String role)
Matches callers holding role.

Properties

allRoles Set<String>
The caller must hold all of these roles (if non-empty).
final
anyRoles Set<String>
The caller must hold at least one of these roles (if non-empty).
final
hashCode int
The hash code for this object.
no setterinherited
requireAuthenticated bool?
Required authentication state, or null if unconstrained.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
specificity int
A relative measure of how specific this rule is, used as a tie-breaker among matching routes of equal priority. Higher is more specific.
no setteroverride

Methods

and(RouteRule other) RouteRule
A rule matching when both this and other match.
inherited
matches(RouteContext context) bool
Whether this rule matches context.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
not() RouteRule
A rule matching when this rule does not match.
inherited
or(RouteRule other) RouteRule
A rule matching when either this or other matches.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator &(RouteRule other) RouteRule
Operator form of and.
inherited
operator ==(Object other) bool
The equality operator.
inherited
operator |(RouteRule other) RouteRule
Operator form of or.
inherited
operator ~() RouteRule
Operator form of not.
inherited