Skip to content

feat: integrate Cloudflare Turnstile for Captcha validation#44

Merged
GTPSHAX merged 10 commits into
NgodingCik:mainfrom
GTPSHAX:dev
May 16, 2026
Merged

feat: integrate Cloudflare Turnstile for Captcha validation#44
GTPSHAX merged 10 commits into
NgodingCik:mainfrom
GTPSHAX:dev

Conversation

@GTPSHAX
Copy link
Copy Markdown
Contributor

@GTPSHAX GTPSHAX commented May 16, 2026

Overview

This pull request introduces Cloudflare Turnstile as an additional CAPTCHA provider, offering a user-friendly alternative to hCaptcha. The integration includes necessary environment variable schemas, frontend exposure of site keys, and critical security header updates to allow Cloudflare's assets to load correctly.

Key Changes

Security & Headers

Updated the helmet.js middleware configuration in both the API and Web apps. To prevent Content Security Policy (CSP) violations, the following directives now include https://challenges.cloudflare.com:

  • frame-src
  • script-src
  • connect-src

Configuration & Environment

  • Environment Variables: Added CLOUDFLARE_TURNSTILE_SITE_KEY and CLOUDFLARE_TURNSTILE_SECRET_KEY to all .env examples and validation schemas.
  • Frontend Access: The CLOUDFLARE_TURNSTILE_SITE_KEY is now passed to the frontend through the META object in the home route, enabling the client-side widget to initialize.

API & Docs

  • Contextual Validation: The handleGenerateDocx function now receives the full request object, allowing for more robust validation (e.g., checking CAPTCHA tokens directly within the handler).
  • Documentation Sync: Updated auto-generated documentation for openai-wrapper and vm-runner to align with recent source code shifts.

How to Test

  1. Environment Setup: Add your Cloudflare Turnstile keys to your local .env file.
  2. Verification:
  • Ensure the Turnstile widget renders on the frontend without CSP errors in the console.
  • Validate that a successful challenge allows the generate-docx request to proceed.
  1. Fallback: Ensure hCaptcha functionality remains unaffected if selected as the provider.

Screenshots/Video

(N/A - Backend and configuration logic)

@GTPSHAX GTPSHAX self-assigned this May 16, 2026
@GTPSHAX GTPSHAX added the enhancement New feature or request label May 16, 2026
@GTPSHAX GTPSHAX merged commit d0ceb2b into NgodingCik:main May 16, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant