Skip to content

morca ui: Cloudflare Turnstile before data reads - #547

Merged
winding-lines merged 1 commit into
mainfrom
ui-turnstile
Nov 19, 2026
Merged

winding-lines merged 1 commit into
mainfrom
ui-turnstile

Conversation

@winding-lines

Copy link
Copy Markdown
Contributor

Crawlers that rotate addresses get past the per-client limits (#545). With MORCA_UI_TURNSTILE_SITEKEY and MORCA_UI_TURNSTILE_SECRET (a secret id, read with fetch_secret) set, a visitor without a session passes Turnstile once a day before a data read:

  • A Data tab without a valid morca_human cookie is a 403 page with the widget (action data); data.csv, data.json and JSON get a 403 in text.
  • POST /turnstile (same-origin) calls siteverify (10 s, fails closed) and needs success, action data and a hostname in MORCA_UI_TURNSTILE_HOSTNAMES; then sets morca_human (expiry + HMAC-SHA256 under a key made at startup; HttpOnly, SameSite=Lax, Secure, a day) and 303s to a sanitised next.
  • Sessions, API tokens and the worker API are exempt, as for the limits. Off unless both are set.
  • Deploy tools 0.37.0: TURNSTILE_SITEKEY, secrets/orca/turnstile-secret in SECRETS_FILE (or TURNSTILE_SECRET_FILE), TURNSTILE_HOSTNAMES (UI_URL's host by default).

Tests: test-turnstile (cookie good/expired/tampered, next sanitising); test-ui-drain with a siteverify stand-in (403 page, failing token, pass sets the cookie, read goes on, forged cookie refused); test-hetzner.

🤖 Generated with Claude Code

https://claude.ai/code/session_017TycszSbyw92Efu4ZeCYL6

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017TycszSbyw92Efu4ZeCYL6
@winding-lines
winding-lines merged commit 1ff6e39 into main Nov 19, 2026
35 checks passed
@winding-lines
winding-lines deleted the ui-turnstile branch November 19, 2026 14:27
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