Feature/support modern password hashes (#182)

* Added ARGON2 password hashing

* added missing ldap tag

Co-authored-by: Jens Rauch <jens.rauch@codenic.de>
This commit is contained in:
dr-waterstorm 2022-11-24 14:58:13 +01:00 committed by GitHub
parent 274fe69bb5
commit 28b2d9673a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -163,7 +163,7 @@ These settings should only be changed if you're trying to make the user manager
* `USERNAME_REGEX` (default: *^[a-z][a-zA-Z0-9\._-]{3,32}$*): The regular expression used to ensure account names and group names are safe to use on servers. See [Username format](#username-format). * `USERNAME_REGEX` (default: *^[a-z][a-zA-Z0-9\._-]{3,32}$*): The regular expression used to ensure account names and group names are safe to use on servers. See [Username format](#username-format).
* `PASSWORD_HASH` (no default): Select which hashing method which will be used to store passwords in LDAP. Options are (in order of precedence) `SHA512CRYPT`, `SHA256CRYPT`, `MD5CRYPT`, `SSHA`, `SHA`, `SMD5`, `MD5`, `CRYPT` & `CLEAR`. If your chosen method isn't available on your system then the strongest available method will be automatically selected - `SSHA` is the strongest method guaranteed to be available. Cleartext passwords should NEVER be used in any situation outside of a test. * `PASSWORD_HASH` (no default): Select which hashing method which will be used to store passwords in LDAP. Options are (in order of precedence) `SHA512CRYPT`, `SHA256CRYPT`, `MD5CRYPT`, `SSHA`, `SHA`, `SMD5`, `MD5`, `ARGON2`, `CRYPT` & `CLEAR`. If your chosen method isn't available on your system then the strongest available method will be automatically selected - `SSHA` is the strongest method guaranteed to be available. Note that for `ARGON2` to work you need to have the ARGON2 plugin enabled, if you do not the passwords will be saved but the user cannot authenticate against it. Cleartext passwords should NEVER be used in any situation outside of a test.
* `ACCEPT_WEAK_PASSWORDS` (default: *FALSE*): Set this to *TRUE* to prevent a password being rejected for being too weak. The password strength indicators will still gauge the strength of the password. Don't enable this in a production environment. * `ACCEPT_WEAK_PASSWORDS` (default: *FALSE*): Set this to *TRUE* to prevent a password being rejected for being too weak. The password strength indicators will still gauge the strength of the password. Don't enable this in a production environment.

View File

@ -205,6 +205,7 @@ function ldap_hashed_password($password) {
"SHA", "SHA",
"SMD5", "SMD5",
"MD5", "MD5",
"ARGON2",
"CRYPT", "CRYPT",
"CLEAR" "CLEAR"
); );
@ -276,6 +277,10 @@ function ldap_hashed_password($password) {
$hashed_pwd = '{SSHA}' . base64_encode(sha1($password . $salt, TRUE) . $salt); $hashed_pwd = '{SSHA}' . base64_encode(sha1($password . $salt, TRUE) . $salt);
break; break;
case 'ARGON2':
$hashed_pwd = '{ARGON2}' . password_hash($password, PASSWORD_ARGON2ID, ['memory_cost' => 2048, 'time_cost' => 4, 'threads' => 3]);
break;
case 'CRYPT': case 'CRYPT':
$salt = generate_salt(2); $salt = generate_salt(2);
$hashed_pwd = '{CRYPT}' . crypt($password, $salt); $hashed_pwd = '{CRYPT}' . crypt($password, $salt);