pub enum AuthContext {
Platform(PlatformPrincipal),
Tenant(Box<Principal>),
}Expand description
The authenticated identity behind a request, in exactly one control plane.
One authentication pipeline produces this, whichever entry path the caller used — a machine credential exchanged for a token, or a human federated login. Everything downstream authorizes against it and never branches on how authentication happened.
The two variants are closed and carry different payloads, so a platform
identity is not representable where a tenant identity is required and the
reverse. That mirrors the database tier’s OperatorPool / TenantConn
split at the identity tier.
Variants§
Platform(PlatformPrincipal)
Platform control plane: tenant lifecycle and administrative recovery.
Tenant(Box<Principal>)
Tenant control plane: the resources of exactly one tenant.
Implementations§
Source§impl AuthContext
impl AuthContext
Sourcepub fn platform(&self) -> Option<&PlatformPrincipal>
pub fn platform(&self) -> Option<&PlatformPrincipal>
Borrow the platform principal, when this context is platform-scoped.
Sourcepub fn tenant(&self) -> Option<&Principal>
pub fn tenant(&self) -> Option<&Principal>
Borrow the tenant principal, when this context is tenant-scoped.
Sourcepub fn principal_id(&self) -> PrincipalId
pub fn principal_id(&self) -> PrincipalId
The authenticated principal id, whichever plane this context names.
Audit uses this so every privileged operation is attributable to a principal rather than to a credential.
Sourcepub fn principal_kind(&self) -> PrincipalKindTag
pub fn principal_kind(&self) -> PrincipalKindTag
The kind of principal behind the request, whichever plane it names.
Audit records this, so it has to be what the store holds rather than a per-plane constant: a platform plane carrying both machine roots and registered humans would otherwise attribute every human decision to a machine.
Sourcepub const fn credential_id(&self) -> Option<Uuid>
pub const fn credential_id(&self) -> Option<Uuid>
The credential the request authenticated with, on either plane.
Audit records it beside the principal, because a principal may hold several live credentials at once and the recorded decision has to say which one was used.
Sourcepub fn effective_permissions(&self) -> &PermissionSet
pub fn effective_permissions(&self) -> &PermissionSet
The permissions authorization is decided against.
One vocabulary and one checker serve both planes; only the set differs.
Sourcepub fn tenant_id(&self) -> Option<DataTenantId>
pub fn tenant_id(&self) -> Option<DataTenantId>
The tenant this context is scoped to, when it is tenant-scoped.
Returns None for a platform context because a platform principal has
no tenant to return — not because one was withheld.
Trait Implementations§
Source§impl Clone for AuthContext
impl Clone for AuthContext
Source§impl Debug for AuthContext
impl Debug for AuthContext
Source§impl<'de> Deserialize<'de> for AuthContext
impl<'de> Deserialize<'de> for AuthContext
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for AuthContext
Source§impl From<PlatformPrincipal> for AuthContext
impl From<PlatformPrincipal> for AuthContext
Source§fn from(principal: PlatformPrincipal) -> Self
fn from(principal: PlatformPrincipal) -> Self
Lift a verified platform principal into the shared context.
The platform arm is the one that carries no tenant, which is what downstream tenancy checks read the context for.
Source§impl From<Principal> for AuthContext
impl From<Principal> for AuthContext
Source§impl PartialEq for AuthContext
impl PartialEq for AuthContext
Source§impl Serialize for AuthContext
impl Serialize for AuthContext
impl StructuralPartialEq for AuthContext
Auto Trait Implementations§
impl Freeze for AuthContext
impl RefUnwindSafe for AuthContext
impl Send for AuthContext
impl Sync for AuthContext
impl Unpin for AuthContext
impl UnsafeUnpin for AuthContext
impl UnwindSafe for AuthContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.