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:
johnnyq
2026-11-28 23:31:17 -05:00
parent 4a2933cac9
commit d9c1c752bd
50 changed files with 4679 additions and 46 deletions

View File

@@ -3,8 +3,9 @@
/*
* Admin > Settings > Security (admin/settings_security.php):
* edit_security_settings saves the sign-in page's message and login key, how
* long a browser is remembered, when admins hear of failed sign-ins, whether
* the API takes a key in the address, and shared links. A login key required with none set - which would leave
* long a browser is remembered, whether passkeys sign people in, when admins
* hear of failed sign-ins, whether the API takes a key in the address, and
* shared links. A login key required with none set - which would leave
* agents no way in but the database - is refused, as is a key that couldn't
* be typed into an address, or a time out of range. Nothing is saved then.
* A choice not offered settles to the usual one.
@@ -16,8 +17,10 @@ if (isset($_POST['edit_security_settings'])) {
validateCSRFToken();
$before = settingsCurrent(['config_login_message', 'config_login_key_required', 'config_login_key_secret', 'config_login_remember_me_expire',
'config_login_alert_failures', 'config_api_key_in_address', 'config_share_max_hours', 'config_share_require_protection']);
$before = settingsCurrent(array_merge(['config_login_message', 'config_login_key_required', 'config_login_key_secret', 'config_login_remember_me_expire',
'config_login_alert_failures', 'config_api_key_in_address', 'config_share_max_hours', 'config_share_require_protection'],
// Passkeys, once the database has them (functions/passkey.php)
passkeysReady() ? ['config_login_passkeys'] : []));
// What was sent, and what is saved for anything that wasn't - a switch not sent is off
$in = $_POST + array_map(function ($value) { return (string) $value; }, $before);
@@ -32,6 +35,9 @@ if (isset($_POST['edit_security_settings'])) {
'config_share_max_hours' => intval($in['config_share_max_hours']),
'config_share_require_protection' => empty($_POST['config_share_require_protection']) ? 0 : 1,
];
if (array_key_exists('config_login_passkeys', $before)) {
$after['config_login_passkeys'] = empty($_POST['config_login_passkeys']) ? 0 : 1;
}
$errors = [];
if ($after['config_login_key_secret'] !== '' && !preg_match('/^\w{3,99}$/', $after['config_login_key_secret'])) {