Merge branch 'QA_5_0'

Signed-off-by: William Desportes <williamdes@wdes.fr>
This commit is contained in:
William Desportes 2020-08-07 23:58:15 +02:00
commit e00d31f714
No known key found for this signature in database
GPG Key ID: 90A0EF1B8251A889
6 changed files with 110 additions and 0 deletions

View File

@ -94,6 +94,7 @@ phpMyAdmin - ChangeLog
- issue #15367 Fix "Change or reconfigure primary server" link
- issue #15367 Fix first replica links, start, stop, ignore links
- issue #16058 Add "PMA_single_signon_HMAC_secret" for signon auths to make special links work and udate examples
- issue #16269 Support ReCaptcha v2 checkbox width "$cfg['CaptchaMethod'] = 'checkbox';"
5.0.2 (2020-03-20)
- issue Fixed deprecation warning "implode(): Passing glue string after array is deprecated." function on export page

View File

@ -1872,6 +1872,18 @@ Cookie authentication options
bypass regular expression by the suffix, while connecting to another
server.
.. config:option:: $cfg['CaptchaMethod']
:type: string
:default: ``'invisible'``
Valid values are:
* ``'invisible'`` Use an invisible captcha checking method;
* ``'checkbox'`` Use a checkbox to confirm the user is not a robot.
.. versionadded:: 5.0.3
.. config:option:: $cfg['CaptchaLoginPublicKey']
:type: string

View File

@ -235,6 +235,7 @@ class AuthenticationCookie extends AuthenticationPlugin
'lang' => $GLOBALS['lang'],
'has_captcha' => ! empty($GLOBALS['cfg']['CaptchaLoginPrivateKey'])
&& ! empty($GLOBALS['cfg']['CaptchaLoginPublicKey']),
'use_captcha_checkbox' => ($GLOBALS['cfg']['CaptchaMethod'] ?? '') === 'checkbox',
'captcha_key' => $GLOBALS['cfg']['CaptchaLoginPublicKey'],
'form_params' => $_form_params,
'errors' => $errors,

View File

@ -835,6 +835,13 @@ $cfg['AllowArbitraryServer'] = false;
*/
$cfg['ArbitraryServerRegexp'] = '';
/**
* To enable reCaptcha v2 checkbox mode if necessary
*
* @global string $cfg['CaptchaMethod']
*/
$cfg['CaptchaMethod'] = 'invisible';
/**
* if reCaptcha is enabled it needs public key to connect with the service
*

View File

@ -80,7 +80,12 @@
<fieldset class="tblFooters">
{% if has_captcha %}
<script src="https://www.google.com/recaptcha/api.js?hl={{ lang }}" async defer></script>
{% if use_captcha_checkbox %}
<div class="g-recaptcha" data-sitekey="{{ captcha_key }}"></div>
<input class="btn btn-primary" value="{% trans 'Go' %}" type="submit" id="input_go">
{% else %}
<input class="btn btn-primary g-recaptcha" data-sitekey="{{ captcha_key }}" data-callback="Functions_recaptchaCallback" value="{% trans 'Go' %}" type="submit" id="input_go">
{% endif %}
{% else %}
<input class="btn btn-primary" value="{% trans 'Go' %}" type="submit" id="input_go">
{% endif %}

View File

@ -335,6 +335,90 @@ class AuthenticationCookieTest extends AbstractNetworkTestCase
);
}
/**
* Test for PhpMyAdmin\Plugins\Auth\AuthenticationConfig::showLoginForm
*
* @group medium
*/
public function testAuthCaptchaCheckbox(): void
{
$mockResponse = $this->mockResponse();
$mockResponse->expects($this->once())
->method('isAjax')
->with()
->will($this->returnValue(false));
$mockResponse->expects($this->once())
->method('getFooter')
->with()
->will($this->returnValue(new Footer()));
$mockResponse->expects($this->once())
->method('getHeader')
->with()
->will($this->returnValue(new Header()));
$_REQUEST['old_usr'] = '';
$GLOBALS['cfg']['LoginCookieRecall'] = false;
$GLOBALS['pmaThemeImage'] = 'test';
$GLOBALS['cfg']['Lang'] = '';
$GLOBALS['cfg']['AllowArbitraryServer'] = false;
$GLOBALS['cfg']['Servers'] = [1];
$GLOBALS['cfg']['CaptchaLoginPrivateKey'] = 'testprivkey';
$GLOBALS['cfg']['CaptchaLoginPublicKey'] = 'testpubkey';
$GLOBALS['cfg']['CaptchaMethod'] = 'checkbox';
$GLOBALS['server'] = 0;
$GLOBALS['error_handler'] = new ErrorHandler();
ob_start();
$this->object->showLoginForm();
$result = ob_get_clean();
// assertions
$this->assertStringContainsString('id="imLogo"', $result);
// Check for language selection if locales are there
$loc = LOCALE_PATH . '/cs/LC_MESSAGES/phpmyadmin.mo';
if (is_readable($loc)) {
$this->assertStringContainsString(
'<select name="lang" class="autosubmit" lang="en" dir="ltr" ' .
'id="sel-lang">',
$result
);
}
$this->assertStringContainsString(
'<form method="post" id="login_form" action="index.php?route=/" name="login_form"' .
' class="disableAjax hide login js-show form-horizontal" autocomplete="off">',
$result
);
$this->assertStringContainsString(
'<input type="hidden" name="server" value="0">',
$result
);
$this->assertStringContainsString(
'<script src="https://www.google.com/recaptcha/api.js?hl=en"'
. ' async defer></script>',
$result
);
$this->assertStringContainsString(
'<div class="g-recaptcha" data-sitekey="testpubkey"></div>',
$result
);
$this->assertStringContainsString(
'<input class="btn btn-primary" value="Go" type="submit" id="input_go">',
$result
);
}
/**
* Test for PhpMyAdmin\Plugins\Auth\AuthenticationConfig::showLoginForm with headers
*/