Skip to main content

Principal

Struct Principal 

#[non_exhaustive]
pub struct Principal { pub id: PrincipalId, pub display_id: String, pub actor: ActorKind, pub auth_method: AuthMethod, pub provider_alias: Option<String>, pub trust_domain: String, pub mfa_verified: bool, pub expires_at: Option<u64>, pub revalidate_by: Option<u64>, }
Expand description

The canonical resolved principal: the single non-secret record every dispatch/audit/isolation surface consumes.

Deliberately carries NO grants and NO raw claims: effective grants are resolved from current permission-profile configuration by the shared resolver and re-resolved when the authorization-policy generation changes, so this record can be held for a connection’s lifetime without becoming a stale authorization snapshot.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§id: PrincipalId

Canonical ownership/audit key.

§display_id: String

Human-readable, non-authoritative display identifier (OIDC sub, roster principal id, service client_id). Never an ownership key.

§actor: ActorKind

Human or service actor.

§auth_method: AuthMethod

How this principal authenticated.

§provider_alias: Option<String>

The <alias> of the configured provider entry that authenticated this principal, when one exists (audit attribution).

§trust_domain: String

The trust domain of the identity source (validated issuer URL, local, or native).

§mfa_verified: bool

Whether a second factor was completed.

§expires_at: Option<u64>

Credential expiry (UNIX seconds), when the provider imposes one.

§revalidate_by: Option<u64>

Provider revalidation deadline (UNIX seconds), when one applies.

Implementations§

Source§

impl Principal

Source

pub fn from_identity(identity: &AuthenticatedIdentity) -> Self

The single construction path: every Principal derives from a provider-verified AuthenticatedIdentity, so no caller can invent a principal with an inconsistent id/actor/trust-domain combination.

Source

pub fn shared_operator() -> Self

The trusted shared-operator sentinel (no distinct identity source).

Source

pub fn auth_provider_label(&self) -> String

The audit label for the verifying provider: <type>.<alias> when a config alias exists, else the bare method label.

Source

pub fn is_authenticated(&self) -> bool

true once a distinct identity source authenticated this principal — i.e. not unbound (AuthMethod::None) and not the shared-operator sentinel. A2A distinct-principal routing keys on this.

Trait Implementations§

Source§

impl Clone for Principal

Source§

fn clone(&self) -> Principal

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

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Principal

Source§

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

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

impl<'de> Deserialize<'de> for Principal

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 Principal

Source§

impl PartialEq for Principal

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl Serialize for Principal

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 Principal

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<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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.