Skip to main content

Gate

Struct Gate 

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

The one rule in front of every call: the method’s grant, held through a role on the target’s scope, within the session’s ceiling. Default deny. Cheap to clone (one Arc); cheap to ask (memory only), so a stream may ask per event.

Implementations§

Source§

impl Gate

Source

pub fn new( memberships: Arc<dyn Memberships>, roles: Arc<dyn Roles>, resolve: Arc<dyn Resolve>, ) -> Self

A gate over a service’s memberships, roles and resolver.

Source

pub fn with_generation(self, generation: GrantsGeneration) -> Self

BIDIR-8: this gate, counting its moves in generation — the service’s one (GrantsGeneration), shared by every gate it builds. Without it a gate counts alone, from 0.

Source

pub fn generation(&self) -> &GrantsGeneration

BIDIR-8: the grants generation this gate’s answers are decided at.

Source

pub fn moved(&self, why: GrantsMove) -> u64

BIDIR-8: a write that could change this gate’s answers happened (the service wrote it — the gate keeps no memberships of its own): the generation moves once. Answers the generation now.

Source

pub fn with_liveness(self, liveness: Arc<dyn Liveness>) -> Self

AUTH-11: this gate, asking liveness whether a caller’s sign-in still stands before every check. Without it the gate still refuses a caller past its expires_at stamp (AuthContext::expired).

Source

pub fn alive(&self, caller: &AuthContext) -> Result<(), String>

AUTH-11: whether caller’s sign-in still stands: not past its expires_at, and live by the service’s Liveness. An anonymous context has no sign-in to end: Ok.

Source

pub fn lists(&self, role: &RoleName, grant: &Grant) -> bool

Whether role lists grant (ADMIN lists every grant).

Source

pub fn roles_listing(&self, grant: &Grant) -> Vec<RoleName>

The roles that list grant, ADMIN last.

Source

pub fn held_on(&self, caller: &AuthContext, grant: &Grant) -> Vec<ScopeRef>

Where the caller holds grant, within its ceiling: [*] when everywhere, [] when nowhere (and for an anonymous caller). What a method without a target answers from. ONE-6: data scopes only — an address scope is never among them.

Source

pub fn fingerprint(&self, caller: &AuthContext) -> Option<Fingerprint>

PERF-15: what this gate’s answers about caller read, besides the grants generation — its principal’s memberships and its session’s ceiling (Fingerprint); None when it is anonymous. The memberships are read now, from memory.

Source

pub fn held_on_by(&self, who: &Fingerprint, grant: &Grant) -> Vec<ScopeRef>

PERF-15: Gate::held_on for whoever has who — read from the fingerprint instead of the memberships, by the same rule, so a view built from it is exactly the one built from any caller it was taken of.

Source

pub fn check( &self, caller: Option<&AuthContext>, grant: &Grant, target: Option<&str>, ) -> Result<Reach, Refusal>

Allowed when the grant is listed by a role held on a scope in the target’s chain — or anywhere, for a call with no target — and every ceiling layer allows it the same way. The Reach is live (it asks this gate again on Reach::allows / Reach::current).

AUTH-11: first, the caller’s sign-in must still stand (Gate::alive) — a signed-out session holds nothing, so a socket that signed out cannot go on to call auth.grant.

ONE-6: decided on data scopes and * alone. An address scope never counts here — not for a target, and not as “held anywhere” for a read with no target: it opens a door (Gate::check_everywhere_at) and holds no data. A caller holding a grant only on addresses is refused here, as one holding it nowhere is.

Source

pub fn check_everywhere( &self, caller: Option<&AuthContext>, grant: &Grant, ) -> Result<Reach, Refusal>

KEEL-31: the check for a method that acts on the whole service (it names no target because its target is everything: a key rotated, a process spawned, a peer connected). Allowed only where the grant is held on * — by a role held on * that lists it, and every ceiling layer allowing it on * — never because it is held on some scope. A scoped admin, or a session minted admin@X, is refused, naming *. The reach is [*] and stays live by this same rule.

Source

pub fn check_everywhere_at( &self, caller: Option<&AuthContext>, call: &DispatchedCall, ) -> Result<Reach, Refusal>

ONE-6: the door — Gate::check_everywhere of the dispatched call, for its own grant: may this caller make this call at this address. Admitted where a role listing the grant is held on a scope that opens the call’s door — * (self), the activation’s address (/dyn for dyn.connect), the method’s own (/dyn.connect), or a subtree above it (/dyn.*) — and every ceiling layer has an entry allowing the grant on such a scope. A data scope never opens a door (KEEL-31), nor an address that does not cover the call (/ui, /dyn.peer.shop.*). A refusal names the activation’s address.

The reach says what was admitted apart from what data is held: Reach::holds_activation is true; Reach::held_on is the caller’s data scopes for the grant, as Gate::check reads them — [*] for a holder of *, [] for one who holds only addresses — so Reach::is_everywhere is true only for a real *. It stays live by this same rule, at the same door.

Source

pub fn reach_of_public( &self, caller: Option<&AuthContext>, grant: &Grant, ) -> Reach

The reach of a public method: what Gate::check would allow without a target, or an empty (still live) reach when the caller holds the grant nowhere or is anonymous. A public method is never refused.

Trait Implementations§

Source§

impl Clone for Gate

Source§

fn clone(&self) -> Self

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 Gate

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Gate

§

impl !UnwindSafe for Gate

§

impl Forget for Gate

§

impl Freeze for Gate

§

impl Move for Gate

§

impl Send for Gate

§

impl Sync for Gate

§

impl Unpin for Gate

§

impl UnsafeUnpin for Gate

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> 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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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