Filament Turnstile
Filament Turnstile, is a plugin to help you implement the Cloudflare turnstile.
This plugin uses Laravel Turnstile Behind the scene, you can head to the page README to learn more.
Installation
You can install the package via composer:
composer require coderflex/filament-turnstile
Turnstile Keys
To be able to use Cloudflare Turnstile, you need to get the SiteKey
, and the SecretKey
from your Cloudflare dashboard
After Generating the keys, use TURNSTILE_SITE_KEY
, and TURNSTILE_SECRET_KEY
in your .env
file
TURNSTILE_SITE_KEY=2x00000000000000000000AB
TURNSTILE_SECRET_KEY=2x0000000000000000000000000000000AA
If you want to test the widget, you can use the Dummy site keys and secret keys that Cloudflare provides.
Usage
The usage of this plugin, is really straight - forward. In your form, use the following code:
...
use Coderflex\FilamentTurnstile\Forms\Components\Turnstile;
...
Turnstile::make('captcha')
->theme('auto')
->language('fr')
->size('normal'),
The Turnstile
field, has few options to use. You can learn more about them in the Cloudflare configuration section
Real Life Example:
In order to use Turnstile captcha with the Login
page in filament, use the following steps:
Create a new App/Filament/Pages/Login.php
class
<?php
namespace App\Filament\Pages;
use Coderflex\FilamentTurnstile\Forms\Components\Turnstile;
class Login extends \Filament\Http\Livewire\Auth\Login
{
protected function getFormSchema(): array
{
return array_merge(
parent::getFormSchema(),
[
Turnstile::make('cf-captcha')
->theme('auto')
->language('en-US')
->size('normal'),
]
);
}
}
Then override the Login
class in the filament.php
config file.
return [
....
'auth' => [
'guard' => env('FILAMENT_AUTH_GUARD', 'web'),
'pages' => [
'login' => \App\Filament\Pages\Login::class,
],
],
...
]
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 the License File for more information.