Refactor support for pre-hashed passwords (#4024)
parent
43146b23c9
commit
4feceb08da
|
@ -88,6 +88,11 @@ function hash_password($password) {
|
|||
// in case default pass scheme is not defined, falling back to BLF-CRYPT.
|
||||
global $default_pass_scheme;
|
||||
$pw_hash = NULL;
|
||||
// support pre-hashed passwords
|
||||
if (preg_match('/^{(ARGON2I|ARGON2ID|BLF-CRYPT|CLEAR|CLEARTEXT|CRYPT|DES-CRYPT|LDAP-MD5|MD5|MD5-CRYPT|PBKDF2|PLAIN|PLAIN-MD4|PLAIN-MD5|PLAIN-TRUNC|PLAIN-TRUNC|SHA|SHA1|SHA256|SHA256-CRYPT|SHA512|SHA512-CRYPT|SMD5|SSHA|SSHA256|SSHA512)}/i', $password)) {
|
||||
$pw_hash = $password;
|
||||
}
|
||||
else {
|
||||
switch (strtoupper($default_pass_scheme)) {
|
||||
case "SSHA":
|
||||
$salt_str = bin2hex(openssl_random_pseudo_bytes(8));
|
||||
|
@ -106,6 +111,7 @@ function hash_password($password) {
|
|||
$pw_hash = "{BLF-CRYPT}" . password_hash($password, PASSWORD_BCRYPT);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $pw_hash;
|
||||
}
|
||||
function last_login($user) {
|
||||
|
|
|
@ -1062,14 +1062,8 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
|
|||
);
|
||||
return false;
|
||||
}
|
||||
// support pre hashed passwords
|
||||
if (preg_match('/^{(ARGON2I|ARGON2ID|BLF-CRYPT|CLEAR|CLEARTEXT|CRYPT|DES-CRYPT|LDAP-MD5|MD5|MD5-CRYPT|PBKDF2|PLAIN|PLAIN-MD4|PLAIN-MD5|PLAIN-TRUNC|PLAIN-TRUNC|SHA|SHA1|SHA256|SHA256-CRYPT|SHA512|SHA512-CRYPT|SMD5|SSHA|SSHA256|SSHA512)}/i', $password)) {
|
||||
$password_hashed = $password;
|
||||
}
|
||||
else {
|
||||
$password_hashed = hash_password($password);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$_SESSION['return'][] = array(
|
||||
'type' => 'danger',
|
||||
|
|
Loading…
Reference in New Issue