Expand description
Subscribe-time authorization + per-tenant announce scoping for the moq streaming plane (#276).
§Why this module exists
#274 made the moq streaming plane network-reachable (served on
web_transport_quinn at /moq, and over the iroh moql ALPN via
crate::transport::iroh_moq::IrohMoqProtocolHandler). That moved the
open-subscribe surface onto the network. This is not a content hole —
stream content is already protected by the §7.5 trust model (a 64-hex
DH-derived HKDF-of-ECDH capability topic, unguessable and learned only
from a signed StreamInfo over authenticated RPC, plus a per-frame chained
HMAC). #276 is metadata defense-in-depth:
- A connected peer can announce-enumerate broadcast (topic) names — moq
announces broadcasts by prefix, so a subscriber’s
announced()cursor sees every broadcast under its allowed prefix. Without scoping, a peer in tenantAcould enumerate tenantB’s broadcast names. - Subscribe-time authorization: a public stream stays open (preserving the working same-tenant subscribe model), but a private stream is gated through the existing policy engine.
§moq-net’s authorization primitive
moq_net::Server exposes no per-subscribe callback. Authorization in
moq-net is enforced structurally: a session can only enumerate/subscribe
to broadcasts that are visible through the [OriginConsumer] handed to
Server::with_publish. [OriginConsumer::scope] / [OriginConsumer::with_root]
narrow that visibility by path prefix. So per-tenant announce scoping is
implemented by handing each accepted session a tenant-scoped consumer
(see tenant_scoped_consumer) — a subscriber that cannot see a
broadcast cannot subscribe to it either.
The subscribe authorization hook (SubscribeAuthorizer) is the
pluggable policy layer on top of that structural scoping, for the
public-vs-private distinction within a tenant. Until moq-net exposes the
per-track callback tracked by #276, installing an authorizer rejects the
session at admission. This is intentionally coarse but fail-closed: an
installed policy is never retained as dead configuration while tracks are
served around it.
Track names are hierarchical {tenant}/{service}/{topic}/{instance} (the
#134 CDN-portability invariant). The first path segment is the tenant.
Structs§
- Default
Authorizer - Default authorizer: public streams are open, private streams are policy-gated, and unknown classification fails closed for safety.
- MacSubscribe
Authorizer SubscribeAuthorizerbacked by the sharedMoqEventPepMAC floor.- Peer
Identity - Identity of the subscribing peer, as far as the moq accept path can determine it.
Enums§
- Subscribe
Decision - The outcome of a subscribe-authorization check.
- Visibility
- Whether a stream is publicly subscribable or policy-gated.
Constants§
- TRACK_
NAME_ SEP - The hierarchical track-name separator (
{tenant}/{service}/{topic}/{instance}).
Traits§
- Subscribe
Authorizer - Pluggable subscribe-time authorization hook for the moq accept path.
Functions§
- filter_
announces_ by_ tenant - Pure per-tenant announce filter — the independently-testable core of the scoping behaviour.
- is_
valid_ tenant_ segment - Return whether
tenantis one non-empty MoQ path segment. - tenant_
of - Extract the
{tenant}segment from a hierarchical track / broadcast name. - tenant_
prefix - Build the tenant prefix (
{tenant}/) used to scope announce enumeration. - tenant_
scoped_ consumer - Restrict an [
OriginConsumer] to a single tenant’s broadcasts.
Type Aliases§
- Policy
Gate - Evaluates a policy decision for a (subject, tenant, track) tuple. Returns
trueto allow. This is the seam onto the existing Casbin/PolicyService (PolicyManager::check_with_domain) withouthyprstream-rpcdepending on thehyprstreamcrate. - Shared
Subscribe Authorizer - Shared handle to a
SubscribeAuthorizersuitable for stashing on a long-lived server/handler. - Visibility
Fn - Classifies a track name as public or private. Returning
Visibility::Publickeeps the existing open model;Visibility::Privateroutes through the policy gate.