GuardUtils class

A utility class for evaluating complex access control logic using roles, permissions, and custom conditions.

Constructors

GuardUtils()

Properties

hashCode int
The hash code for this object.
no setterinherited
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

Static Methods

cronValidationError(String cron) String?
evaluate({required Guard guard, List<String> requiredRoles = const [], List<String> requiredPermissions = const [], bool condition()?}) bool
evaluateDetailed({required Guard guard, List<String> requiredRoles = const [], List<String> requiredPermissions = const [], bool condition()?, String? policyName}) AccessDecision
Detailed evaluation with denial reasons.
evaluatePolicy({required Guard guard, required AccessPolicy policy}) bool
evaluatePolicyDetailed({required Guard guard, required AccessPolicy policy}) AccessDecision
hasAllPermissions(Guard guard, List<String> permissions) bool
Check if user has all of the given permissions.
hasAllRoles(Guard guard, List<String> roles) bool
Check if user has all of the given roles.
hasAnyPermission(Guard guard, List<String> permissions) bool
Check if user has any of the given permissions.
hasAnyRole(Guard guard, List<String> roles) bool
Check if user has any of the given roles.
isInSchedule(String schedule, {DateTime? now, bool useUtc = false}) bool
Checks if now matches cron schedule with optional UTC matching.
isInTimeRange(DateTime start, DateTime end, {DateTime? now}) bool
Returns true if the current time is within the given start and end window.
isValidCron(String cron) bool
periodicTimeStream({Duration interval = const Duration(seconds: 1)}) Stream<DateTime>
scheduleStream(String schedule, Duration interval, {bool useUtc = false}) Stream<bool>
timeLeft(DateTime end, {DateTime? now}) Duration
timeUntilStart(DateTime start, {DateTime? now}) Duration
timeWindowStream(DateTime start, DateTime end, Duration interval) Stream<bool>