Skip to main content

IdentityPayload

Struct IdentityPayload 

Source
pub struct IdentityPayload {
    pub subject: Option<SubjectExtension>,
    pub client: Option<ClientExtension>,
    pub caller_workload: Option<WorkloadIdentity>,
    pub delegation: Option<DelegationExtension>,
    pub raw_credentials: Option<RawCredentialsExtension>,
    pub resolved_at: Option<DateTime<Utc>>,
    pub raw_claims: HashMap<String, Value>,
    /* private fields */
}
Expand description

State threaded through the IdentityResolve hook chain.

See the module-level docs for the input/output split. In short: input fields are private (set once via the constructor + builders, never mutated), output fields are pub (handlers populate them on clones and return the updated payload).

Implements PluginPayload so it can flow through the executor’s existing Sequential-phase machinery — no bespoke plumbing.

Fields§

§subject: Option<SubjectExtension>

Resolved user identity. None until a handler populates it.

§client: Option<ClientExtension>

Resolved OAuth client / gateway-access identity.

§caller_workload: Option<WorkloadIdentity>

Resolved attested workload identity for the inbound peer.

§delegation: Option<DelegationExtension>

Initial delegation chain parsed from act / equivalent claims.

§raw_credentials: Option<RawCredentialsExtension>

Raw inbound tokens to stash in Extensions.raw_credentials.inbound_tokens after the chain completes (gated by read_inbound_credentials for consumers).

§resolved_at: Option<DateTime<Utc>>

Optional resolution timestamp. Audit-useful.

§raw_claims: HashMap<String, Value>

Raw decoded token claims, when a handler wants to expose them for audit/policy without elevating each claim to a typed field. Mirrors the Python raw_claims: dict[str, Any].

Implementations§

Source§

impl IdentityPayload

Source

pub fn new(raw_token: impl Into<String>, source: TokenSource) -> Self

Construct a payload with the required input fields populated. The most common entry point — hosts call this once per request before invoking the hook. Optional input slots (source_header, headers, client_host, client_port) are set via the .with_* builders below; output fields start as None / false / empty and accumulate as handlers run.

Source

pub fn with_source_header(self, h: impl Into<String>) -> Self

Source

pub fn with_headers(self, h: HashMap<String, String>) -> Self

Source

pub fn with_client_host(self, h: impl Into<String>) -> Self

Source

pub fn with_client_port(self, port: u16) -> Self

Source

pub fn raw_token(&self) -> &str

The raw credential bytes. Borrowed — handlers cannot move or replace the underlying Zeroizing<String> through this accessor.

Source

pub fn source(&self) -> &TokenSource

Source

pub fn source_header(&self) -> Option<&str>

Source

pub fn headers(&self) -> &HashMap<String, String>

Source

pub fn client_host(&self) -> Option<&str>

Source

pub fn client_port(&self) -> Option<u16>

Source

pub fn merge(&mut self, other: IdentityPayload)

Layer another payload’s output fields onto this one’s, following “Some replaces None, last write wins per slot.” Input fields are not touched — the running payload’s input is canonical for the whole chain.

Rejection is not a merged field — handlers reject via PluginResult::deny, which halts the chain at the framework level rather than being expressed as payload state. See the module docs for the rationale.

Source

pub fn from_pipeline_result(result: &PipelineResult) -> Option<Self>

Pull the resolved IdentityPayload out of a PipelineResult returned by mgr.invoke_named::<IdentityHook>(...). Returns None when the pipeline was denied (no modified_payload) or when the result’s payload wasn’t an IdentityPayload — a programmer error if the latter, since the executor produces modified_payload typed per the hook’s HookTypeDef::Payload.

Clones the inner payload — the original Box<dyn PluginPayload> stays in the PipelineResult so callers can also inspect continue_processing, violation, etc.

Source

pub fn apply_to_extensions(&self, ext: Extensions) -> Extensions

Apply this payload’s resolved identity slots back into an Extensions container. Returns a new Extensions ready to hand to the next hook in the request lifecycle (cmf.tool_pre_invoke, etc.) — downstream plugins read security.subject / security.client / security.caller_workload / raw_credentials etc. through the standard capability-gated filter.

Merging rules:

  • security.subject / .client / .caller_workloadSome values on the payload overwrite the existing slot; other security fields (labels, classification, this_workload, auth_method, objects, data) are preserved from the input Extensions.
  • raw_credentials — replaced wholesale when populated on the payload. Wholesale rather than merged because handlers produce the complete set of inbound tokens for this request; the host’s pre-invoke Extensions wouldn’t normally carry one.
  • delegation — replaced wholesale when populated. Initial chain from act claims in the inbound credential.

Input fields on the payload (raw_token, headers, …) are not copied into Extensions — they’re the resolver’s internal workspace, not request-wide state.

Trait Implementations§

Source§

impl Clone for IdentityPayload

Source§

fn clone(&self) -> IdentityPayload

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 IdentityPayload

Source§

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

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

impl<'de> Deserialize<'de> for IdentityPayload

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 PluginPayload for IdentityPayload

Source§

fn clone_boxed(&self) -> Box<dyn PluginPayload>

Clone this payload into a new Box<dyn PluginPayload>. Read more
Source§

fn as_any(&self) -> &dyn Any

Downcast to a concrete type via &dyn Any. Read more
Source§

fn as_any_mut(&mut self) -> &mut dyn Any

Downcast to a concrete type via &mut dyn Any.
Source§

impl Serialize for IdentityPayload

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

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> 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> 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.
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