reCAPTCHA icon indicating copy to clipboard operation
reCAPTCHA copied to clipboard

Configurable proxy

Open MVnComputers opened this issue 5 years ago • 2 comments

Hi, is it possible to make a configurable proxy? Our company policy will not allow that file_get_contents request. Specifically, the file is ReCaptchaProvider.php, function makeRequest (), line 102.

Now I have to make a hard adjustment to:

$aContext = array(
	'http' => array(
		'proxy '=> 'proxyXYZ.de:8000',
		'request_fulluri' => true,
	),
);
$context = stream_context_create($aContext);

return @file_get_contents($this->buildUrl($params), false, $context);

Otherwise, the recaptcha always returns to me that I am a robot

MVnComputers avatar Dec 13 '19 07:12 MVnComputers

Hey @MVnComputers. Sure, could you please more elaborate a propose some http client changes? Thanks man.

f3l1x avatar Feb 24 '20 19:02 f3l1x

Hi guys, I have same situation as MVnComputers. My servers are behind proxy server so I had to hardcode stream_context_create as example above in file ReCaptchaProvider.php, function makeRequest (), line 102.

      /**
	 * @param mixed $response
	 * @return mixed
	 */
	protected function makeRequest($response, ?string $remoteIp = null)
	{
		if (empty($response)) {
			return null;
		}

		$params = [
			'secret' => $this->secretKey,
			'response' => $response,
		];

		if ($remoteIp !== null) {
			$params['remoteip'] = $remoteIp;
		}

		return @file_get_contents($this->buildUrl($params), false, stream_context_create(array(
                    'http' => array(
                        'proxy'           => '192.168.41.240:3128',
                        'request_fulluri' => true,
                    ),
                )));
	}

Is it possible to integrate optional arguments to neon configuration file like?

 recaptcha:
 	secretKey: xxx 
 	siteKey: xxx 
        proxy: 
                 host: xxx 
                 port: 3128

Thanks

latisak avatar Mar 10 '22 14:03 latisak