diff --git a/ispconfig3_pass/config/config.inc.php.dist b/ispconfig3_pass/config/config.inc.php.dist index f52c741..e4a3ab0 100644 --- a/ispconfig3_pass/config/config.inc.php.dist +++ b/ispconfig3_pass/config/config.inc.php.dist @@ -5,4 +5,8 @@ $rcmail_config['password_check_symbol'] = TRUE; $rcmail_config['password_check_lower'] = TRUE; $rcmail_config['password_check_upper'] = TRUE; $rcmail_config['password_check_number'] = TRUE; -?> \ No newline at end of file +$rcmail_config['password_min_symbol'] = 1; +$rcmail_config['password_min_lower'] = 1; +$rcmail_config['password_min_upper'] = 1; +$rcmail_config['password_min_number'] = 1; +?> diff --git a/ispconfig3_pass/ispconfig3_pass.php b/ispconfig3_pass/ispconfig3_pass.php index 08539a1..da5d60a 100644 --- a/ispconfig3_pass/ispconfig3_pass.php +++ b/ispconfig3_pass/ispconfig3_pass.php @@ -55,6 +55,11 @@ function save() $curpwd = get_input_value('_curpasswd', RCUBE_INPUT_POST); $newpwd = get_input_value('_newpasswd', RCUBE_INPUT_POST); $pwl = $this->rcmail_inst->config->get('password_min_length'); + // minimum password number of : total chars, lower case, upper case, numbers, symbols + $pwml = $this->rcmail_inst->config->get('password_min_lower'); + $pwmu = $this->rcmail_inst->config->get('password_min_upper'); + $pwmn = $this->rcmail_inst->config->get('password_min_number'); + $pwms = $this->rcmail_inst->config->get('password_min_symbol'); $checkUpper = $this->rcmail_inst->config->get('password_check_upper'); $checkLower = $this->rcmail_inst->config->get('password_check_lower'); $checkSymbol = $this->rcmail_inst->config->get('password_check_symbol'); @@ -64,36 +69,52 @@ function save() if (!empty($pwl)) $pwl = max(6, $pwl); else - $pwl = 6; - - if ($confirm && $this->rcmail_inst->decrypt($_SESSION['password']) != $curpwd) - $this->rcmail_inst->output->command('display_message', $this->gettext('passwordincorrect'), 'error'); - else { - if (strlen($newpwd) < $pwl) { - $error = TRUE; - $this->rcmail_inst->output->command('display_message', str_replace("%d", $pwl, $this->gettext('passwordminlength')), 'error'); - } - - if (!$error && $checkNumber && !preg_match("#[0-9]+#", $newpwd)) { - $error = TRUE; - $this->rcmail_inst->output->command('display_message', $this->gettext('passwordchecknumber'), 'error'); - } - - if (!$error && $checkLower && !preg_match("#[a-z]+#", $newpwd)) { - $error = TRUE; - $this->rcmail_inst->output->command('display_message', $this->gettext('passwordchecklower'), 'error'); - } - - if (!$error && $checkUpper && !preg_match("#[A-Z]+#", $newpwd)) { - $error = TRUE; - $this->rcmail_inst->output->command('display_message', $this->gettext('passwordcheckupper'), 'error'); - } - - if (!$error && $checkSymbol && !preg_match("#\W+#", $newpwd)) { - $error = TRUE; - $this->rcmail_inst->output->command('display_message', $this->gettext('passwordchecksymbol'), 'error'); - } - + $pwl = 6; + if (!empty($pwml)) + $pwml = max(1, $pwml); + else + $pwml = 1; + if (!empty($pwmu)) + $pwmu = max(1, $pwmu); + else + $pwmu = 1; + if (!empty($pwmn)) + $pwmn = max(1, $pwmn); + else + $pwmn = 1; + if (!empty($pwms)) + $pwms = max(1, $pwms); + else + $pwms = 1; + + if ($confirm && $this->rcmail_inst->decrypt($_SESSION['password']) != $curpwd) + $this->rcmail_inst->output->command('display_message', $this->gettext('passwordincorrect'), 'error'); + else { + if (strlen($newpwd) < $pwl) { + $error = TRUE; + $this->rcmail_inst->output->command('display_message', str_replace("%d", $pwl, $this->gettext('passwordminlength')), 'error'); + } + + if (!$error && $checkNumber && !preg_match("#(.*[0-9]){" . $pwmn . ",}#", $newpwd)) { + $error = TRUE; + $this->rcmail_inst->output->command('display_message', str_replace("%d", $pwmn, $this->gettext('passwordchecknumber')), 'error'); + } + + if (!$error && $checkLower && !preg_match("#(.*[a-z]){" . $pwml . ",}#", $newpwd)) { + $error = TRUE; + $this->rcmail_inst->output->command('display_message', str_replace("%d", $pwml, $this->gettext('passwordchecklower')), 'error'); + } + + if (!$error && $checkUpper && !preg_match("#(.*[A-Z]){" . $pwmu . ",}#", $newpwd)) { + $error = TRUE; + $this->rcmail_inst->output->command('display_message', str_replace("%d", $pwmu, $this->gettext('passwordcheckupper')), 'error'); + } + + if (!$error && $checkSymbol && !preg_match("#(.*\W){" . $pwms . ",}#", $newpwd)) { + $error = TRUE; + $this->rcmail_inst->output->command('display_message', str_replace("%d", $pwms, $this->gettext('passwordchecksymbol')), 'error'); + } + if (!$error) { try { $soap = new SoapClient(NULL, array('location' => $this->rcmail_inst->config->get('soap_url') . 'index.php', diff --git a/ispconfig3_pass/localization/en_US.inc b/ispconfig3_pass/localization/en_US.inc index 8622797..96ce749 100644 --- a/ispconfig3_pass/localization/en_US.inc +++ b/ispconfig3_pass/localization/en_US.inc @@ -12,8 +12,8 @@ $messages['nocurpassword'] = 'Please input current password.'; $messages['passwordincorrect'] = 'Current password is incorrect.'; $messages['passwordinconsistency'] = 'Inconsistency of password, please try again.'; $messages['passwordminlength'] = 'Password is too short: %d digits required.'; -$messages['passwordchecknumber'] = 'Password must include at least one number.'; -$messages['passwordchecklower'] = 'Password must include at least one lower case letter.'; -$messages['passwordcheckupper'] = 'Password must include at least one upper case letter.'; -$messages['passwordchecksymbol'] = 'Password must include at least one symbol.'; -?> \ No newline at end of file +$messages['passwordchecknumber'] = 'Password must include at least %d number.'; +$messages['passwordchecklower'] = 'Password must include at least %d lower case letter.'; +$messages['passwordcheckupper'] = 'Password must include at least %d upper case letter.'; +$messages['passwordchecksymbol'] = 'Password must include at least %d symbol.'; +?> diff --git a/ispconfig3_pass/localization/fr_FR.inc b/ispconfig3_pass/localization/fr_FR.inc index 9d2a234..511cb22 100644 --- a/ispconfig3_pass/localization/fr_FR.inc +++ b/ispconfig3_pass/localization/fr_FR.inc @@ -12,4 +12,8 @@ $messages['nocurpassword'] = 'Merci de saisir votre mot de passe actuel.'; $messages['passwordincorrect'] = 'Le mot de passe actuel est incorrect.'; $messages['passwordinconsistency'] = 'Les mots de passe ne sont pas identiques, veuillez réessayer'; $messages['passwordminlength'] = 'Le mot de passe est trop court: %d caractères requis.'; -?> \ No newline at end of file +$messages['passwordchecknumber'] = 'Le mot de passe doit contenir au moins %d chiffres.'; +$messages['passwordchecklower'] = 'Le mot de passe doit contenir au moins %d lettres minuscules.'; +$messages['passwordcheckupper'] = 'Le mot de passe doit contenir au moins %d lettres majuscules.'; +$messages['passwordchecksymbol'] = 'Le mot de passe doit contenir au moins %d symboles.'; +?>