advancedideasmechanics / mezzio-recaptcha-v3-middleware
Google reCAPTCHA v3 PSR-15 Middleware and Service for Mezzio and Laminas applications
Package info
github.com/AdvancedIdeasMechanics/mezzio-recaptcha-v3-middleware
pkg:composer/advancedideasmechanics/mezzio-recaptcha-v3-middleware
Requires
- php: ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0
- psr/container: ^1.0 || ^2.0
- psr/http-client: ^1.0
- psr/http-factory: ^1.0
- psr/http-message: ^1.0 || ^2.0
- psr/http-server-middleware: ^1.0
Suggests
- mezzio/mezzio-template: Required if you want to use ReCaptchaTemplateMiddleware to automatically inject recaptcha_site_key into view templates.
README
Mezzio Middleware for Google ReCaptcha V3
Composer
composer require advancedideasmechanics/mezzio-recaptcha-v3-middleware
Use
For route.php Middleware use.
use AdvancedIdeasMechanics\MezzioReCaptchaV3\Middleware\ReCaptchaMiddleware::class;
$app->get('/', [ReCaptchaMiddleware:class, App\Handler\HomePageHandler::class], 'home');
For use with Oauth2 Example
$app->post('/oauth/authorize', [ // Uses the withAction helper to change the expected Google action fn($container) => $container->get(ReCaptchaMiddleware::class)->withAction('oauth_login'), App\Handler\OAuthAuthorizationHandler::class, ], 'oauth.authorize');
Config
return [ 'recaptcha' => [ 'site_key' => '6Lxxxx...', 'secret_key' => '6Lxxxx...', 'score_threshold' => 0.5, ], ];