fix(relay): route WebSocket auth by request domain#2386
Conversation
There was a problem hiding this comment.
Sorry @kixelated, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
WalkthroughThe WebSocket endpoint now derives authentication parameters from the request host and full original URI, including the path and query. Host extraction uses the 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@rs/moq-relay/src/websocket.rs`:
- Around line 85-88: Update request_auth_params to construct the URL using
uri.path_and_query() rather than formatting the full Uri, so absolute-form URIs
do not duplicate scheme and authority. Preserve the existing https scheme, host,
parsing error mapping to BAD_REQUEST, and auth.params_from_url flow.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 0bfdc123-9d08-4569-bd83-7317b78c13b6
📒 Files selected for processing (1)
rs/moq-relay/src/websocket.rs
e7d12f2 to
b908a34
Compare
What changed
Auth::params_from_urlto WebSocket fallback sessions, matching native WebTransport authentication routing.Uri::path_and_query, including for absolute-form requests.Root cause
The WebTransport accept path passed its full request URL through
Auth::params_from_url, but the WebSocket fallback constructedAuthParamsdirectly from only the request path and query. A URL such ashttps://demo.cdn.moq.pro/bbb.hangtherefore authenticated as/bbb.hangover WebSocket instead of/demo/bbb.hang, causing public and token-scoped project access to fail whenever the client fell back from WebTransport.The first URL reconstruction also formatted the entire
Uri. For absolute-form requests that would duplicate the scheme and authority. Restricting reconstruction topath_and_querymakes both HTTP URI forms behave identically.Validation
just ci(1,726 tests passed, repository checks, docs, and flake evaluation)cargo test -p moq-relay websocket_auth_applies_subdomain_routing -- --nocaptureafter rebasing onto currentmainPublic API changes
None.
(Written by GPT-5)