Skip to content

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

Merged
rolandgeider merged 7 commits into
wger-project:masterfrom
kwitykwity:feature/1461-turnstile-clean
Nov 8, 2026
Merged

rolandgeider merged 7 commits into
wger-project:masterfrom
kwitykwity:feature/1461-turnstile-clean

Conversation

@kwitykwity

Copy link
Copy Markdown
Contributor

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

kwitykwity and others added 7 commits September 1, 2026 20:48
…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>
The package had a single release and looked unmaintained.
@rolandgeider
rolandgeider merged commit b2232fd into wger-project:master Nov 8, 2026
8 checks passed
@rolandgeider

Copy link
Copy Markdown
Member

Finally merged, thanks!

(in the end I replaced the package with a small POST, it had one release and didn't seem to be maintained)

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

2 participants