mirror of
https://github.com/itflow-org/itflow
synced 2026-12-02 00:59:03 +00:00
Passkeys: agents and client portal contacts can add a passkey with their password and sign in with it instead of their email and password, counting as two-step sign-in; a passkey that supports PRF also opens an agent's credential vault, otherwise credentials stay locked until they type their password once; admins can turn passkeys off in Security settings, and resetting MFA, turning off a contact's two-step sign-in, archiving an agent and the incident password reset remove them; database 4.2.2 adds user_passkeys, users.user_passkey_handle and settings.config_login_passkeys, and lbuchs/WebAuthn 2.2.0 is bundled in libs/webauthn
This commit is contained in:
@@ -285,10 +285,14 @@ if (isset($_POST['edit_user'])) {
|
||||
$changes[] = 'password changed';
|
||||
userNotifyChange($name, $email, 'an administrator set a new password');
|
||||
}
|
||||
if (!empty($_POST['reset_mfa']) && trim((string) $row['user_token']) !== '') {
|
||||
if (!empty($_POST['reset_mfa']) && (trim((string) $row['user_token']) !== '' || (passkeysReady() && passkeyCount($user_id)))) {
|
||||
userResetMfa($user_id);
|
||||
$passkeys_removed = passkeysReady() ? passkeysForget($user_id) : 0;
|
||||
if ($passkeys_removed) {
|
||||
$changes[] = 'passkeys removed';
|
||||
}
|
||||
$changes[] = 'MFA reset';
|
||||
userNotifyChange($name, $email, 'an administrator turned off multi-factor authentication' . ($force_mfa ? ' - you will set it up again at your next sign in' : ''));
|
||||
userNotifyChange($name, $email, 'an administrator turned off multi-factor authentication' . ($passkeys_removed ? ' and removed your passkeys' : '') . ($force_mfa ? ' - you will set it up again at your next sign in' : ''));
|
||||
}
|
||||
if (strcasecmp($email, $row['user_email']) !== 0) {
|
||||
$changes[] = 'email changed';
|
||||
@@ -388,9 +392,11 @@ if (isset($_GET['reset_user_mfa'])) {
|
||||
$user_id = intval($row['user_id']);
|
||||
|
||||
userResetMfa($user_id);
|
||||
userNotifyChange($row['user_name'], $row['user_email'], 'an administrator turned off multi-factor authentication' . (intval($row['user_config_force_mfa']) ? ' - you will set it up again at your next sign in' : ''));
|
||||
// Their passkeys count as MFA, and go too (functions/passkey.php)
|
||||
$passkeys_removed = passkeysReady() ? passkeysForget($user_id) : 0;
|
||||
userNotifyChange($row['user_name'], $row['user_email'], 'an administrator turned off multi-factor authentication' . ($passkeys_removed ? ' and removed your passkeys' : '') . (intval($row['user_config_force_mfa']) ? ' - you will set it up again at your next sign in' : ''));
|
||||
|
||||
logAudit("User", "Edit", "$session_name reset MFA for user " . escapeSql($row['user_name']), 0, $user_id);
|
||||
logAudit("User", "Edit", "$session_name reset MFA for user " . escapeSql($row['user_name']) . ($passkeys_removed ? " and removed their passkeys" : ''), 0, $user_id);
|
||||
|
||||
flashAlert("MFA reset for <strong>" . $row['user_name'] . "</strong>" . (intval($row['user_config_force_mfa']) ? ' - they set it up again at their next sign in' : ' - they sign in with their password alone until they turn it on'));
|
||||
|
||||
@@ -418,6 +424,9 @@ if (isset($_POST['archive_user'])) {
|
||||
$scrambled = escapeSql(password_hash(randomString(), PASSWORD_DEFAULT));
|
||||
mysqli_query($mysqli, "UPDATE users SET user_name = '$archived_name', user_password = '$scrambled', user_status = 0, user_specific_encryption_ciphertext = '', user_archived_at = NOW() WHERE user_id = $user_id");
|
||||
mysqli_query($mysqli, "DELETE FROM remember_tokens WHERE remember_token_user_id = $user_id");
|
||||
if (passkeysReady()) {
|
||||
passkeysForget($user_id);
|
||||
}
|
||||
|
||||
logAudit("User", "Archive", "$session_name archived user " . escapeSql($row['user_name']), 0, $user_id);
|
||||
|
||||
@@ -653,12 +662,15 @@ if (isset($_POST['ir_reset_user_password'])) {
|
||||
while ($row = mysqli_fetch_assoc($sql_users)) {
|
||||
$new_password = generateReadablePassword(4);
|
||||
userSetPassword($row['user_id'], $new_password);
|
||||
// A remembered browser would skip their MFA code - in an incident, it must not
|
||||
// A remembered browser would skip their MFA code, and a passkey their password - in an incident, neither must
|
||||
mysqli_query($mysqli, "DELETE FROM remember_tokens WHERE remember_token_user_id = " . intval($row['user_id']));
|
||||
if (passkeysReady()) {
|
||||
passkeysForget($row['user_id']);
|
||||
}
|
||||
$reset[] = $row + ['password' => $new_password];
|
||||
}
|
||||
|
||||
logAudit("User", "Edit", "$session_name reset the passwords of " . count($reset) . " agent(s) and forgot their remembered browsers (incident response)");
|
||||
logAudit("User", "Edit", "$session_name reset the passwords of " . count($reset) . " agent(s) and forgot their remembered browsers and passkeys (incident response)");
|
||||
|
||||
// Shown once, not kept - a plain page to read out or copy, and nothing else on it
|
||||
header('Cache-Control: no-store');
|
||||
|
||||
Reference in New Issue
Block a user