Download the PHP package l3aro/filament-turnstile without Composer
On this page you can find all versions of the php package l3aro/filament-turnstile. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download l3aro/filament-turnstile
More information about l3aro/filament-turnstile
Files in l3aro/filament-turnstile
Package filament-turnstile
Short Description Filament Turnstile is an essential plugin designed to seamlessly integrate Cloudflare Turnstile into your Filament application.
License MIT
Homepage https://github.com/l3aro/filament-turnstile
Informations about the package filament-turnstile
Filament Turnstile
Filament Turnstile is a lightweight plugin that seamlessly integrates Cloudflare Turnstile with your Filament application.
Installation
Install the package via Composer:
Publish the configuration file with:
Optionally publish the views with:
The published configuration file contains:
Customizing the Reset Event
You can customize the name of the reset event globally by modifying the TURNSTILE_RESET_EVENT in your .env file:
Or by directly modifying the reset_event value in the configuration file. This allows you to use a custom event name that better fits your application's event naming convention or to avoid conflicts with other JavaScript events.
Turnstile Keys
To use Cloudflare Turnstile, obtain your SiteKey and SecretKey from the Cloudflare dashboard.
Refer to the documentation for step-by-step instructions.
After you generate the keys, add them to your .env file in the following format:
For testing, you may use the dummy site and secret keys provided by Cloudflare.
Usage
Using the plugin is straightforward. In your form, add the following component:
See the supported languages list for available locale codes.
The Turnstile field exposes additional options. Review the Cloudflare configuration guide for full details.
Turnstile Events
The package provides events you can use to control the captcha in different scenarios.
Reset event
The reset event (default: reset-captcha) resets the captcha challenge. It is helpful when you need to:
- Clear the challenge after a successful submission so the next visitor receives a fresh captcha.
- Reset the challenge after validation errors to avoid reusing a solved captcha when the form fails.
Dispatching the reset event
There are two primary ways to dispatch reset-captcha:
-
Via
onValidationError: Filament automatically callsonValidationErrorwhen validation fails. Dispatch the event there to refresh the captcha. - Manually: Dispatch the event whenever your logic requires a reset.
Resetting the login captcha
To automatically reset the captcha after a failed login attempt, use the throwFailureValidationException method in your login form's Livewire component:
Throwing a validation exception triggers onValidationError, which dispatches reset-captcha and refreshes the captcha for the next attempt.
Real-life example
To implement the Turnstile captcha on the Login page in Filament, follow these steps:
Create a new App/Filament/Pages/Auth/Login.php class:
Then override the login() method in your PanelProvider (for example, AdminPanelProvider):
Testing
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
- l3aro
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of filament-turnstile with dependencies
filament/filament Version ^4.0|^5.0
spatie/laravel-package-tools Version ^1.92
illuminate/contracts Version ^11.0|^12.0|^13.0