Skip to main content

Module policy

Module policy 

Source
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:

  • Open and Closed admit or reject everyone.
  • from_fn decides with a synchronous closure.
  • Policy::filter narrows a policy by a predicate.
  • Queue hands each decision to the application.
  • Verify decides with a TokenVerifier when 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 TokenVerifier of 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.
PeerRequest
A peer’s request for a session, as a policy sees it.
Pending
A request waiting in a Queue for the application’s answer.
Queue
A policy that hands each decision to the application, through a bounded queue.
RcanVerifier
A TokenVerifier of rcan capability chains that a principal issued.
Rejection
Why a policy rejected a session.
Verify
A policy that decides with a TokenVerifier when 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 Policy with its type erased, as a node stores it.
Policy
A rule that decides whether a peer may hold a session, and with which rights.
TokenVerifier
A check of the token a peer presents, which returns what the token authorizes.

Functions§

decide_within
Asks policy about request within timeout, 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.