EWZRecaptchaBundle icon indicating copy to clipboard operation
EWZRecaptchaBundle copied to clipboard

ReCaptcha Version 3

Open seddighi78 opened this issue 6 years ago • 10 comments

Is possible to use the ReCaptcha version 3 and if yes how to use it?

seddighi78 avatar Dec 05 '18 19:12 seddighi78

The server-side code for verifying the CAPTCHA (as well as the frontend api.js JS URL) seems to be the same on v2 and v3, so it's just the front-end implementation which would need to be modified. We've decided to stick with v2 for now, but v3 didn't look too difficult to add: https://developers.google.com/recaptcha/docs/v3#integration

This PHP code from this package's README shows how to manually implement v2 frontend code:

<div id="recaptcha-container"></div>
<script type="text/javascript">
    $(document).ready(function() {
        $.getScript("<?php echo \EWZ\Bundle\RecaptchaBundle\Form\Type\EWZRecaptchaType::RECAPTCHA_API_JS_SERVER ?>", function() {
            Recaptcha.create("<?php echo $form['recaptcha']->get('public_key') ?>", "recaptcha-container", {
                theme: "clean",
            });
        });
    };
</script>

I'm guessing v3 would be something like this:

<script src="<?php echo \EWZ\Bundle\RecaptchaBundle\Form\Type\EWZRecaptchaType::RECAPTCHA_API_JS_SERVER ?>?render=<?php echo $form['recaptcha']->get('public_key') ?>"></script>
  <script>
  grecaptcha.ready(function() {
      grecaptcha.execute('<?php echo $form['recaptcha']->get('public_key') ?>', {action: 'homepage'}).then(function(token) {
         ...
      });
  });
  </script>

NOTE: The above code is entirely untested but might be enough to get you started :slightly_smiling_face:

chrisaligent avatar Dec 12 '18 00:12 chrisaligent

maybe adding a additional configuration with version could be added:

ewz_recaptcha:
    version: 'v3' # defaults to v2

so the backward compatibility is given?

alexander-schranz avatar Dec 16 '18 18:12 alexander-schranz

So... is it possible to simply do:

ewz_recaptcha:
    version: 'v3' # defaults to v2

MichaelBrauner avatar Dec 28 '18 20:12 MichaelBrauner

any updates regarding this?

man-andy avatar Feb 18 '19 13:02 man-andy

I'm also interested in this feature.

spavanes avatar Feb 18 '19 15:02 spavanes

I made simple bundle for reCAPTHCA v3 if someone want to use https://github.com/prugala/PRRecaptchaBundle

@spavanes @man-andy

prugala avatar Apr 14 '19 17:04 prugala

I made simple bundle for reCAPTHCA v3 if someone want to use https://github.com/prugala/PRRecaptchaBundle

@spavanes @man-andy

I'm intersting but i need to use it on an old symfony version (2.7). Is it compatible ?

Astro-Otter-Space avatar Aug 30 '19 13:08 Astro-Otter-Space

I've tried suggestion from @alexander-schranz

ewz_recaptcha:
    version: 'v3' # defaults to v2

But this option does not exists in current version 1.5:

Unrecognized option "version" under "ewz_recaptcha".

Any ideas?

itinance avatar Jun 21 '20 19:06 itinance

@itinance it was idea only. As I wrote above I made simple bundle for Recaptcha V3: https://github.com/prugala/PRRecaptchaBundle

prugala avatar Jun 21 '20 21:06 prugala

This seems to be implemented in #256 Thx to @manuxi

alexander-schranz avatar Dec 13 '20 19:12 alexander-schranz