Skip to main content

AuthContext

Enum AuthContext 

Source
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

Source

pub fn platform(&self) -> Option<&PlatformPrincipal>

Borrow the platform principal, when this context is platform-scoped.

Source

pub fn tenant(&self) -> Option<&Principal>

Borrow the tenant principal, when this context is tenant-scoped.

Source

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.

Source

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.

Source

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.

Source

pub fn effective_permissions(&self) -> &PermissionSet

The permissions authorization is decided against.

One vocabulary and one checker serve both planes; only the set differs.

Source

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

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AuthContext

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for AuthContext

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for AuthContext

Source§

impl From<PlatformPrincipal> for AuthContext

Source§

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

Source§

fn from(principal: Principal) -> Self

Lift a verified tenant principal into the shared context.

Boxed because a tenant principal carries its roles and resolved permissions, and the platform variant carries far less; keeping the enum small matters where it is passed by value on every request.

Source§

impl PartialEq for AuthContext

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for AuthContext

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for AuthContext

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more