Skip to content

fix(sites): keep console auth cookies out of runtimes and tighten preview access - #14823

Merged
ChiragAgg5k merged 1 commit into
mainfrom
fix/site-preview-auth
Oct 22, 2026
Merged

ChiragAgg5k merged 1 commit into
mainfrom
fix/site-preview-auth

Conversation

@ChiragAgg5k

@ChiragAgg5k ChiragAgg5k commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

What

  • The router no longer forwards console auth cookies to site and function runtimes. a_jwt_console (the preview cookie), a_session_console and a_session_console_legacy are left out of the cookie header passed to executions. All other cookies are still forwarded.
  • New Request::getHeadersWithoutCookies(array $names) builds the synthesized cookie header without the named cookies. getHeaders() now delegates to it.
  • Preview access now requires a confirmed console membership in the project's team (confirm === true). Pending invitations no longer grant access.
  • Preview access now requires the session bound to the preview JWT to still be active (User::sessionActive()), not just present on the user.

Compatibility

Project session cookies (a_session_<projectId>) are still forwarded. Appwrite's SSR guides tell sites to set and read that cookie themselves, so stripping it would break SSR auth. Only the console cookies, which belong to Appwrite and not to the site, are removed.

Tests

  • Unit: tests/unit/Utopia/RequestTest.php covers named cookies being left out, and the cookie header being omitted when no cookies remain.
  • E2E: SitesCustomServerTest::testPreviewCookies deploys the Astro SSR fixture with a new /cookie-header page and checks that only non-console cookies reach the runtime through a preview domain. testPreviewDomain now also checks that a pending (unconfirmed) console invitee is redirected to preview auth.

Related: appwrite-labs/cloud#6673

…view access

Site and function runtimes received every request cookie, including the console preview JWT and console session cookies. Preview access also accepted unconfirmed console memberships and expired sessions.
@luxor-code-review

luxor-code-review Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Review complete. No issues found — approved ✅.


The change tightens preview-domain access control and pins cookie-forwarding behavior for sites runtimes. Verified scans (correctness, security, domain, holistic, sweep) found no issues meeting the reporting threshold.

Files Change
app/controllers/general.php Preview auth now requires an active (non-expired, non-revoked) session via sessionActive() instead of a raw membership sessions list check.
src/Appwrite/Utopia/Request.php Adds getHeadersWithoutCookies(), which strips the raw Cookie header and synthesizes one excluding configured console/session cookies.
tests/unit/Utopia/RequestTest.php Unit tests pinning the cookie-header filtering semantics, including full omission when all cookies are excluded.
tests/e2e/Services/Sites/SitesCustomServerTest.php E2E coverage asserting preview cookies are not forwarded to the SSR runtime and authorization redirects behave as expected.
tests/resources/sites/astro/src/pages/cookie-header.js Astro test page echoing received headers to verify cookie filtering end-to-end.

One reviewer candidate about legacy membership documents missing the confirm attribute was examined and judged not reachable: every membership-creation path writes the boolean confirm attribute.

Reviewed commit: 40495bc

@ChiragAgg5k ChiragAgg5k self-assigned this Oct 22, 2026
@ghost

ghost commented Oct 22, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

The router now omits Appwrite console cookies from headers sent to function and site runtimes, while preserving other cookies. Preview authorization also requires a confirmed team membership and an unexpired session bound to the JWT.

Verdict New comments Fixed Still open
✅ Approved 0 0 0
📂 Walkthrough · 5
File Change
app/controllers/general.php Require active sessions and confirmed team membership for preview access, and filter console cookies from runtime headers.
src/Appwrite/Utopia/Request.php Add a header accessor that omits selected cookies while preserving the existing accessor.
tests/e2e/Services/Sites/SitesCustomServerTest.php Cover pending-invite preview denial and runtime cookie filtering.
tests/resources/sites/astro/src/pages/cookie-header.js Add an Astro SSR route that returns the received cookie header.
tests/unit/Utopia/RequestTest.php Test cookie filtering and omission of an empty synthesized cookie header.

Reviewed 40495bc · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Tier A · Looks good to merge. Summary

Comment thread app/controllers/general.php Resolved
@github-actions

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → fix/site-preview-auth (after).

Metric Before After Change
🚀 Requests/sec 184.63 191.46 ⚪ +3.7%
⏱️ Latency P50 93.14 ms 89.86 ms ⚪ -3.5%
⏱️ Latency P95 214.62 ms 211.5 ms ⚪ -1.5%
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 89.86 211.5 12,198 191.46 -3.13
Account 172.55 320.41 642 10.65 +7.93
TablesDB 86.24 162.88 6,634 107.2 -5.2
Storage 83.97 195.52 3,210 53.48 +0.4
Functions 124.81 248.57 1,712 29.13 -12.98

Top API waits (after)

API request Max wait (ms)
account.prefs.update 430.5
account.name.update 418.2
functions.create 386.27
functions.variables.update 381.65
storage.buckets.create 373.02

@github-actions

Copy link
Copy Markdown

Security rules

No new WARNING or ERROR findings from security rules.

6 existing findings tracked in .semgrep/baseline.json
  • php.appwrite.guest-write-without-abuse-limit (3)
  • php.appwrite.secret-compare-timing (1)
  • php.appwrite.weak-secret-env-default (2)

Posted by Checks / Rules. Re-runs update this comment in place. Rule details and baseline: .semgrep/README.md.

@ChiragAgg5k
ChiragAgg5k merged commit ff45743 into main Oct 22, 2026
74 checks passed
ChiragAgg5k added a commit that referenced this pull request Oct 24, 2026
…view access (backport #14823)

(cherry picked from commit ff45743)
ChiragAgg5k added a commit that referenced this pull request Oct 24, 2026
…view access (backport #14823)

(cherry picked from commit ff45743)
ChiragAgg5k added a commit that referenced this pull request Oct 24, 2026
…view access (backport #14823)

(cherry picked from commit ff45743)
ChiragAgg5k added a commit that referenced this pull request Oct 24, 2026
…view access (backport #14823)

(cherry picked from commit ff45743)
ChiragAgg5k added a commit that referenced this pull request Oct 24, 2026
…view access (backport #14823)

(cherry picked from commit ff45743)
ChiragAgg5k added a commit that referenced this pull request Oct 24, 2026
…view access (backport #14823)

(cherry picked from commit ff45743)
Tapraj-Pathak pushed a commit to Tapraj-Pathak/appwrite that referenced this pull request Oct 24, 2026
fix(sites): keep console auth cookies out of runtimes and tighten preview access

(cherry picked from commit ff45743)
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.

1 participant