Skip to content

Add Cloudflare Turnstile on session minting - #464

Merged
xenodus merged 4 commits into
masterfrom
cursor/turnstile-session-mint-210a
Sep 10, 2026
Merged

xenodus merged 4 commits into
masterfrom
cursor/turnstile-session-mint-210a

Conversation

@xenodus

@xenodus xenodus commented Sep 10, 2026

Copy link
Copy Markdown
Owner

Summary

Adds optional Cloudflare Turnstile verification on session minting to raise the cost of scripted /session/search abuse.

  • Backend: When TURNSTILE_SECRET_KEY is set, GET /session requires X-Turnstile-Token; tokens are verified server-side via Cloudflare siteverify, then the response hostname must match gishathfetch.com (or localhost when ENV is not prod). api.gishathfetch.com is not accepted — the widget runs on the SPA origin only.
  • Frontend: When VITE_TURNSTILE_SITE_KEY is set, invisible Turnstile runs on every session mint and 10-minute background refresh.
  • Deploy: deploy-on-merge.yml passes VITE_TURNSTILE_SITE_KEY from GitHub secrets into the frontend build.
  • UX: Initial session bootstrap failures surface in searchError.

Deployment checklist

Variable Where
TURNSTILE_SECRET_KEY Lambda mtg-price-scrapper
VITE_TURNSTILE_SITE_KEY GitHub repository secret

Cloudflare widget hostnames must include gishathfetch.com (not api.gishathfetch.com).

Testing

  • make test

Privacy policy: updated — Turnstile disclosed in Modals.jsx.

Open in Web Open in Cursor 

cursoragent and others added 4 commits September 10, 2026 14:08
Require POST /session with a verified Turnstile token when
TURNSTILE_SECRET_KEY is set. The SPA runs invisible Turnstile on
every session mint and 10-minute background refresh when
VITE_TURNSTILE_SITE_KEY is configured.

Includes privacy policy disclosure, env examples, and abuse-mitigation
docs. GET /session remains available when Turnstile is disabled (local dev).

Co-authored-by: xenodus <xenodus@gmail.com>
Avoids API Gateway POST route changes. Token travels in a custom header
instead of the URL or request body. Includes TODO notes to migrate to
POST once API Gateway exposes POST on /session.

Co-authored-by: xenodus <xenodus@gmail.com>
…rors

- Pass VITE_TURNSTILE_SITE_KEY from GitHub secrets into make deploy
- Fix stale Turnstile JSDoc (GET + header, not POST)
- Surface session bootstrap failures via searchError instead of failing silently

Co-authored-by: xenodus <xenodus@gmail.com>
Reject tokens whose hostname is not gishathfetch.com (or localhost in
non-prod). api.gishathfetch.com is intentionally excluded because the
widget runs on the SPA, not the API host.

Co-authored-by: xenodus <xenodus@gmail.com>
@xenodus
xenodus marked this pull request as ready for review September 10, 2026 17:02
@xenodus
xenodus merged commit b56e57b into master Sep 10, 2026
4 checks passed
@xenodus
xenodus deleted the cursor/turnstile-session-mint-210a branch September 10, 2026 17:03
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.

2 participants