Repository navigation
feat(net): a request grant admits only the request kinds it names - #9640
Draft
ksletmoe-aws wants to merge 2 commits into
Draft
ksletmoe-aws wants to merge 2 commits into
ksletmoe-aws wants to merge 2 commits into
Conversation
A grant issued to a moq-transport request token covered SUBSCRIBE,
FETCH and TRACK_STATUS alike by its subscribe prefixes, and
SUBSCRIBE_NAMESPACE by any subscribe prefix. Requests reusing a token
share its first verdict, so an acceptor that granted a SUBSCRIBE also
admitted the other reads at those paths, with no way to refuse them.
`auth::Grant` gains `kinds`, a `RequestKinds` set checked for every
request naming the token; the default is every kind. `RequestKind` is
public again with the reads split into Subscribe, Fetch and
TrackStatus, and `auth::Request::{kind, path}` report the request that
named the token first. A quest plans moq-relay's use of both.
…path} The acceptor needs only to grant some request kinds and not others; the first naming request's kind and path depend on request order and have no consumer. Drop them and the relay quest, and log an acceptor that narrows an AUTH token's kinds while telling the peer only that the grant was refused. Add a wire test for a renewal granted without SUBSCRIBE on a live subscription.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
NOTE: draft, opened beside #9630, whose subscriber credential (
auth::Handle::set_subscribe_auth) is the consumer motivating this change. The branch is independent of #9630 and based on main; review #9630 first.Problem
With #9630, one subscriber credential rides every SUBSCRIBE, standalone FETCH and TRACK_STATUS its session sends, so an acceptor needs to grant some of those kinds and not others: a token scoped to live viewing must not read past groups or probe tracks it was not granted. It cannot today. A grant issued to a moq-transport request token covers SUBSCRIBE, FETCH and TRACK_STATUS alike through its
subscribeprefixes, and SUBSCRIBE_NAMESPACE through anysubscribeprefix.Link::verify_requestverifies a token once per session while any request naming it is open, so a later request reusing the token shares the first verdict and never reaches the acceptor.Approach
auth::Grantgainskinds: RequestKinds, the request kinds a request-borne grant admits.RequestKind::coverschecks it for every request naming the token, inRequestGrant::new,renew, and an acceptor'sIssued::update, so a request reusing a shared token is held to it too.Grant::default()andGrant::all()admit every kind, so existing acceptors behave as before.RequestKindis public,#[non_exhaustive], with the read kind split intoSubscribe,Fetch(standalone) andTrackStatus, besidePublishNamespace,DiscoverandPublish. A joining FETCH stays under its subscription's grant.Handle::authorize) admits every kind, soRequest::acceptandIssued::updaterefuse an AUTH token's grant that narrowskindsrather than silently widen it. The refusal is logged, the peer is told only "grant refused", and onupdateit ends the existing grant.{Subscribe}also refuses the standalone FETCHes and TRACK_STATUS a subscriber sends for group recovery and fills on that token, so that subscriber loses head recovery on route changes. GrantFetchandTrackStatusbesideSubscribeto keep it.a_grant_admits_only_its_request_kinds_on_a_shared_token(publisher, moq-transport 18, 20, 22, 23): a SUBSCRIBE-only grant keeps its subscription and a joining FETCH (draft 18), and refuses a TRACK_STATUS, a standalone FETCH and a SUBSCRIBE_NAMESPACE reusing the SUBSCRIBE's token, which never reach the acceptor. A default grant admits all of them.a_renewal_without_the_subscribe_kind_ends_the_subscription(publisher, moq-transport 18 and 22): a REQUEST_UPDATE renewed without SUBSCRIBE gets REQUEST_ERROR with the unauthorized code, and the subscription ends with PUBLISH_DONE UPDATE_FAILED.a_reused_token_is_held_to_the_grants_kinds,an_update_dropping_the_kind_ends_the_request,a_renewal_dropping_the_kind_is_refused(the old grant stays at the auth layer; the publisher ends the subscription on any refused renewal, as before),an_auth_token_refuses_a_narrowed_grant,a_grant_covers_only_its_kinds.Impact
auth::Grant.kinds,auth::RequestKind,auth::RequestKinds(all,contains,without,From<RequestKind>,FromIterator; noDefault, since the empty set is not a grant's default).Grantis#[non_exhaustive], so the field is not a break;Grant::default()still grants no paths.kindsat its default. An AUTH token's grant that narrowskindsis refused.Alternatives
subscribe(for exampletrack_statusprefixes) instead of a kinds set: one field per kind multiplies prefix sets, and the kinds set composes with the existing prefixes.Follow-ups
moq_auth::Grantkinds field intoauth::Grant::kinds.ServePublish): no harness drives one today, so itsRequestKind::Publishenforcement is untested, as before this change.Validation
Locally on the head, based on main 48ec786:
cargo fmt --check;cargo clippy -D warningsover moq-net, moq-relay, moq-ffi, moq-tokio and libmoq with all features, and moq-net with no default features;cargo doc -D warningsfor moq-net with all features and with none;cargo shear;cargo sort --check;sh/rs/coroutines.sh moq-net;sh/markdown.sh check; nextest over moq-net, moq-relay, moq-ffi, moq-tokio and moq-auth, 6261 passed.just ciwas not run: this host has no Nix orquestbinary.Models
Implementer: Kiro, claude-opus-5.5. Reviewed in separate adversarial sessions (claude-fable-5.1 and claude-opus-5.5) before the first push.
(Written with AI assistance: Claude Opus 5.5)