Skip to main content

AccessView

Struct AccessView 

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

An immutable per-request snapshot of one principal’s access.

Holds the config Arc taken at request start so a single request evaluates against one consistent config, plus a handle to the shared attribute cache for label/role lookups by identity.

Implementations§

Source§

impl AccessView

Source

pub fn enforced(&self) -> bool

True when this view actually enforces anything.

Source

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

Source

pub fn groups(&self) -> &BTreeSet<String>

Source

pub fn is_admin(&self) -> bool

Source

pub fn decide( &self, action: &str, resource: &AccessResource<'_>, ) -> AccessDecision

Full check against explicit resource attributes.

Source

pub fn allows(&self, action: &str) -> bool

Check an action with no resource (e.g. gating.decide).

Source

pub fn may_perform_anywhere(&self, action: &str) -> bool

Coarse capability check: could this principal perform action against at least one resource? Used to intersect capability advertisements (mobkit/capabilities) so the console doesn’t surface affordances the caller can never use; per-resource enforcement still applies per call.

Source

pub fn allows_agent(&self, action: &str, identity: &str) -> bool

Check an action against an agent identity, resolving cached attributes (role/labels) when available.

Source

pub fn decide_agent(&self, action: &str, identity: &str) -> AccessDecision

Full decision for an action against an agent identity, resolving cached attributes (role/labels) when available. The argument may also be a runtime agent/member id; the cache resolves it back to the identity it belongs to.

Agents carry their spawn lineage as a spawned_by label (recorded by the agent-tool spawn path). A spawned member inherits its spawning parent’s permissions: rules that match the parent — or any ancestor — also match the member, with deny-overrides preserved across the chain.

Source

pub fn can_view_agent(&self, identity: &str) -> bool

Convenience: can this principal see the given agent at all?

Source

pub fn knows_agent(&self, identity: &str) -> bool

True when the agent’s resource attributes (role/labels) are present in the shared attribute cache, keyed by identity or projected agent_id.

A cache-MISS means decide_agent falls back to a bare-identity resource with role: None, labels: None, so a label/role-scoped deny rule fails the rule closed and DOES NOT match — i.e. the agent is not actually hidden. Long-lived SSE streams use this to detect a member spawned after the one-time subscribe prime and re-prime the cache before deciding, so the deny resolves against real attributes instead of failing open.

Source

pub fn can_administer(&self) -> bool

Can this principal read and edit the access configuration?

Admins always can. While enforcement is enabled, subjects granted access.admin by rule also can. While the feature is disabled and no admins are configured yet, any caller can — this is the bootstrap path that lets a fresh deployment configure itself from the console before flipping enforcement on (enabling requires naming admins).

Trait Implementations§

Source§

impl Clone for AccessView

Source§

fn clone(&self) -> AccessView

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 AccessView

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> 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> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
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> 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

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

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + 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
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + 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
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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