chg: Default password policy now includes a 16 char+ string option as an alternative to the short 3/4, fixes #2117

pull/2128/head
iglocska 2017-04-07 10:47:23 +02:00
parent c305891693
commit 6c487c393a
2 changed files with 2 additions and 2 deletions

View File

@ -893,7 +893,7 @@ class Server extends AppModel {
),
'password_policy_complexity' => array(
'level' => 2,
'description' => 'Password complexity requirement. Leave it empty for the default setting (3 out of 4, with either a digit or a special char) or enter your own regex. Keep in mind that the length is checked in another key. Example (simple 4 out of 4): /((?=.*\d)|(?=.*\W+))(?![\n])(?=.*[A-Z])(?=.*[a-z]).*$/',
'description' => 'Password complexity requirement. Leave it empty for the default setting (3 out of 4, with either a digit or a special char) or enter your own regex. Keep in mind that the length is checked in another key. Default (simple 3 out of 4 or minimum 16 characters): /^((?=.*\d)|(?=.*\W+))(?![\n])(?=.*[A-Z])(?=.*[a-z]).*$|.{16,}/',
'value' => '',
'errorMessage' => '',
'test' => 'testPasswordRegex',

View File

@ -368,7 +368,7 @@ App::uses('RandomTool', 'Tools');
*/
public function complexPassword($check) {
$regex = Configure::read('Security.password_policy_complexity');
if (empty($regex) || @preg_match($regex, 'test') === false) $regex = '/((?=.*\d)|(?=.*\W+))(?![\n])(?=.*[A-Z])(?=.*[a-z]).*$/';
if (empty($regex) || @preg_match($regex, 'test') === false) $regex = '/^((?=.*\d)|(?=.*\W+))(?![\n])(?=.*[A-Z])(?=.*[a-z]).*$|.{16,}/';
$value = array_values($check);
$value = $value[0];
return preg_match($regex, $value);