fix(auth): allow tokscale.ai CSRF origin - #652
Merged
IvGolovach merged 1 commit intoJun 4, 2026
Merged
Conversation
Validation * Validation tier: Tier 3 — High-risk runtime/security change, because the default CSRF allowlist affects cookie-authenticated mutating requests. * TDD red: `bun run test __tests__/lib/requestSessionCsrf.test.ts`: FAIL before implementation, 1 failed and 12 passed; the new `tokscale.ai` production-origin case returned null. * `bun run test __tests__/lib/requestSessionCsrf.test.ts`: PASS, 13 tests. * `bun run test __tests__/api/groupRoute.test.ts`: PASS, 5 tests. * `git diff --check`: PASS. * `git diff --cached --check`: PASS. * Ledger: not applicable — not required for selected validation tier/change family. * Version: not applicable — no release/version manifests changed and the documented version coherence check applies to CLI release manifests. * Not run: full frontend suite, lint, build — not required for the focused local proof requested for this scoped allowlist fix. Rollback * git revert HEAD
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
https://tokscale.aito the default CSRF trusted-origin set for cookie-authenticated browser mutations.Why
Production browser requests from
https://tokscale.aican carry a validtt_sessioncookie but still be rejected by the CSRF origin gate if the app does not have an explicit environment override. Group creation is one of the affected mutating routes, so users can be signed in yet receive an authorization failure in production. The fix makes the canonical production origin part of the safe default instead of requiring every deployment to rediscover the same allowlist setting.Diff scope
packages/frontend/src/lib/auth/requestSession.ts: includeshttps://tokscale.aiin the built-in trusted origins used bygetSessionFromRequestfor cookie-authenticated mutation requests.packages/frontend/__tests__/lib/requestSessionCsrf.test.ts: adds a production-origin regression case forPOST https://tokscale.ai/api/groupswith a validtt_sessioncookie.Branch integrity
main.a86e688d620939d2c973c6d5625baa815ea223d7.0 behind / 1 aheadagainstorigin/main.a86e688d620939d2c973c6d5625baa815ea223d7.origin/mainis an ancestor of this branch.Commit integrity
5a2eba5d2d8f3568fe7c45ae7e87e74c7a4c604e fix(auth): allow tokscale.ai CSRF origin.Diff hygiene
git diff --name-status origin/main...HEAD: onlypackages/frontend/src/lib/auth/requestSession.tsandpackages/frontend/__tests__/lib/requestSessionCsrf.test.tschanged.git diff --check origin/main...HEAD: PASS, no output.Validation mode and proof
Mode 3 - security-sensitive runtime change, because the CSRF origin allowlist affects cookie-authenticated mutating requests. Local validation was targeted to the CSRF request-session helper and the group creation route that exercises this auth path.
bun run test __tests__/lib/requestSessionCsrf.test.tsfailed before the implementation because the newtokscale.aiproduction-origin case returnednull.bun run test __tests__/lib/requestSessionCsrf.test.ts __tests__/api/groupRoute.test.ts: PASS, 2 files and 18 tests.git diff --check origin/main...HEAD: PASS, no output.Required remote gates
Pending - GitHub Actions, Vercel, and mergeability checks will run after the PR is opened.
Migration notes
Not applicable - no database migration changed.
Runtime safety
The change is additive to the trusted-origin defaults and does not weaken same-origin/session requirements. It allows the canonical production site origin while preserving existing localhost and environment-configured origins. No token handling, session storage, role checks, or route mutation semantics changed. No invariant regression introduced.
Documentation integrity
Not applicable - no docs, commands, or runbooks changed.
Rollback plan
Rollback: revert this PR. DB downgrade: not applicable. Data repair: not applicable. Operational caveats: reverting would reintroduce the production-origin CSRF rejection unless the deployment provides an equivalent environment allowlist.
Known residual risks
Remote CI and GitHub mergeability are pending until the PR is opened. If the production domain changes in the future, that new canonical origin will still need to be configured or added separately.
Summary by cubic
Allow
https://tokscale.aias a trusted CSRF origin for cookie-authenticated browser mutations so signed-in users aren’t blocked in production (e.g., group creation). Localhost and env-configured origins remain unchanged.https://tokscale.aito the default CSRF trusted origins used bygetSessionFromRequest.POST https://tokscale.ai/api/groupsto confirm cookie sessions are accepted when bearer auth is disabled.Written for commit 5a2eba5. Summary will update on new commits.