Skip to content

Add Cloudflare Turnstile verification middleware#7

Closed
HTMHell wants to merge 6 commits into
mainfrom
turnstile-middleware
Closed

Add Cloudflare Turnstile verification middleware#7
HTMHell wants to merge 6 commits into
mainfrom
turnstile-middleware

Conversation

@HTMHell
Copy link
Copy Markdown
Contributor

@HTMHell HTMHell commented Mar 15, 2026

Summary

  • Add FastAPI HTTP middleware that verifies Cloudflare Turnstile tokens on all endpoints except /health
  • Reads cf-turnstile-response header, validates against Cloudflare siteverify API using TURNSTILE_SECRET_KEY env var
  • Returns 403 for missing or invalid tokens

Test plan

  • Set TURNSTILE_SECRET_KEY env var and verify requests without token return 403
  • Verify requests with valid Turnstile token return 200
  • Verify /health endpoint remains accessible without token

🤖 Generated with Claude Code

HTMHell and others added 5 commits March 15, 2026 11:13
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@HTMHell HTMHell requested a review from AmitMY March 15, 2026 09:39
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@HTMHell
Copy link
Copy Markdown
Contributor Author

HTMHell commented Mar 15, 2026

Switching to GCP Cloud Armor + reCAPTCHA Enterprise approach instead of app-level Turnstile middleware

@HTMHell HTMHell closed this Mar 15, 2026
@HTMHell HTMHell deleted the turnstile-middleware branch March 15, 2026 10:19
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