Expand description
Driver-based captcha for Laravel Rust: one API for Cloudflare Turnstile and Google reCAPTCHA v2/v3. Switch providers by changing one environment variable, no code changes.
// In a template: the widget, drawn for the configured driver.
{{ laracaptcha_widget(action='register') }}
// On the form's input type: the rule.
#[serde(rename = "cf-turnstile-response")]
#[validate(required, Captcha::new())]
captcha: String,It is the port of the PHP package edulazaro/laracaptcha
to Laravel Rust 0.1 (beta), and its API follows the framework’s changes until 1.0.
The facade of the PHP package is this module’s free functions: driver(), verify(), fake(),
props(), site_key(), script_url(), response_field() and extend().
Re-exports§
pub use config::DriverConfig;pub use config::Drivers;pub use config::LaracaptchaConfig;pub use config::Messages;pub use config::RecaptchaV3Config;pub use contracts::CaptchaDriver;pub use drivers::RecaptchaV2Driver;pub use drivers::RecaptchaV3Driver;pub use drivers::TurnstileDriver;pub use manager::CaptchaManager;pub use manager::Props;pub use provider::LaracaptchaServiceProvider;pub use result::VerificationResult;pub use rule::Captcha;pub use testing::Attempt;pub use testing::FakeDriver;pub use widget::Widget;
Modules§
- config
- contracts
- drivers
- The drivers that ship with the package.
- manager
- provider
- provider_
client - result
- rule
- support
- testing
- views
- The MiniJinja function
laracaptcha_widget(), the equivalent of the<x-laracaptcha::widget />Blade component. - widget
Functions§
- driver
- The named driver, or the default one when
None:Captcha::driver('recaptcha_v3'). - extend
- Register a driver of your own while the application runs:
Captcha::extend('name', fn). - fake
- Replace every driver with a fake for testing:
Captcha::fake($success, $score). Assert on the returnedFakeDriver. - manager
- The captcha manager of the running application.
- props
- What the React, Vue and Svelte components need:
Captcha::props($driver, $action). - response_
field - The name of the field carrying the token, for the default driver.
- script_
url - The script url of the default driver.
- site_
key - The public site key of the default driver.
- verify
- Verify a token with the default driver:
Captcha::verify($token, $request->ip()).