pub struct Principal {
pub subject: String,
pub tenant: Option<String>,
pub permissions: BTreeSet<String>,
}Expand description
The authenticated caller: who they are, the tenant their requests are scoped to (if any), and the permissions they hold.
Built only by an Authenticator from verified credentials — never from a
request argument. tenant of None means the caller is not tenant-scoped
(a tenant-wide or single-tenant deployment); an empty Principal is the
anonymous caller.
Fields§
§subject: StringA stable, loggable identity for the caller (the token’s subject). Never the bearer token itself. Empty for the anonymous principal.
tenant: Option<String>The tenant every tenant-scoped resource is constrained to, if any.
permissions: BTreeSet<String>The permissions the caller holds, compared verbatim against a facade
method’s requires.
Implementations§
Source§impl Principal
impl Principal
Sourcepub fn anonymous() -> Principal
pub fn anonymous() -> Principal
The anonymous principal: no subject, no tenant, no permissions.
Sourcepub fn new<I, P>(subject: impl Into<String>, permissions: I) -> Principal
pub fn new<I, P>(subject: impl Into<String>, permissions: I) -> Principal
A principal with the given subject holding permissions, belonging to no
particular tenant. Use in_tenant to scope it.