Repository navigation
fix(api): accept admin mode only from console origins - #14813
Conversation
Admin mode authenticates with the console session, so its CORS and origin allowlists must not include the managed project's platform hostnames, custom schemes or site rules. Console preview rules from trusted projects are kept.
|
Review complete. 🟡 1 medium 📍 Findings outside the diff (1) — 🟡 1 medium — defects on lines GitHub can't attach comments to🟡 Medium — Realtime origin validator misses admin-mode restriction · app/init/realtime/connection.php The new admin-mode tightening in 🧹 Nitpicks (1) — 🟢 1 low
The change tightens admin-mode origin handling in the request resource and locks the new behavior in with an e2e test. The main gap is that the realtime origin validator still follows the old, permissive allowlist, so admin-mode WebSocket origins are validated less strictly than HTTP ones.
Reviewed commit: 215741a |
🟢 Tier S · Ready to merge
Admin-mode requests now exclude project-managed platform hosts, schemes, and non-trusted site-rule domains from the request allowlists, while default mode retains its existing origins. The new end-to-end test exercises admin-mode user and JWT calls from console and project origins, and confirms default-mode access from a project origin remains available.
📂 Walkthrough · 2
Reviewed |
|
Thanks. The realtime connection builds its own origin validator and its admin mode handling is being changed separately in #14790, so I kept this PR to the HTTP request allowlists. The realtime origin restriction for admin mode is tracked for that work rather than here. |
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
Security rulesNo new WARNING or ERROR findings from security rules. 6 existing findings tracked in
|
(cherry picked from commit 244d047)
…e-origins fix(api): accept admin mode only from console origins (cherry picked from commit 244d047)
What
Admin mode requests (
x-appwrite-mode: admin) authenticate with the console session. The allowed hostnames and schemes used for CORS, the origin check and redirect validation now leave out the managed project's platform hostnames, platform schemes and site rule domains when the request is in admin mode, so only console hosts can make credentialed admin mode calls. Site rules from_APP_CONSOLE_TRUSTED_PROJECTS(console previews) stay allowed. This also covers console JWT creation throughPOST /v1/account/jwtsin admin mode, which goes through the same origin check.Requests in default mode keep the existing behaviour: project platform origins are still allowed.
Compatibility
Tools that call admin mode endpoints from a browser page hosted on a project platform origin will get
general_unknown_origin. Server side calls without anOriginheader and API key calls are unaffected.Tests
New e2e
tests/e2e/General/AdminModeOriginTest.php: admin modeGET /v1/usersandPOST /v1/account/jwtssucceed from the console origin and are refused (403, no CORS grant) from a registered web platform origin, while a default modeGET /v1/accountfrom that platform origin still succeeds with the CORS grant. Pint, PHPStan and Rector pass locally; e2e runs in CI.Related: appwrite-labs/cloud#6666