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
impl Gate
Sourcepub fn new(
memberships: Arc<dyn Memberships>,
roles: Arc<dyn Roles>,
resolve: Arc<dyn Resolve>,
) -> Gate
pub fn new( memberships: Arc<dyn Memberships>, roles: Arc<dyn Roles>, resolve: Arc<dyn Resolve>, ) -> Gate
A gate over a service’s memberships, roles and resolver.
Sourcepub fn with_liveness(self, liveness: Arc<dyn Liveness>) -> Gate
pub fn with_liveness(self, liveness: Arc<dyn Liveness>) -> Gate
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).
Sourcepub fn alive(&self, caller: &AuthContext) -> Result<(), String>
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.
Sourcepub fn lists(&self, role: &RoleName, grant: &Grant) -> bool
pub fn lists(&self, role: &RoleName, grant: &Grant) -> bool
Whether role lists grant (ADMIN lists every grant).
Sourcepub fn roles_listing(&self, grant: &Grant) -> Vec<RoleName>
pub fn roles_listing(&self, grant: &Grant) -> Vec<RoleName>
The roles that list grant, ADMIN last.
Sourcepub fn held_on(&self, caller: &AuthContext, grant: &Grant) -> Vec<ScopeRef>
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.
Sourcepub fn check(
&self,
caller: Option<&AuthContext>,
grant: &Grant,
target: Option<&str>,
) -> Result<Reach, Refusal>
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.
Sourcepub fn reach_of_public(
&self,
caller: Option<&AuthContext>,
grant: &Grant,
) -> Reach
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.