Skip to main content

TenantCapability

Struct TenantCapability 

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

Unforgeable proof of authority to mutate a single tenant’s quota counters.

Minted only by crate::TenantRegistry::register_with_capability; the _seal field is private to this crate so no downstream crate (and no hostile workload) can construct one out of thin air. Holding an Arc<TenantContext> is therefore no longer sufficient to drive that tenant’s bytes_in_use counter — the caller must also present the matching capability, which it can only get if it originally registered the tenant.

Clone is intentionally derived: the API gateway holds the authoritative copy and may need to hand clones to per-tenant subsystems (the scheduler, the memory pool, etc.). What is NOT derived is any From<TenantId> or public constructor, so a workload running inside tenant A cannot fabricate one for tenant B.

§Registry binding (H1 — always enforced)

Every capability carries an Arc<()> token that points to its minting registry’s allocation. Comparison is by Arc::ptr_eq, so a capability minted by registry A is rejected when presented against a context registered in registry B, even if both contexts happen to share the same numeric TenantId. Without this binding, capabilities from independent registries are interchangeable, which the H1 audit finding flagged as a cross-registry capability-confusion vector — see the note on RegistryAdminCapability for the threat model.

H1 fix: this binding is now UNCONDITIONAL and no longer behind the strict-cap-binding feature gate. A release build with the feature disabled still binds caps to their minting registry and still fails closed on cross-registry / forged-admin caps. The strict-cap-binding feature remains defined only to keep the typed *_strict admin APIs and the cap_binding_strict integration test compiling.

Implementations§

Source§

impl TenantCapability

Source

pub fn tenant_id(&self) -> TenantId

Identifier of the tenant this capability authorises.

Trait Implementations§

Source§

impl Clone for TenantCapability

Source§

fn clone(&self) -> TenantCapability

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 TenantCapability

Source§

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

Formats the value using the given formatter. 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> 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