Repository navigation
feat(relay)!: an attached token arrives as a token, not in the query - #8923
Conversation
Quest-Claim: 1e5f764cbd36dd29
An in-band credential now rides Request.token (kind 0, any bytes) on attach and leaves query as dialed. The relay drops with_jwt, the UTF-8 refusal, and the query jwt check in its public rules; moq auth serve reads an event with auth from its token alone. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. WalkthroughThe relay now sends attached credentials in the token field without changing the dialed query. The auth server uses that token for attachment authorization and supports a query-JWT fallback when an older relay omits the token. Public-rule admission checks for a request token rather than a JWT query parameter. Documentation and tests describe and verify these behaviors, including binary token bytes and compatibility cases. Merge Risk:
|
There was a problem hiding this comment.
Important
moq auth serve mishandles both of a previous-release relay's requests for an attached credential. It refuses the attach. For a revalidate it ignores the credential and decides on the anonymous rules. During a rollout with mixed relay versions, that breaks in-band renewal on the old relays.
Reviewed changes
I reviewed the relay, moq auth serve, the contract docs and the tests that move an attached credential from a rewritten query into Request.token.
- Relay attach:
refresh.rsnow clones the connection's request and setstokento{kind: 0, bytes}without touchingquery.with_jwtand the UTF-8 refusal are removed. Revalidate and end replay the same facts, so they carry the token too. - Public rules:
presents_tokenis removed, so public rules refuse a request only when it has a SETUPtoken. A?jwt=query is now admitted on the public grant, as Decision 1 says. moq auth serve:jwt()ignores the query wheneverauthis set.answer()refuses anAttachthat has no token.- Docs and contracts: the
tokenfield docs inrequest.rs,contract.tsandauth.mdnow describe the attached credential. - Tests: the refresh tests assert that the dialed query passes through unchanged. A binary token now reaches the decider unchanged, and the integration test checks the shape of the
attachrequest.
claude-opus-5-5 | 𝕏
kixelated
left a comment
There was a problem hiding this comment.
Automated review by review (OpenAI)
Reviewed commit: 9f99184af5f1181c6796ea7b748215edbd2beb0a.
I confirmed the mixed-relay rollout blocker. “Auth server first” is not a safe rollout with either server as written: the new server refuses old attaches, and an old query-only handler can authorize a new attach as the dial-time identity. For attach and attached revalidation, deploy a dual reader first: if token is present, validate it and never fall back to query on an invalid token; if absent, accept only the old attached-query shape with a valid credential, never anonymous. Cover both relay generations in the same integration test, then move relay senders.
Keeping the original query opaque and delivering raw token bytes is a good separation. Independently, the public-rule change admits clients presenting a query-only JWT on the anonymous grant; it does not bestow the JWT's grants, but it is a deliberate admission-policy change rather than a necessary part of moving the attachment. I'd keep that decision separate from the compatibility fix.
Static review only; I did not run auth tests or check live deployments. COMMENT only, not approval.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… from the query A relay before this change rewrote an attached credential into the query's jwt and cleared the token. Keep reading that shape on attach and revalidate as a marked temporary migration, and refuse an event with auth that carries no credential rather than deciding it on the anonymous rules. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
kixelated
left a comment
There was a problem hiding this comment.
Automated review by review (OpenAI)
Reviewed commit: 5287e4ecd9f76b3ab9bcb68feb0ec88145368cfc.
The built-in auth server now handles both relay generations for attach and revalidate. The current relay sends token on attach, and the server never falls back to the query when that field is present. I’d add a negative fixture with a valid dial JWT and an invalid or expired attached token to pin that rule.
The built-in fix does not make a query-only external auth handler safe for the new sender. Update and verify those handlers before rolling out the relay, then remove the temporary missing-token fallback after the last old sender is gone. Until then, a missing token plus a query JWT is indistinguishable from the old format. Static review only; no tests or deploys run.
There was a problem hiding this comment.
✅ No new issues found. The mixed-relay concern from the prior review is fixed.
Reviewed changes
This review covers the changes since the prior Pullfrog review at 9f99184. The merge of main brought in only quest README churn.
- Temporary migration in
jwt(): when a request hasauthbut notoken,jwt()now reads the query'sjwt, which is the shape a previous-release relay sends. It refuses the request asMalformedTokenwhen there is no queryjwteither. Whentokenis present, the query is still ignored, so a bad attached token never falls back to the dial credential. answer()guard: theAttachguard checks only for a missingauthagain.decide_rootanddecidecalljwt()before reaching the mTLS or public rules, so an attachment with no credential is refused on bothattachandrevalidaterather than decided anonymously.- Tests: added
a_previous_relays_attachment_is_read_from_its_queryforattachandrevalidate, plus checks that a bare attachment is refused. - Docs and quest:
auth.mdmentions the temporary query read.auth-attach-downstream.mdrecords that moq.pro's edge reads onlyqueryand has to be updated before it meets a relay with this change.
claude-opus-5-5 | 𝕏
The publish side buffered what a widened grant newly showed after its flush, then rested with it unsent: the grant's wakeup was spent. Also repairs two bench fixtures: moq-lite-07's Announce Stream holds a uni stream grant beside the delivery-credit groups, and an attached token arrives as the request's token since #8923. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Finishes
quest/m2/auth-attach-token.md.Summary
A credential a client attaches in band now reaches the auth server as
Request.token(kind0, the bytes as sent) andquerystays exactly as dialed. The relay no longer knows the namejwtand no longer needs an attached token to be UTF-8.attachsetstokenand leavesqueryalone.with_jwtand the UTF-8 refusal are deleted. Public rules refuse a request with atokenand no longer read?jwt=(see Decisions).moq auth serve: an event withauth(attach, and that credential'srevalidateandend) reads its JWT fromtoken, so the dialed query'sjwtneither conflicts with it nor stands in for it. Temporary migration: when such an event has notoken, it is a previous-release relay's, which put the attached JWT inquery, so thatjwtis read instead. An event withauthand no credential at all is refused as malformed, never decided on the anonymous rules.request.rs,js/auth/src/contract.ts,doc/bin/relay/auth.md.?jwt=as the fallback before lite-07, unchanged.js/netis untouched, so no overlap with feat(net): a JS Connection reports the peer's verdict on its tokens #8902.Impact
Rust and JS public API: doc comments only. Wire: none (no
just test interop --all).HTTP contract: breaking for
attach. An auth server that read the attached credential fromqueryjwtnow sees the connection's first credential there and the attached one intoken.Migration for auth servers: for an event with
authset (attach,revalidate,end), read the credential fromtokenand ignorequery's credential.moq auth servedoes, and for the rollout also still reads a previous-release relay'squeryshape (marked temporary inserve.rs; delete at the next version cut), so it is safe to deploy before the relays. An old server given a new relay'sattachverifies the stale dialed query, so update auth servers first.Downstream, checked at moq.pro
9373cdfb3:rs/edge/src/auth/mod.rsreads the credential only fromrequest.query(query_jwt,:393), neverrequest.token:Endforgets the query credential (:1312-1317),AttachandRevalidatedecide on the query'sjwt(:1331,:1061,limits.rs:179/383/419). So moq.pro must readtokenbefore it meets a relay with this change; plain?jwt=dials are unaffected. Kixel'ssrc/mesh.ts:557reads acredentialquery parameter, and its client has no attach use today. See Follow-ups.Validation
quest gate cargo test -p moq-auth -p moq-relaypasses, andjust check.in_band_tokens_widen_and_withdraw_live_prefixes(relay over real QUIC and upgraded WebSocket against a scripted HTTP auth server) now asserts theattachrequest hasquery == "jwt=token"as dialed andtoken == {kind: 0, value: "replacement"}.&/=bytes) token reaches the decider unchanged and the dialed query is untouched (a_binary_token_is_attached_unchanged);moq auth serverenews a session whose dialed query holds an expiredjwt, onattachandrevalidate, and refuses anattachwithout a token (an_attached_credential_is_read_from_its_token); the existing token-cap test now attaches throughtoken.Decisions
Taken on my recommendation while the maintainer was away; the maintainer confirmed 1, 2, 4 and 3 and kept the follow-up on 2026-11-16 (/quest-run).
--auth-public) no longer refuse a request whose query has ajwt; they refuse only atoken. The quest says the relay holds no parameter name, and public rules have no server to ask. Cost: a pre-lite-07 client that dials a public relay with?jwt=is now admitted on the public grant instead of refused. Alternative: keep thejwtread inpresents_token, which keeps the name in the relay.moq auth servekeys onauthbeing set, not onevent == attach, sorevalidateandendof an attached credential read the same token (the relay replays the attach request for them). An event withauthand no credential isMalformedToken.authset, notoken, the credential inquery) is still read fromquery, as a temporary migration, because moq.pro runs the newest and previous relay releases side by side. Alternative: refuse that shape and break in-band renewal on old relays during the rollout. Taken on the AGENTS.md rule; undo by returningMalformedTokenfor(Some, None)injwt().kindis 0, as the quest says.Follow-ups
Maintainer:fix of the moq.proattachhandler (it reads onlyquery, as found above) and a check of Kixel's before this reaches them. No open decisions.Caused by
No single PR: the
jwtrewrite is as old as in-band attach.Models
Size: S
Implementer: Claude Code, claude-sonnet-5-5, high effort (arm B)
(Written by Claude Sonnet 5.5 with high effort)
Review
Rewritten by
quest reviewafter each round.Head: 5287e4e
Base: origin/main at 73d65ed
Risk: high,
Credential selection affects the authentication boundary for relay users; an incorrect grant could expose data, which reverting the change cannot undo.Classified: medium by default
Reviewer: Codex, gpt-6.1-sol, medium effort
Session:
01a1e468-53f4-7831-8bd9-e2b89e0928ec, round 2Score: 9/10,
No actionable defects found in the incremental changes: the temporary fallback supports previous-release relay attachments while preserving token precedence, with execution checks intentionally not run.Raised the risk to high:
Credential selection affects the authentication boundary for relay users; an incorrect grant could expose data, which reverting the change cannot undo.Rounds: 2; first round 0; findings 0: fixed 0, refuted 0, open 0
Findings: none