Repository navigation
fix(realtime): align origin validation with the HTTP API - #14020
Conversation
The realtime handshake checked the Origin header against the platform allowlist for regular projects only. Apply the same check to every project, and allow the console URL host as the HTTP API already does. Co-Authored-By: Claude Fable 5.1 <[email protected]>
🔵 Tier A · Mergeable after minor fixes
Realtime now validates browser origins for console projects as well as regular projects, while retaining the no-Origin exemption. Its allowlist also includes the configured console URL host. A console-client E2E test covers accepted and rejected origins and checks server disconnection. Latest changes: The latest commit replaces the fixed disconnect sleep with a bounded socket read and disconnection assertion, and checks the error message prefix instead of its exact wording.
Fix with agent prompt### Issue 1
tests/e2e/Services/Realtime/RealtimeConsoleClientTest.php:200-203
**Cover a console URL host outside the existing allowlist**
The success case uses localhost, which is already allowed by the platform configuration, so it still passes if the new `consoleUrl` handling is removed. Please add a connection case with `_APP_CONSOLE_URL` on a distinct host not present in `_APP_DOMAIN`, `_APP_CONSOLE_DOMAIN`, or `_APP_CONSOLE_HOSTNAMES` to protect the separate-console deployment fix.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.📂 Walkthrough · 3
⏳ Still open from earlier reviews · 1
✅ Fixed since the last review · 1
Reviewed the commits since |
|
Co-Authored-By: Claude Fable 5.1 <[email protected]>
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
Brings in main's OAuth2 state and nonce validation (#14012), which cloud needs, along with the realtime origin alignment (#14020), subscriber target ownership (#14019), GitLab primary email (#14010), impersonation MFA (#14017), write-only webhook passwords (#14016), chunked-upload resume ownership (#14014), preview authorize validation (#14013), nightly forcing (#14015) and scheduled-function enqueue checks (#14011). The merge had no textual conflicts, and main left composer.json and composer.lock unchanged. So the lock keeps the branch's database and async pins. Main's assertResumeAllowed() in Storage Buckets/Files/Create checks Input(Database::PERMISSION_UPDATE, ...). utopia-php/database 8 has no PERMISSION_* constants, so every chunked resume would fail with an undefined-constant error. It now passes PermissionType::Update, as the rest of that action already does. Co-Authored-By: Claude Opus 5.5 <[email protected]>
What does this PR do?
The realtime handshake validates the
Originheader against the platform allowlist, but applied it to regular projects only, while the HTTP API applies one policy to every project. This makes the realtime handshake follow the same rules:Originheader (non-web clients) are unchanged._APP_CONSOLE_URLhost, as the HTTP allowlist already does, so a console served apart from the API host keeps working alongside_APP_CONSOLE_DOMAINand_APP_CONSOLE_HOSTNAMES.Test Plan
RealtimeConsoleClientTest::testConnectionPlatformconnects to the console project from an allowed origin and from an unknown one, expecting aconnectedframe and a policy violation respectively.RealtimeCustomClientTest::testConnectionPlatformkeeps covering regular projects.Related PRs and Issues
Checklist
🤖 Generated with Claude Code