Merge #15495 - Fix #15496 - Modify ReCaptcha to allow for custom siteVerifyUrl value

Merge #15495
Fixes: #15496

Signed-off-by: William Desportes <williamdes@wdes.fr>
This commit is contained in:
William Desportes 2020-05-02 13:36:53 +02:00
commit d2efd91f60
No known key found for this signature in database
GPG Key ID: 90A0EF1B8251A889
5 changed files with 26 additions and 3 deletions

View File

@ -1892,6 +1892,17 @@ Cookie authentication options
reCaptcha will be then used in :ref:`cookie`.
.. config:option:: $cfg['CaptchaSiteVerifyURL']
:type: string
:default: ``''``
The URL for the reCaptcha service to do siteverify action.
reCaptcha will be then used in :ref:`cookie`.
.. versionadded:: 5.1.0
Navigation panel setup
----------------------

View File

@ -898,6 +898,8 @@ class Descriptions
'CaptchaLoginPublicKey_name' => __('Public key for reCaptcha'),
'CaptchaLoginPrivateKey_desc' => __('Enter your private key for your domain reCaptcha service.'),
'CaptchaLoginPrivateKey_name' => __('Private key for reCaptcha'),
'CaptchaSiteVerifyURL_desc' => __('Enter your siteverify URL for your reCaptcha service.'),
'CaptchaSiteVerifyURL_name' => __('URL for reCaptcha siteverify'),
'SendErrorReports_desc' => __('Choose the default action when sending error reports.'),
'SendErrorReports_name' => __('Send error reports'),

View File

@ -49,6 +49,7 @@ class FeaturesForm extends \PhpMyAdmin\Config\Forms\User\FeaturesForm
'LoginCookieDeleteAll',
'CaptchaLoginPublicKey',
'CaptchaLoginPrivateKey',
'CaptchaSiteVerifyURL',
];
$result['Developer'] = [
'UserprefsDeveloperTab',

View File

@ -268,20 +268,22 @@ class AuthenticationCookie extends AuthenticationPlugin
&& ! empty($GLOBALS['cfg']['CaptchaLoginPublicKey'])
) {
if (! empty($_POST['g-recaptcha-response'])) {
$captchaSiteVerifyURL = $GLOBALS['cfg']['CaptchaSiteVerifyURL'] ?? '';
$captchaSiteVerifyURL = empty($captchaSiteVerifyURL) ? null : $captchaSiteVerifyURL;
if (function_exists('curl_init')) {
$reCaptcha = new ReCaptcha\ReCaptcha(
$GLOBALS['cfg']['CaptchaLoginPrivateKey'],
new ReCaptcha\RequestMethod\CurlPost()
new ReCaptcha\RequestMethod\CurlPost(null, $captchaSiteVerifyURL)
);
} elseif (ini_get('allow_url_fopen')) {
$reCaptcha = new ReCaptcha\ReCaptcha(
$GLOBALS['cfg']['CaptchaLoginPrivateKey'],
new ReCaptcha\RequestMethod\Post()
new ReCaptcha\RequestMethod\Post($captchaSiteVerifyURL)
);
} else {
$reCaptcha = new ReCaptcha\ReCaptcha(
$GLOBALS['cfg']['CaptchaLoginPrivateKey'],
new ReCaptcha\RequestMethod\SocketPost()
new ReCaptcha\RequestMethod\SocketPost(null, $captchaSiteVerifyURL)
);
}

View File

@ -848,6 +848,13 @@ $cfg['CaptchaLoginPublicKey'] = '';
*/
$cfg['CaptchaLoginPrivateKey'] = '';
/**
* if reCaptcha is enabled may need an URL for site verify
*
* @global string $cfg['CaptchaSiteVerifyURL']
*/
$cfg['CaptchaSiteVerifyURL'] = '';
/**
* Enable drag and drop import
*