Download the PHP package asignua/filament-captcha without Composer

On this page you can find all versions of the php package asignua/filament-captcha. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package filament-captcha

Filament Captcha

Filament Captcha

Tests

A captcha field for Filament 5 forms and plain Livewire components. One field, one validation rule, five providers: Google reCAPTCHA v2 (checkbox and invisible), reCAPTCHA v3 (score and action), Cloudflare Turnstile and hCaptcha. It re-initialises after Livewire morphs, resets the single-use token after every failed submit, fetches v3 tokens right before the form goes out, and has a fake mode so your test suite never touches the network.

Screenshots

The login page with the Turnstile widget (the same field works on registration and password reset):

Login page with a Cloudflare Turnstile widget

A missing or failed check is reported under the widget and the single-use token is reset:

Error message under the captcha widget

The widget after the check passed

Captcha::make() in an ordinary Filament form:

A Filament form with the Captcha field

Dark mode:

Login page in dark mode

Requirements

Installation

Put the keys of the provider you use in .env (see Configuration):

Register the plugin on the panel only if you want the captcha on Filament's auth pages, or want the client script printed on every panel page automatically (the default):

Call ->plugin() after ->login() / ->registration() / ->passwordReset(): the plugin swaps in page classes that add the field, and a later call on the panel would swap them back.

No filament:assets step: the small client script is served by the package itself (/filament-captcha/captcha.js, versioned and cacheable for a year).

Usage

In a Filament form

The field is validated, never saved: it is not dehydrated, so the single-use token does not end up in $form->getState(). It is named captchaAction() and not action() because Filament's own Component::action() is taken.

In a plain Livewire component

Once in your layout (Filament panels get it from the plugin):

The widget also takes driver, theme, size and locale. Outside Livewire (no wire:model) it renders a hidden input named captcha_token (name="..." to change it).

As a validation rule

The rule is implicit: an empty or missing token fails with "Please complete the security check", it does not skip the rule. Within one request the same token is verified once, so repeated validation does not burn it.

Auth pages

CaptchaPlugin::make()->login()->registration()->passwordReset() adds the field to Filament's pages. Pass a driver per page (->login(driver: 'recaptcha_v3'); the action is login, register or password_reset). With your own page classes use the trait instead:

The trait works without registering the plugin (the driver then comes from config/filament-captcha.php), but the page still needs the client script: add <x-filament-captcha::scripts /> through a panel render hook (for example PanelsRenderHook::HEAD_END).

Multi-factor login: Filament runs authenticate() twice (password, then the challenge). The captcha is checked on the first step only; on the challenge step the field is hidden, because the token was spent. This works for the plugin's pages and for the trait alike.

Tests

Or set CAPTCHA_FAKE=true in .env.testing (honoured only in local / testing; elsewhere it is ignored with a log warning). Without a call to fake(), use Http::fake() for the provider's siteverify URL: the package resolves the HTTP client on every verification, so it honours your fake.

Configuration

config/filament-captcha.php, all of it also reachable through .env:

Key Default
driver (CAPTCHA_DRIVER) turnstile recaptcha_v2, recaptcha_v2_invisible, recaptcha_v3, turnstile, hcaptcha
enabled (CAPTCHA_ENABLED) null false turns the captcha off everywhere
fake (CAPTCHA_FAKE) false no widget, no network, validation passes
missing_keys (CAPTCHA_MISSING_KEYS) auto keys missing: auto = off with a log warning in local/testing, fails elsewhere; disable; fail
timeout (CAPTCHA_TIMEOUT) 5 seconds to wait for the provider
fail_open (CAPTCHA_FAIL_OPEN) false let visitors through when the provider is unreachable (a rejected token is never let through)
hostnames null null = no check, true = the request host, or an allow-list
theme auto auto follows the dark class on <html>
token_refresh 100 seconds between v3 token refreshes
script_path filament-captcha/captcha.js null to serve resources/js/captcha.js yourself
drivers.* site_key, secret_key per driver; reCAPTCHA domain (www.recaptcha.net), v3 score_threshold and default action, hCaptcha size (invisible)

reCAPTCHA v2 checkbox and v2 invisible need separate key pairs (Google issues a different key type for each).

Custom provider

Implement Asignua\FilamentCaptcha\Contracts\CaptchaDriver (or extend Drivers\SiteVerifyDriver: set the endpoint and clientConfig(); the client script knows the recaptcha, turnstile and hcaptcha kinds).

Content-Security-Policy

The widget needs the provider's origins. Captcha::cspSources(['turnstile']) returns them by directive (script-src, frame-src, connect-src, and style-src for hCaptcha). Add them to your policy. With asignua/filament-csp-nonce the directives() you pass are merged over the preset directive by directive, so include the sources the preset already has:

The package prints <script src nonce="..."> with Vite::cspNonce() and the client script gives the same nonce to the provider's script tag it injects. With 'strict-dynamic' that is enough; without it, allow the provider origins in script-src.

Gotchas

Translations

The interface ships in English, Ukrainian, German, Spanish, French, Italian, Dutch, Polish, Brazilian Portuguese and Turkish under the filament-captcha::filament-captcha namespace. A test keeps every language in step with the English keys. Override a string by publishing the translations (--tag=filament-captcha-translations) and editing the copy in lang/vendor/filament-captcha.

AI agents

The package ships Laravel Boost guidelines (resources/boost/guidelines/core.blade.php) so a coding agent wires it up correctly.

Testing

Changelog

See CHANGELOG.md.

License

The MIT License (MIT). See LICENSE.md.


All versions of filament-captcha with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
filament/filament Version ^5.0
illuminate/contracts Version ^12.0|^13.0
spatie/laravel-package-tools Version ^1.16
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package asignua/filament-captcha contains the following files

Loading the files please wait ...