friendsoforo / oro-recaptcha-bundle
Oro Bundle to inject ReCAPTCHA into public forms
Installs: 21 547
Dependents: 0
Suggesters: 0
Security: 0
Stars: 7
Watchers: 12
Forks: 4
Open Issues: 1
Type:project
Requires
- excelwebzone/recaptcha-bundle: ^1.5
- oro/platform: 6.0.*
This package is auto-updated.
Last update: 2024-11-03 22:51:57 UTC
README
This bundle adds Google ReCAPTCHA protection for various Oro features.
Features which can currently be protected are:
- Registration Form
- Contact Us Form
Extends the Symfony EWZRecaptchaBundle by excelwebzone
Requirements
This bundle supports the following Oro Platform versions:
-
Oro Platform v3.x
- Support for this version is on the "v3.x" branch
-
Oro Platform v4.1.x
- Support for this version is on the "v4.1.x" branch
-
Oro Platform v4.2.x
- Support for this version is on the "v4.2.x" branch
-
Oro Platform v5.x
- Support for this version is on the "v5.x" branch
-
Oro Platform v6.0.x
- Support for this version is on the "v6.0.x" branch
The Master branch will always track support for the latest released Oro Platform version.
Installation and Usage
NOTE: Adjust instructions as needed for your local environment
- Install via Composer:
composer require friendsoforo/oro-recaptcha-bundle
- Update your config.yml:
# app/config/config.yml ewz_recaptcha: public_key: here_is_your_public_key private_key: here_is_your_private_key # Not needed as "%kernel.default_locale%" is the default value for the locale key # locale_key: %kernel.default_locale% # etc. Refer to the ewz_recaptcha package for more information.
- Purge Oro cache:
php bin/console cache:clear --env=prod
- Login to Oro Admin
- Navigate to System Configuration => Integrations => ReCAPTCHA
- Configure the ReCAPTCHA widget and enabled/disable Protected Features
- Save the configuration and verify that it is now appearing on the frontend website
Testing in Development
Copy the config.yml
values into config_dev.yml
and replace the public/private keys with the test keys provided by Google:
https://developers.google.com/recaptcha/docs/faq#id-like-to-run-automated-tests-with-recaptcha-what-should-i-do
The widget should render on the forms, but will be overlaid with the text:
"This reCAPTCHA is for testing purposes only. Please report to the site admin if you are seeing this. "
Adding to new Form Types
- Create a new Form Type Extension which extends
HackOro\RecaptchaBundle\Form\Extension\AbstractRecaptchaTypeExtension
<?php namespace Acme\CustomBundle\Form\Extension; use Acme\CustomBundle\Form\Type\CustomPageType; class CustomPageTypeExtension extends AbstractRecaptchaTypeExtension { public function getExtendedType() { // The Form Type we are extending return CustomPageType::class; } /** * Protect the Custom Page Form? * @return boolean */ public function isProtected() { // Replace this with a configuration option if needed return true; } }
- Register the Form Type Extension via
services.yml
:hack_oro_recaptcha.form.registration_form_type_extension: class: Acme\CustomBundle\Form\Extension\CustomPageTypeExtension calls: - [setConfigManager, ['@oro_config.user']] tags: - { name: form.type_extension, extended_type: Acme\CustomBundle\Form\Type\CustomPageType }
Roadmap / Remaining Tasks
- Add support for "Invisible" ReCAPTCHA v2
- Add support for ReCAPTCHA v3
- Add ability to customize ReCAPTCHA v3 score threshold on a per-feature basis
- Add ability to set public/private keys via Oro Configuration instead of YAML files