karser / KarserRecaptcha3Bundle

Google ReCAPTCHA v3 for Symfony
MIT License
160 stars 22 forks source link

google.com not accessible from China #45

Closed Prometee closed 3 years ago

Prometee commented 3 years ago

We use your bundle on our shop through a plugin prometee/sylius-google-recaptcha-v3-plugin without any issue.

Except when Chinese people try to fill a form (with a GRecaptchaV3 embeded) from China, apparently this is a known issue and google assistance page is telling us to replace google.com by recaptcha.net. You can find more info about this reading the StackOverflow answer here : https://stackoverflow.com/questions/57827914/google-recaptcha-in-china

One way to fix this is to simply extends the template, but may I suggest to be able to switch this from a config switch ?

# config/packages/karser_recaptcha3.yaml (or app/config/config.yml if using Symfony3)

karser_recaptcha3:
    use_recaptcha_net: true

(A comment can be also linked to this config field with the link to the StackOverflow page)

And then add a third constructor argument to the Recaptcha3Type to allow the twig template to switch domain accordingly.

Any suggestion or advise before I start to propose a PR ?

karser commented 3 years ago

That makes sense. How about adding a host parameter and inject it into all services?

karser_recaptcha3:
    host: 'www.google.com'
#    host: 'www.recaptcha.net'

P.S. the title of this issue is awesome :)

Prometee commented 3 years ago

@karser I agree host is better. Let start a PR 😉 !

Prometee commented 3 years ago

@karser I'm wondering if the $siteVerifyUrl argument of ReCaptcha\RequestMethod\CurlPost class has to be updated too because, it will be required only if your server is hosted in China. The modified verify url is responding to a GET request (to test it) : https://www.recaptcha.net/recaptcha/api/siteverify