versaorigin/cloudflare-turnstile

A Cloudflare Turnstile Validator for Laravel

v1.0.3 2024-04-28 18:51 UTC

This package is auto-updated.

Last update: 2024-04-28 18:52:36 UTC


README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This package provides a validator for Laravel to validate Cloudflare Turnstile responses. It is useful when you want to validate a reCAPTCHA response from a form.

Requirements

  • PHP 8.3 or higher
  • Laravel 11.0 or higher
  • Cloudflare Turnstile API key and secret

Installation

You can install the package via composer:

composer require versaorigin/cloudflare-turnstile

You can publish the config file with:

php artisan vendor:publish --tag="cloudflare-turnstile-config"

or, you can publish the config file with:

php artisan cloudflare-turnstile:install

This is the contents of the published config file:

return [

    'enabled' => env('CLOUDFLARE_TURNSTILE_ENABLED', true),

    'key' => env('CLOUDFLARE_TURNSTILE_KEY', 'your-cloudflare-turnstile-key'),

    'secret' => env('CLOUDFLARE_TURNSTILE_SECRET', 'your-cloudflare-turnstile-secret'),

];

Usage

$request->validate([
    'cf-turnstile-response' => 'required|cloudflare_turnstile',
]);

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.