pub struct WamiContext { /* private fields */ }Expand description
WAMI Context - carries authentication and authorization information
This context is created during authentication and passed to all service operations. It contains information about who is performing the operation and where it should be executed.
Implementations§
Source§impl WamiContext
impl WamiContext
Sourcepub fn builder() -> WamiContextBuilder
pub fn builder() -> WamiContextBuilder
Create a new context builder
Sourcepub fn is_root(&self) -> bool
pub fn is_root(&self) -> bool
Check if the caller is a root user
Root users have full access and bypass all authorization checks.
Sourcepub fn caller_arn(&self) -> &WamiArn
pub fn caller_arn(&self) -> &WamiArn
Get the caller’s ARN
Sourcepub fn provenance(&self) -> &[Step]
pub fn provenance(&self) -> &[Step]
How authority reached the current caller, oldest first.
The chain answers “by what route”, which no ARN should: an ARN names a thing, and one that grows a segment per service traversed stops being comparable — policies matching on it would break, and a trailing wildcard added to compensate would swallow segments nobody intended.
Sourcepub fn provenance_trail(&self) -> String
pub fn provenance_trail(&self) -> String
The provenance as one string, for an audit log.
The first principal, then one service:type/value segment per hand-off:
arn:wami:iam:12345678:wami:999:user/alice:sts:assumed-role/DataScientist/session1It exists to be queried. A trail in a text column answers “which
requests went through STS then SSO” with LIKE '%:sts:%:sso:%' — one
index, no join, no JSON operators. That is the most common question
asked of an audit log, and the structured chain answers it poorly.
This is a projection, not a serialisation: it is deliberately lossy, and
there is no parser back. Reconstructing a context from it would give
something that looks authoritative while having lost the full ARNs — use
WamiContext::provenance when the structure is what matters.
Note it is not the caller’s ARN, and must never be used as one. An identifier that grows a segment per service traversed stops comparing equal to itself, and every policy written against it silently stops matching.
Sourcepub fn through(
&self,
principal: WamiArn,
via: Transition,
) -> Result<WamiContext>
pub fn through( &self, principal: WamiArn, via: Transition, ) -> Result<WamiContext>
Derive the context that results from authority passing to principal.
One call writes both the new caller and the step recording the move, so the chain cannot end up describing someone other than the caller. The tenant path and instance follow the new principal, exactly as they do when a context is built.
Root is never regained: a context that was not root cannot become root by assuming something, whatever that something is named. It can only be kept, and only by staying on a root principal.
Fails past MAX_PROVENANCE_DEPTH.
Sourcepub fn tenant_path(&self) -> &TenantPath
pub fn tenant_path(&self) -> &TenantPath
Get the tenant path
Sourcepub fn instance_id(&self) -> &str
pub fn instance_id(&self) -> &str
Get the instance ID
Sourcepub fn session_info(&self) -> Option<&SessionInfo>
pub fn session_info(&self) -> Option<&SessionInfo>
Get session information (if temporary credentials)
Sourcepub fn mfa_present(&self) -> Option<bool>
pub fn mfa_present(&self) -> Option<bool>
Check if MFA was used for this request (if known)
Sourcepub fn secure_transport(&self) -> Option<bool>
pub fn secure_transport(&self) -> Option<bool>
Check if the request uses secure transport (if known)
Sourcepub fn can_access_tenant(&self, target_tenant: &TenantPath) -> bool
pub fn can_access_tenant(&self, target_tenant: &TenantPath) -> bool
Check if this context can access a specific tenant path
A context can access:
- Its own tenant
- Any child tenant below it in the hierarchy
- If root user: any tenant in the instance
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Check if the session has expired (for temporary credentials)
Trait Implementations§
Source§impl Clone for WamiContext
impl Clone for WamiContext
Source§fn clone(&self) -> WamiContext
fn clone(&self) -> WamiContext
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for WamiContext
impl Debug for WamiContext
Source§impl<'de> Deserialize<'de> for WamiContext
impl<'de> Deserialize<'de> for WamiContext
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>,
Source§impl From<&WamiContext> for MatchContext
Build a MatchContext from a WamiContext.
impl From<&WamiContext> for MatchContext
Build a MatchContext from a WamiContext.