A spam protector and form field using CloudFlare's Turnstile


Repository: https://github.com/webbuilders-group/silverstripe-turnstile

Packagist: http://packagist.org/packages/webbuilders-group/silverstripe-turnstile

Issues: https://github.com/webbuilders-group/silverstripe-turnstile/issues

Authors: Ed Chipman

4 3 6.5K


Readme

Turnstile for Silverstripe

Adds a "spam protection" field to Silverstripe userforms using Cloudflare's Turnstile service.

Maintainer Contact

Requirements

Installation

composer require webbuilders-group/silverstripe-turnstile

Configuration

There are multiple configuration options for the field, you must set the site_key and the secret_key which you can get from Cloudflare. These configuration options must be added to your site's yaml config typically this is app/_config/config.yml.

SilverStripe\SpamProtection\Extension\FormSpamProtectionExtension:
  default_spam_protector: WebbuildersGroup\Turnstile\Forms\TurnstileProtector  #Set the default spam protector

WebbuildersGroup\Turnstile\Forms\TurnstileField:
  site_key: '`TURNSTILE_SITE_KEY`' #Your site key (required)
  secret_key: '`TURNSTILE_SECRET_KEY`' #Your secret key (required)
  verify_ssl: true #Allows you to disable php-curl's SSL peer verification by setting this to false (optional, defaults to true)
  default_theme: "light" #Default theme color (optional, light, dark or auto, defaults to light)
  js_onload_callback: null #Onload callback to be called when the JS for Turnstile is loaded
  proxy_server: "`SS_OUTBOUND_PROXY_SERVER`" #Your proxy server address (optional)
  proxy_port: "`SS_OUTBOUND_PROXY_PORT`" #Your proxy server address port (optional)
  proxy_auth: "`SS_OUTBOUND_PROXY_AUTH`" #Your proxy server authentication information (optional)

Adding field labels

If you want to add a field label or help text to the Captcha field you can do so like this:

$form->enableSpamProtection()
    ->Fields()
      ->fieldByName('Captcha')
          ->setTitle('Spam protection')
          ->setDescription('Your description here');

Adding Custom Attributes

Turnstile has a few other options that this module does not out of the box provide hooks for setting, however you can set them your self using setAttribute for example:

$form->enableSpamProtection()
    ->Fields()
      ->fieldByName('Captcha')
          ->setAttribute('data-action', 'action')
          ->setAttribute('data-cdata', 'payload')
          ->setAttribute('data-callback', 'yourChallengeJSCallback')
          ->setAttribute('data-expired-callback', 'yourExpiredJSCallback')
          ->setAttribute('data-error-callback', 'youErrorJSCallback')
          ->setAttribute('data-tabindex', 0);

Testing scenarios

Several dummy site and secret keys are available to help you test different scenarios. Choosing a visible challenge will let you style the widget during development.


Versions

dev-master
2026-30-8 2461200: UTC
BSD-3-Clause

Install composer require webbuilders-group/silverstripe-turnstile dev-master

Manual Install: Download

Requires
  • silverstripe/framework: ^6
  • silverstripe/spamprotection: ~5.0
  • ext-curl: *
1.x-dev
2024-33-10 2460441: UTC
BSD-3-Clause

Install composer require webbuilders-group/silverstripe-turnstile 1.x-dev

Manual Install: Download

Requires
  • silverstripe/framework: >=4.0,<6.0
  • silverstripe/spamprotection: >=3.0,<5.0
2.1.2
2026-37-5 2461197: UTC
BSD-3-Clause

Install composer require webbuilders-group/silverstripe-turnstile 2.1.2

Manual Install: Download

Requires
  • silverstripe/framework: ^6
  • silverstripe/spamprotection: ~5.0
  • ext-curl: *
2.1.1
2026-53-29 2461190: UTC
BSD-3-Clause

Install composer require webbuilders-group/silverstripe-turnstile 2.1.1

Manual Install: Download

Requires
  • silverstripe/framework: ^6
  • silverstripe/spamprotection: ~5.0
  • ext-curl: *
2.1.0
2025-50-21 2460970: UTC
BSD-3-Clause

Install composer require webbuilders-group/silverstripe-turnstile 2.1.0

Manual Install: Download

Requires
  • silverstripe/framework: ^6
  • silverstripe/spamprotection: ~5.0
  • ext-curl: *
2.0.0
2025-24-26 2460853: UTC
BSD-3-Clause

Install composer require webbuilders-group/silverstripe-turnstile 2.0.0

Manual Install: Download

Requires
  • silverstripe/framework: ^6
  • silverstripe/spamprotection: ~5.0
1.1.1
2024-33-10 2460441: UTC
BSD-3-Clause

Install composer require webbuilders-group/silverstripe-turnstile 1.1.1

Manual Install: Download

Requires
  • silverstripe/framework: >=4.0,<6.0
  • silverstripe/spamprotection: >=3.0,<5.0
1.1.0
2023-15-8 2460073: UTC
BSD-3-Clause

Install composer require webbuilders-group/silverstripe-turnstile 1.1.0

Manual Install: Download

Requires
  • silverstripe/framework: >=4.0,<6.0
  • silverstripe/spamprotection: >=3.0,<5.0
1.0.0
2022-39-15 2459929: UTC
BSD-3-Clause

Install composer require webbuilders-group/silverstripe-turnstile 1.0.0

Manual Install: Download

Requires
  • silverstripe/framework: ~4.0
  • silverstripe/spamprotection: ~3.0