Skip to content

feat: add Cloudflare Turnstile as alternative captcha provider - #2499

Open
kwitykwity wants to merge 1 commit into
wger-project:masterfrom
kwitykwity:feature/1461-turnstile-clean
Open

feat: add Cloudflare Turnstile as alternative captcha provider#2499
kwitykwity wants to merge 1 commit into
wger-project:masterfrom
kwitykwity:feature/1461-turnstile-clean

Conversation

@kwitykwity

Copy link
Copy Markdown

Summary

Add support for Cloudflare Turnstile as a privacy-friendly alternative to Google reCAPTCHA for the signup form.

  • New setting: CAPTCHA_PROVIDER with options: 'recaptcha', 'turnstile', or 'none'
  • Backwards compatible: Existing USE_RECAPTCHA=True configurations continue to work
  • Django checks: Added validation warnings when captcha keys are missing

Changes

  • Add django-cf-turnstile dependency
  • Add CAPTCHA_PROVIDER setting to replace boolean USE_RECAPTCHA
  • Add CF_TURNSTILE_SITE_KEY and CF_TURNSTILE_SECRET_KEY settings
  • Update signup form to conditionally use either provider
  • Add Django system checks for configuration validation
  • Add tests for all three captcha modes

Configuration

# Option 1: Cloudflare Turnstile (new)
CAPTCHA_PROVIDER=turnstile
CF_TURNSTILE_SITE_KEY=your_key
CF_TURNSTILE_SECRET_KEY=your_secret

# Option 2: reCAPTCHA (existing)
CAPTCHA_PROVIDER=recaptcha
RECAPTCHA_PUBLIC_KEY=your_key
RECAPTCHA_PRIVATE_KEY=your_secret

# Option 3: No captcha
CAPTCHA_PROVIDER=none

Related Issue(s)

Fixes #1461

Please check that the PR fulfills these requirements

  • Tests for the changes have been added (for bug fixes / features)
  • Code has been formatted to avoid unnecessary diffs (ruff format && isort .)
  • If the feature is big enough or if there are manual steps needed (deployment changes etc.), write a small writeup in CHANGELOG.md

Testing

DJANGO_SETTINGS_MODULE=settings.ci python manage.py test wger.core.tests.test_registration

All 12 tests pass.

🤖 Generated with Claude Code

…project#1461)

Add support for Cloudflare Turnstile as a privacy-friendly alternative
to Google reCAPTCHA for the signup form.

Changes:
- Add django-cf-turnstile dependency
- Replace USE_RECAPTCHA boolean with CAPTCHA_PROVIDER setting
  ('recaptcha', 'turnstile', or 'none')
- Add CF_TURNSTILE_SITE_KEY and CF_TURNSTILE_SECRET_KEY settings
- Update signup form to conditionally use either provider
- Add Django checks to validate captcha configuration
- Maintain backwards compatibility with USE_RECAPTCHA=True
- Update CHANGELOG.md

Fixes wger-project#1461

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.

Feature request: Change ReCaptcha to another service

1 participant