Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReCaptcha Version 3 #218

Open
seddighi78 opened this issue Dec 5, 2018 · 10 comments
Open

ReCaptcha Version 3 #218

seddighi78 opened this issue Dec 5, 2018 · 10 comments

Comments

@seddighi78
Copy link

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

@chrisaligent
Copy link

chrisaligent commented Dec 12, 2018

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 🙂

@alexander-schranz
Copy link
Contributor

alexander-schranz commented Dec 16, 2018

maybe adding a additional configuration with version could be added:

ewz_recaptcha:
    version: 'v3' # defaults to v2

so the backward compatibility is given?

@MichaelBrauner
Copy link

So... is it possible to simply do:

ewz_recaptcha:
    version: 'v3' # defaults to v2

@man-andy
Copy link

any updates regarding this?

@spavanes
Copy link

I'm also interested in this feature.

@prugala
Copy link

prugala commented Apr 14, 2019

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

@spavanes @man-andy

@HamHamFonFon
Copy link

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 ?

@itinance
Copy link

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?

@prugala
Copy link

prugala commented Jun 21, 2020

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

@alexander-schranz
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants