大疆航域 / recaptcha
由大疆航域定制的Oro平台reCAPTCHA
dev-master
2022-03-30 15:01 UTC
Requires
- google/recaptcha: ^1.1
- oro/commerce: ^4.0 || ^5.0
- xngageoro/google-recaptcha: dev-master
- xngcomposer/installers: dev-master
This package is not auto-updated.
Last update: 2024-09-27 00:28:25 UTC
README
此包为Oro平台的各种功能添加了Google ReCAPTCHA保护。
目前可以受保护的功能包括
- 注册表单
- 联系我们表单
扩展了excelwebzone的Symfony EWZRecaptchaBundle
要求
此包支持以下Oro平台版本
Oro Platform v3.x
- 对该版本的支持位于“v3.x”分支
Oro Platform v4.1.x
- 对该版本的支持位于“v4.1.x”分支
Oro Platform v4.2.x
- 对该版本的支持位于“v4.2.x”分支
主分支将始终跟踪最新发布版Oro平台的兼容性。
安装和使用
注意:根据您的本地环境调整说明
- 通过Composer安装
composer require friendsoforo/oro-recaptcha-bundle
更新您的config.yml
# app/config/config.yml google_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 google_recaptcha package for more information. # optional, modify key values if you need to override this bundle's default settings xngage_recaptcha: settings: #theme: light #size: normal #protect_registration: true #protect_contact_form: true
- 清除Oro缓存
php bin/console cache:clear --env=prod
- 登录到Oro Admin
- 导航到系统配置 => 集成 => ReCAPTCHA
- 配置ReCAPTCHA小部件并启用/禁用受保护功能
- 保存配置并验证它现在是否已出现在前端网站上
开发中测试
将config.yml中的值复制到config_dev.yml中,并将公钥/私钥替换为Google提供的测试密钥: https://developers.google.com/recaptcha/docs/faq#id-like-to-run-automated-tests-with-recaptcha-what-should-i-do
小部件应在表单中渲染,但将被文本覆盖
"此reCAPTCHA仅用于测试目的。如果您看到此内容,请向网站管理员报告。 "
添加到新表单类型
创建一个新的表单类型扩展,该扩展继承自
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; } }
- 通过
services.yml
注册表单类型扩展xngage_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 }
路线图/剩余任务
- [ ] 添加对“隐形”ReCAPTCHA v2的支持
- [ ] 添加对ReCAPTCHA v3的支持
- [ ] 添加按功能定制ReCAPTCHA v3分数阈值的能力
- [ ] 添加通过Oro配置设置公钥/私钥而不是YAML文件的能力