// Read DB settings
$dbdata = json_decode(file_get_contents('/etc/kairo/auth_db.json'), true);
if (!is_array($dbdata)) { trigger_error('DB configuration not found', E_USER_ERROR); }
+$settings = json_decode(file_get_contents('/etc/kairo/auth_settings.json'), true);
+if (!is_array($settings)) { trigger_error('Auth settings not found', E_USER_ERROR); }
// Extended DOM document class
require_once('../kairo/include/cbsm/util/document.php-class');
require_once('../kairo/include/classes/email.php-class');
// Class for sending emails
require_once(__DIR__.'/authutils.php-class');
-$utils = new AuthUtils(array());
+$utils = new AuthUtils($settings);
bindtextdomain('kairo_auth', 'en'); // XXX: Should negotiate locale.
bind_textdomain_codeset('kairo_auth', 'utf-8');
//
// private $pwd_nonces
// The array of nonces to use for "peppering" passwords. For new hashes, the last one of those will be used.
+ // Generate a nonce with this command: |openssl rand -base64 48|
//
// function checkPasswordConstraints($new_password, $user_email)
// Check password constraints and return an array of error messages (empty if all constraints are met).
}
function pwdVerify($password_to_verify, $userdata) {
- if (preg_match('/^(\d+)\|/', $userdata['pwdhash'], $regs)) {
+ $pwdhash = $userdata['pwdhash'];
+ if (preg_match('/^(\d+)\|(.+)$/', $userdata['pwdhash'], $regs)) {
$password_to_verify .= $this->pwd_nonces[$regs[1]];
+ $pwdhash = $regs[2];
}
- return password_verify($password_to_verify, $userdata['pwdhash']);
+ return password_verify($password_to_verify, $pwdhash);
}
function pwdNeedsRehash($userdata) {