Expand description
Admission and authorization of sessions, decided by a Policy.
A node asks its policy when a session opens, in either direction, and
again later (see Event). The answer is a Decision. The building
blocks compose:
OpenandClosedadmit or reject everyone.from_fndecides with a synchronous closure.Policy::filternarrows a policy by a predicate.Queuehands each decision to the application.Verifydecides with aTokenVerifierwhen the peer presents a token, and with a fallback policy when it does not.
§Examples
Admit everyone to subscribe, except one peer:
use moq_ext_access::{
Grant,
policy::{self, Policy},
};
let policy = policy::Open(Grant::subscribe_only())
.filter(|request: &policy::PeerRequest<String>| request.peer() != "mallory");Structs§
- Authorization
- What an admitted session may do, and until when.
- Closed
- A policy that rejects everyone.
- Filter
- A policy that rejects the peers a predicate refuses, built by
Policy::filter. - FromFn
- A policy that decides with a closure, built by
from_fn. - JwtVerifier
- A
TokenVerifierof JWTs, which checks them with a moq-auth [KeySet] as moq-relay does. - MoqCapability
- What a holder may do at a moq node: publish and subscribe under a root.
- Open
- A policy that admits everyone with one grant.
- Peer
Request - A peer’s request for a session, as a policy sees it.
- Pending
- A request waiting in a
Queuefor the application’s answer. - Queue
- A policy that hands each decision to the application, through a bounded queue.
- Rcan
Verifier - A
TokenVerifierof rcan capability chains that a principal issued. - Rejection
- Why a policy rejected a session.
- Verify
- A policy that decides with a
TokenVerifierwhen the peer presents a token.
Enums§
- Event
- Why a node asks its policy.
Constants§
- MAX_
LINKS - The most links a capability chain may have.
- MAX_
LINK_ BYTES - The most bytes one encoded link of a capability chain may take.
Traits§
- DynPolicy
- A
Policywith its type erased, as a node stores it. - Policy
- A rule that decides whether a peer may hold a session, and with which rights.
- Token
Verifier - A check of the token a peer presents, which returns what the token authorizes.
Functions§
- decide_
within - Asks
policyaboutrequestwithintimeout, as a node does before it admits a session. - encode_
chain - Encodes a capability chain as a token, first link first.
- from_fn
- Returns a policy that decides with the synchronous closure
decide.
Type Aliases§
- Decision
- A policy’s answer: the session’s rights, or a rejection that closes it.