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

@@ -1,9 +1,10 @@
<?php
/*
* Your account > Security - your password, multi-factor authentication, and
* the browsers that skip your MFA code. Changing the password or turning MFA
* off takes your current password; you are emailed either way.
* Your account > Security - your password, multi-factor authentication, your
* passkeys, and the browsers that skip your MFA code. Changing the password,
* turning MFA off and adding a passkey take your current password; you are
* emailed each time.
*/
require_once "includes/inc_all_user.php";
@@ -13,6 +14,10 @@ $has_mfa = trim((string) $me['user_token']) !== '';
$forced = intval($me['user_config_force_mfa']) === 1;
$browsers = userRememberedBrowsers($session_user_id);
$remember_days = max(1, intval($config_login_remember_me_expire));
// Passkeys, once the database has them (functions/passkey.php)
$passkeys_ready = passkeysReady();
$passkeys_on = $passkeys_ready && passkeysOn();
$passkeys = $passkeys_ready ? passkeyList($session_user_id) : [];
?>
@@ -108,6 +113,43 @@ $remember_days = max(1, intval($config_login_remember_me_expire));
</div>
</div>
<?php if ($passkeys_ready && ($passkeys_on || $passkeys)) { ?>
<!-- Passkeys -->
<div class="col-12">
<div class="card mb-0">
<div class="card-header bg-dark">
<h3 class="card-title"><i class="fas fa-fw fa-fingerprint me-2"></i>Passkeys</h3>
<?php if ($passkeys_on) { ?>
<div class="card-tools">
<button type="button" class="btn btn-sm btn-outline-light" data-bs-toggle="modal" data-bs-target="#addPasskeyModal"><i class="fas fa-plus me-2"></i>Add a Passkey</button>
</div>
<?php } ?>
</div>
<?php if ($passkeys) { ?>
<ul class="list-group list-group-flush">
<?php foreach ($passkeys as $passkey) { ?>
<li class="list-group-item d-flex align-items-center gap-3">
<i class="fas fa-fw fa-fingerprint fa-lg text-body-secondary"></i>
<div class="flex-grow-1 min-w-0">
<div class="text-truncate"><?= escapeHtml($passkey['passkey_name']) ?></div>
<div class="small text-body-secondary"><?= passkeyMetaHtml($passkey) ?></div>
</div>
<a class="btn btn-sm btn-outline-danger confirm-link" href="post.php?delete_your_passkey=<?= intval($passkey['passkey_id']) ?>&csrf_token=<?= $_SESSION['csrf_token'] ?>" title="It no longer signs you in">Remove</a>
</li>
<?php } ?>
</ul>
<?php if (!$passkeys_on) { ?>
<div class="card-footer small text-body-secondary">Your administrator has turned passkeys off, so these don't sign you in for now.</div>
<?php } ?>
<?php } else { ?>
<div class="card-body small text-body-secondary">
None yet. A passkey signs you in with your fingerprint, face or PIN instead of your password - kept on this device, your phone, a security key or your password manager. It counts as multi-factor authentication, and where it can, it opens your credentials too.
</div>
<?php } ?>
</div>
</div>
<?php } ?>
<!-- Remembered browsers -->
<div class="col-12">
<div class="card mb-0">
@@ -165,6 +207,11 @@ $remember_days = max(1, intval($config_login_remember_me_expire));
require_once "modals/user_mfa_modal.php";
} ?>
<?php if ($passkeys_on) {
require_once "modals/user_passkey_modal.php"; ?>
<script src="<?= staticFileUrl('/js/passkey.js') ?>"></script>
<?php } ?>
<script>
(function () {
// The new password, typed twice - said as soon as they match, or don't