Skip to main content

SecurityContext

Struct SecurityContext 

Source
pub struct SecurityContext { /* private fields */ }
Expand description

A verified subject’s security context = the clearance label the monitor compares against object labels.

Construction is deliberately gated: you build it from a clearance (level + compartments, authority-asserted) and verified key material (assurance, crypto-derived). The assurance axis of the resulting label is ALWAYS the derived one — a caller cannot pass in a higher assurance than the crypto supports.

Implementations§

Source§

impl SecurityContext

Source

pub fn new( level: Level, compartments: CompartmentSet, key_material: VerifiedKeyMaterial, ) -> Self

Build a subject context from an authority-asserted clearance (level + compartments) and crypto-derived key_material.

The resulting clearance’s assurance axis is clamped to the derived assurance — a classical key can never carry a PqHybrid clearance even if policy mistakenly assigned one. This is the load-bearing invariant of #548: assurance is a property of the verified identity, not a grant.

Source

pub fn from_clearance( clearance: SecurityLabel, key_material: VerifiedKeyMaterial, ) -> Self

Build from a pre-assembled clearance label and verified key material, clamping the assurance axis down to what the crypto supports.

min(clearance.assurance, derived) — clamp DOWN only, never up. If policy assigned PqHybrid but the key is Classical, the effective assurance is Classical (fail-closed/least-privilege).

Source

pub fn derive_assurance(key_material: VerifiedKeyMaterial) -> Assurance

Derive assurance directly from verified key material (#548). Thin forwarder kept as a named entry-point so the enforcement/PDP layers (S2/S4) have one obvious call site.

Source

pub fn clearance(&self) -> &SecurityLabel

The clearance label. This is the subject.ctx the monitor feeds into can_access(object_label).

Source

pub fn can_access(&self, object_label: &SecurityLabel) -> bool

self ⊒ object — does this subject context dominate the object’s content-bound label? The per-op MAC floor (design §10). Pure forward to the intrinsic lattice order.

Source

pub fn can_write_to(&self, object_label: &SecurityLabel) -> bool

object ⊒ self — Bell–LaPadula *-property (no-write-down): may this subject write to the object? Write-direction IFC floor (#1269). Forward to SecurityLabel::can_write_to.

Source

pub fn level(&self) -> Level

Source

pub fn assurance(&self) -> Assurance

Source

pub fn compartments(&self) -> CompartmentSet

Source

pub fn delegated_meet( delegator: &SecurityContext, actor: &SecurityContext, ) -> SecurityContext

#681 two-principal composition for a delegated call. THE single shared derivation — both the S6 token-exchange gate (#680) and the downstream PDP call this; it is never re-implemented (a parallel impl would drift into the exact escalation hole this closes).

  • Level + compartments = meet(delegator, actor) (min level, compartment intersection). The effective clearance dominates an object only if both the authority source (delegator = UCAN chain root) and the acting receiver (actor = the presenter/MCP that signs the downstream envelope and receives the bytes) dominate it. Never either alone.
  • Assurance = the actor’s (the signer’s verified key material, already clamped into actor’s context per #548). The actor signs the downstream envelope and receives the object bytes, so the crypto floor that governs the read is the actor’s — not the delegator’s (who authorizes but never receives). A Classical actor thus cannot reach a PqHybrid-labeled object even if the delegated clearance claims PqHybrid.

meet(root, actor) is sufficient: intermediate delegation hops carry authority, not data (bounded by UCAN capability attenuation), and never receive the object bytes — so their clearances do not enter the read floor.

Source

pub fn delegated( delegator: Option<&SecurityContext>, actor: Option<&SecurityContext>, ) -> Option<SecurityContext>

Fail-closed wrapper over Self::delegated_meet: None (→ deny) if either principal’s clearance is unresolved (#681 AC — no default clearance for a missing principal). This is the entry point the exchange gate and the PDP both call.

Trait Implementations§

Source§

impl Clone for SecurityContext

Source§

fn clone(&self) -> SecurityContext

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 SecurityContext

Source§

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

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

impl<'de> Deserialize<'de> for SecurityContext

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 PartialEq for SecurityContext

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for SecurityContext

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 Eq for SecurityContext

Source§

impl StructuralPartialEq for SecurityContext

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
§

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

§

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

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

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

§

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

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T> ServiceExt for T

§

fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>
where Self: Sized,

Apply a transformation to the response body. Read more
§

fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>
where Self: Sized,

High level tracing that classifies responses using HTTP status codes. Read more
§

fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>
where Self: Sized,

High level tracing that classifies responses using gRPC headers. Read more
§

fn follow_redirects(self) -> FollowRedirect<Self>
where Self: Sized,

Follow redirect resposes using the Standard policy. Read more
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

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

§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSend for T
where T: Send,

§

impl<T> MaybeSend for T
where T: Send,

§

impl<T> MaybeSync for T
where T: Sync,

§

impl<T> MaybeSync for T
where T: Sync,

Source§

impl<T> TerminalState for T
where T: Clone + Send + Sync,