Skip to content

Commit

Permalink
- Added a new flag $use_checkpasswordhistory to config.inc.php
Browse files Browse the repository at this point in the history
- Documented feature for use
  • Loading branch information
abpai94 committed Sep 4, 2024
1 parent 7a39be8 commit 7639545
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 4 deletions.
1 change: 1 addition & 0 deletions conf/config.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@

# Features
$use_checkpassword = true;
$use_checkpasswordhistory = true;
$use_resetpassword = true;
$use_resetpassword_resetchoice = true;
$resetpassword_reset_default = true;
Expand Down
11 changes: 11 additions & 0 deletions docs/checkpassword.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,14 @@ To enable this feature:
.. code-block:: php
$use_checkpassword = true;
Check password history
----------------------

The password history can be checked by enabling this feature.

To enable this feature:

.. code-block:: php
$use_checkpasswordhistory = true;
15 changes: 11 additions & 4 deletions htdocs/checkpassword.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
$result = "passwordrequired";
}



if ($result === "") {

require_once("../conf/config.inc.php");
Expand All @@ -32,8 +30,17 @@
$ldap = $ldap_connection[0];
$result = $ldap_connection[1];

if( !$result ) {

if ($use_checkpasswordhistory) {
$hashed_password_history = $ldapInstance->get_attribute_values($dn, "pwdHistory");
foreach ($hashed_password_history as $hashed_password) {
preg_match("/(?<={).*(?=})/", $hashed_password, $algorithm);
preg_match("/{(?<={).*/", $hashed_password, $password_hash);
if (\Ltb\Password::check_password($password, $password_hash[0], $algorithm[0])) {
$result = "passwordinhistory";
}
}
}
if (!$result) {
$bind = ldap_bind($ldap, $dn, $password);
$result = $bind ? "passwordok" : "ldaperror";
}
Expand Down
1 change: 1 addition & 0 deletions htdocs/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
$smarty->assign('display_footer',$display_footer);
$smarty->assign('logout_link',isset($logout_link) ? $logout_link : false);
$smarty->assign('use_checkpassword',$use_checkpassword);
$smarty->assign('use_checkpasswordhistory',$use_checkpasswordhistory);
$smarty->assign('use_resetpassword',$use_resetpassword);
$smarty->assign('use_resetpassword_resetchoice',$use_resetpassword_resetchoice);
$smarty->assign('resetpassword_reset_default',$resetpassword_reset_default);
Expand Down
1 change: 1 addition & 0 deletions lang/en.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
$messages['passwordinvalid'] = "Authentication has failed";
$messages['passwordok'] = "Authentication succeeds!";
$messages['passwordrefused'] = "Password was refused";
$messages['passwordinhistory'] = "Password in history";
$messages['passwordrequired'] = "Please enter the password";
$messages['resetpassword'] = "Reset password";
$messages['search'] = "Search";
Expand Down
3 changes: 3 additions & 0 deletions templates/display.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@
{if $checkpasswordresult eq 'passwordok'}
<div class="alert alert-success"><i class="fa fa-fw fa-check"></i> {$msg_passwordok}</div>
{/if}
{if $checkpasswordresult eq 'passwordinhistory'}
<div class="alert alert-warning"><i class="fa fa-fw fa-exclamation-triangle"></i> {$msg_passwordinhistory}</div>
{/if}
<input type="hidden" name="dn" value="{$dn}" />
<div class="input-group mb-3">
<span class="input-group-text"><i class="fa fa-fw fa-lock"></i></span>
Expand Down

0 comments on commit 7639545

Please sign in to comment.