Skip to content

docs: add AuthHook trait design proposal#169

Open
englishm-cloudflare wants to merge 1 commit into
cloudflare:mainfrom
englishm-cloudflare:docs/authhook-design
Open

docs: add AuthHook trait design proposal#169
englishm-cloudflare wants to merge 1 commit into
cloudflare:mainfrom
englishm-cloudflare:docs/authhook-design

Conversation

@englishm-cloudflare
Copy link
Copy Markdown
Contributor

Design sketch for a pluggable AuthHook trait to support intra-scope
authorization in the relay. Covers the trait surface, supporting types,
invocation points, and reference implementation sketches for PrivacyPass
and C4M (CAT for MoQ) auth schemes.

Intended as a shared reference for contributors working on PP and C4M
implementations in parallel.

Design sketch for a pluggable AuthHook trait to support intra-scope
authorization in the relay. Covers the trait surface, supporting types,
invocation points, and reference implementation sketches for PrivacyPass
and C4M (CAT for MoQ) auth schemes.

Intended as a shared reference for contributors working on PP and C4M
implementations in parallel.
Copy link
Copy Markdown

@thibmeu thibmeu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall seems to be the right shape to experiment with

Comment thread docs/AUTH_HOOK_DESIGN.md

## DenyReason → wire codes

On the SETUP path, any `Verdict::Deny(_)` produces session termination with `UNAUTHORIZED (0x2)`. The reason phrase carries the deny reason for diagnostic purposes.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be limiting for Privacy Pass integration in MoQ, which needs to reply with a challenge. See Section 3.4.5.1 of privacy-pass-moq-auth

Similar to C4M which has some of its own code, I suspect different authentication method would have difjferent Deny Reason.

Comment thread docs/AUTH_HOOK_DESIGN.md
Comment on lines +124 to +131
/// A fully-resolved AUTHORIZATION TOKEN parameter. Alias bookkeeping is
/// handled by the relay's transport layer; the hook always sees Type+Value
/// pairs, never raw alias directives.
pub struct AuthBlob {
/// Token type from the IANA "MOQT Auth Token Type" registry.
pub token_type: u64,
pub token_value: Bytes,
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably worth mentioning AUTHORIZATION TOKEN parameter directly.

Specifically, there are possible alias

Token {
  Alias Type (vi64),
  [Token Alias (vi64),]
  [Token Type (vi64),]
  [Token Value (..)]
}

Comment thread docs/AUTH_HOOK_DESIGN.md

1. Parsing AUTHORIZATION TOKEN parameters from SETUP and per-message KVPs.
2. Resolving aliases (REGISTER → store, USE_ALIAS → look up, DELETE → retire) using an `AuthTokenCache`.
3. Surfacing the resolved set as `Vec<AuthBlob>` — `(token_type, token_value)` pairs — to the hook.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as mentioned before: need some issue in moqt

Comment thread docs/AUTH_HOOK_DESIGN.md

The relay's request pipeline, with `AuthHook` invocation points:

| Stage | Hook call | On `Deny` |
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leaving here because I think we need to dive before having an answer: this is a place where order might matters: decode before scope, or even scope before knowing the right challenge to return (think of two distinct namespace that use two distinct issuers).

Comment thread docs/AUTH_HOOK_DESIGN.md
Comment on lines +116 to +120
Publish { namespace: &'a TrackNamespace, track: &'a str },
Subscribe { namespace: &'a TrackNamespace, track: &'a str },
SubscribeNamespace { prefix: &'a TrackNamespace },
Fetch { namespace: &'a TrackNamespace, track: &'a str },
TrackStatus { namespace: &'a TrackNamespace, track: &'a str },
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: is &str the right interface? privacy-pass-moq-auth uses bytes, which I think avoid the whole UTF-8/normalisation question.

I would suggest &[u8] or something similar

Comment thread docs/AUTH_HOOK_DESIGN.md

- **No request mutation.** The hook returns allow or deny; it cannot rewrite namespaces or substitute auth scopes.
- **No outbound credential management.** If the relay needs to present credentials to an upstream origin, that is a separate concern (a future `UpstreamAuthProvider` trait or similar). `AuthHook` is strictly for incoming authorization.
- **No relay-side verdict cache.** Implementations that want per-session caching (e.g., parse a token once at SETUP and apply cached claims on subsequent operations) manage that state internally.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that design choice. Beyond the fact that everyone has different requirements, for privacy pass it's actually part of the privacy model

Comment thread docs/AUTH_HOOK_DESIGN.md

`AuthHook` is called at two points in the relay's request pipeline:

1. **At session establishment** — after AUTHORIZATION TOKEN parameters from CLIENT_SETUP have been decoded. Used to validate session-level credentials.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably worth using SETUP consistently instead of CLIENT_SETUP given draft -18 collapses them (despite still being defined)

Comment thread docs/AUTH_HOOK_DESIGN.md

## Forward-portability across MoQT draft versions

The initial PP and C4M PoC implementations will target **draft-16**, which is the version currently deployed in the reference relay. The next planned implementation target after the PoCs is **draft-18** (draft-17 will be skipped). Supporting multiple MoQT draft versions simultaneously in the relay is not a current goal, but it is something we expect to revisit after draft-18 lands.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

asgree with -16 as a target. there is some discrepencies in the wording that importsd some wording from draft 18 though: SETUP/CLIENT_SETUP/SERVER_SETUP for isntance. The assumption there is already a MOQT Auth Token Type registry, possibly others

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants