ZenithPolicy class
A named collection of authorization rules evaluated against a UserSecurityContext.
A ZenithPolicy supports three evaluation modes — all are optional but at least one must produce a result:
-
requirements: a list of ZenithRequirements evaluated synchronously. All requirements must pass for the policy to succeed.
-
evaluate: a synchronous lambda that receives a PolicyRef and returns
true/false. Ideal for reactive node-based checks (e.g.ref.watch(entitlementNode).contains('pro_tier')). -
evaluateAsync: an async lambda that returns a
PolicyRef → AsyncValue<bool>for async receipt verification.
final policy = ZenithPolicy(
name: 'CanExport4K',
requirements: [RequireAuthenticatedUser(), RequireEntitlement('export_4k')],
);
Constructors
-
ZenithPolicy({required String name, List<
ZenithRequirement> ? requirements, bool evaluate(PolicyRef ref)?, AsyncValue<bool> evaluateAsync(PolicyRef ref)?}) -
Creates a ZenithPolicy with
nameand at least one evaluation strategy.const
Properties
- evaluate → bool Function(PolicyRef ref)?
-
Reactive sync evaluation lambda.
final
-
evaluateAsync
→ AsyncValue<
bool> Function(PolicyRef ref)? -
Reactive async evaluation lambda returning AsyncValue<bool>.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- name → String
-
A human-readable name for this policy (used in logs and error messages).
final
-
requirements
→ List<
ZenithRequirement> ? -
Synchronous list of requirements — all must pass.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited