formtools / core

The Form Tools Core.
https://formtools.org
207 stars 78 forks source link

Google ReCaptcha verification via proxy #605

Open gdhnz opened 5 years ago

gdhnz commented 5 years ago

In our environment setup, we block the server from sending outgoing requests unless they go through a proxy server.

We have set the https_proxy, http_proxy, and no_proxy environments to easily support this but unfortunately, the default RequestMethod\Post method doesn't use these environment variables when reaching out to Google for verification.

Can an option be added so that we can use the ReCaptcha\RequestMethod\CurlPost() as a second parameter to the ReCaptcha\ReCaptcha method.

cURL in PHP will use the https_proxy, http_proxy, and no_proxy environment variables if they're set.

I've used the following in my API validateRecaptcha method but I'd rather not have to hack the core as that causes problems when updating.

$recaptcha = new \ReCaptcha\ReCaptcha(
    $secret_key,
    new \ReCaptcha\RequestMethod\CurlPost()
);