mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/ConfirmEdit
synced 2024-11-24 00:04:15 +00:00
Add $wgHCaptchaProxy
Bug: T252427 Change-Id: Ia062edb5e619ef3782ad92ab0b7859770f8b5bdd
This commit is contained in:
parent
8dc308a156
commit
96f348b64b
|
@ -20,6 +20,10 @@
|
|||
"CaptchaClass": {
|
||||
"value": "MediaWiki\\Extensions\\ConfirmEdit\\hCaptcha\\HCaptcha"
|
||||
},
|
||||
"HCaptchaProxy" : {
|
||||
"description": "Proxy to use for outbound PHP web requests to hCaptcha servers",
|
||||
"value": false
|
||||
},
|
||||
"HCaptchaSiteKey": {
|
||||
"description": "Sitekey from hCaptcha (requires creating an account)",
|
||||
"value": ""
|
||||
|
|
|
@ -8,8 +8,8 @@ use ConfirmEditHooks;
|
|||
use FormatJson;
|
||||
use Html;
|
||||
use MediaWiki\Auth\AuthenticationRequest;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use Message;
|
||||
use MWHttpRequest;
|
||||
use RawMessage;
|
||||
use SimpleCaptcha;
|
||||
use Status;
|
||||
|
@ -82,7 +82,7 @@ class HCaptcha extends SimpleCaptcha {
|
|||
* @return bool
|
||||
*/
|
||||
protected function passCaptcha( $_, $token ) {
|
||||
global $wgRequest, $wgHCaptchaSecretKey, $wgHCaptchaSendRemoteIP;
|
||||
global $wgRequest, $wgHCaptchaSecretKey, $wgHCaptchaSendRemoteIP, $wgHCaptchaProxy;
|
||||
|
||||
$url = 'https://hcaptcha.com/siteverify';
|
||||
$data = [
|
||||
|
@ -92,13 +92,19 @@ class HCaptcha extends SimpleCaptcha {
|
|||
if ( $wgHCaptchaSendRemoteIP ) {
|
||||
$data['remoteip'] = $wgRequest->getIP();
|
||||
}
|
||||
$request = MWHttpRequest::factory(
|
||||
$url,
|
||||
[
|
||||
'method' => 'POST',
|
||||
'postData' => $data,
|
||||
]
|
||||
);
|
||||
|
||||
$options = [
|
||||
'method' => 'POST',
|
||||
'postData' => $data,
|
||||
];
|
||||
|
||||
if ( $wgHCaptchaProxy ) {
|
||||
$options['proxy'] = $wgHCaptchaProxy;
|
||||
}
|
||||
|
||||
$request = MediaWikiServices::getInstance()->getHttpRequestFactory()
|
||||
->create( $url, $options, __METHOD__ );
|
||||
|
||||
$status = $request->execute();
|
||||
if ( !$status->isOK() ) {
|
||||
$this->error = 'http';
|
||||
|
|
Loading…
Reference in a new issue