Skip to content

feat(auth): send X-CSRF-Token on state-changing /auth/* (nginx+auth step 10.5) - #210

Closed
cyberantonz wants to merge 1 commit into
constructorfabric:mainfrom
cyberantonz:feat/auth-csrf-header
Closed

feat(auth): send X-CSRF-Token on state-changing /auth/* (nginx+auth step 10.5)#210
cyberantonz wants to merge 1 commit into
constructorfabric:mainfrom
cyberantonz:feat/auth-csrf-header

Conversation

@cyberantonz

Copy link
Copy Markdown
Contributor

SPA side of nginx+auth step 10.5 (CSRF). Pairs with backend PR constructorfabric/insight#1848, which now enforces CSRF fail-closed on state-changing /auth/*.

  • Session gains csrfToken, populated from GET /auth/me (csrf_token).
  • signOut sends X-CSRF-Token on POST /auth/logout.

Any future SPA-initiated state-changing /auth/* call (e.g. an explicit refresh) must send the same header.

⚠️ Merge coordination: land this (or set the backend's csrfOrigins to the SPA origin) before/with the backend chart roll, or logout 403s during the transition.

Unit tests updated (src/auth/*). Pre-existing unrelated test-collection + eslint-plugin failures on main are untouched.

EPIC: constructorfabric/insight#1583 · #1593

🤖 Generated with Claude Code

…583 step 10.5)

The authenticator now enforces CSRF on state-changing /auth/* methods
(double-submit header, constant-time, with an Origin-allowlist fallback;
fail closed). /auth/me echoes the per-session csrf_token; the store keeps it
and signOut sends it as X-CSRF-Token on POST /auth/logout. Future /auth/refresh
calls must do the same.

Signed-off-by: Anton Zelenov <antonz@constructor.tech>
@cyberantonz
cyberantonz requested a review from a team as a code owner July 22, 2026 09:33
@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@cyberantonz, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 10 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a0afc7b6-51f2-4dfd-98e4-1ad96f5c00fb

📥 Commits

Reviewing files that changed from the base of the PR and between 79b3ed7 and 56082a5.

📒 Files selected for processing (5)
  • src/auth/session.test.ts
  • src/auth/session.ts
  • src/auth/types.ts
  • src/auth/use-auth.test.ts
  • src/auth/use-auth.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cyberantonz
cyberantonz deleted the feat/auth-csrf-header branch July 22, 2026 09:53
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