Principal class

An authenticated caller.

The framework treats principals as opaque data; the only fields inspected by built-in guards are roles and permissions. Anything else you put in claims is yours to use from controllers.

Constructors

Principal({required String id, Set<String> roles = const <String>{}, Set<String> permissions = const <String>{}, Map<String, Object?> claims = const <String, Object?>{}})
const

Properties

claims → Map<String, Object?>
Arbitrary extra claims (token issuer, expiry, tenant id, ...).
final
hashCode → int
The hash code for this object.
no setterinherited
id → String
Stable identifier (e.g. user id, service account id).
final
permissions → Set<String>
Permission scopes assigned to the principal. Checked by the @Permissions / @AnyPermission guards.
final
roles → Set<String>
Role names assigned to the principal. Checked by the @Roles guard.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

hasPermission(String permission) → bool
hasRole(String role) → bool
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
override

Operators

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