Skip to content

Commit

Permalink
Feature/support modern password hashes (#182)
Browse files Browse the repository at this point in the history
* Added ARGON2 password hashing

* added missing ldap tag

Co-authored-by: Jens Rauch <[email protected]>
  • Loading branch information
dr-waterstorm and dr-waterstorm authored Nov 24, 2022
1 parent 274fe69 commit 28b2d96
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

* `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.

Expand Down
5 changes: 5 additions & 0 deletions www/includes/ldap_functions.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ function ldap_hashed_password($password) {
"SHA",
"SMD5",
"MD5",
"ARGON2",
"CRYPT",
"CLEAR"
);
Expand Down Expand Up @@ -276,6 +277,10 @@ function ldap_hashed_password($password) {
$hashed_pwd = '{SSHA}' . base64_encode(sha1($password . $salt, TRUE) . $salt);
break;

case 'ARGON2':
$hashed_pwd = '{ARGON2}' . password_hash($password, PASSWORD_ARGON2ID, ['memory_cost' => 2048, 'time_cost' => 4, 'threads' => 3]);
break;

case 'CRYPT':
$salt = generate_salt(2);
$hashed_pwd = '{CRYPT}' . crypt($password, $salt);
Expand Down

0 comments on commit 28b2d96

Please sign in to comment.