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

Any way to support hCaptcha? #240

Open
StudioMaX opened this issue Apr 3, 2020 · 1 comment
Open

Any way to support hCaptcha? #240

StudioMaX opened this issue Apr 3, 2020 · 1 comment

Comments

@StudioMaX
Copy link

hCaptcha is a new alternative to ReCaptcha with the same API, but uses a bit different URL with the same arguments. Even Clodflare and DigitalOcean is moving to hCaptcha from ReCaptcha. Unfortunaley, there's none Symfony bundles which provides hCaptcha's support.
Maybe someone has plans to implement hCaptcha in this bundle? Since it makes little sense to create a separate bundle if these two captchas are implemented almost identically.

@chrisaligent
Copy link

The documentation for hCaptcha seems to indicate it's pretty simple to swap over:
https://docs.hcaptcha.com/switch

But there are quite a few locations in this bundle which would need to be modified/swapped based on which is used.
For example:
https://github.com/excelwebzone/EWZRecaptchaBundle/blob/master/src/Form/Type/EWZRecaptchaType.php#L78
Although you can change the hostname from www.google.com to www.hcaptcha.com the path is still hard-coded here, and this URL doesn't exist:
https://www.hcaptcha.com/recaptcha/api.js
It needs to be:
https://www.hcaptcha.com/1/api.js

I guess the easiest way around this is to add a new EWZHCaptchaType Form Type which extends the EWZRecaptchaType and overrides some of these values.
There's also the backend POST call, as the URL of the verification server is entirely different (even if they say the API calls themselves match):
https://github.com/excelwebzone/EWZRecaptchaBundle/blob/master/src/Extension/ReCaptcha/RequestMethod/Post.php#L34

Finally I think additional Twig templates may be necessary for hCaptcha.

It's an interesting concept, it just depends if there's enough demand to justify someone spending time working on adding this feature. I'd love to do it myself but I don't have any clients using hCaptcha yet.

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

2 participants