mirror of
https://github.com/itflow-org/itflow
synced 2026-12-02 09:09:01 +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:
@@ -35,6 +35,10 @@ $microsoft_account = $session_auth_method === 'azure';
|
||||
$mfa_required = intval($config_client_portal_require_mfa) === 1;
|
||||
$mfa_setup = $password_account && !$session_mfa_on && (($_GET['mfa'] ?? '') === 'setup' || $portal_mfa_setup_needed) && !portalViewingAs();
|
||||
$remembered = $session_mfa_on ? portalRememberedBrowsers($session_user_id) : 0;
|
||||
// Passkeys, once the database has them (functions/passkey.php)
|
||||
$passkeys_ready = $password_account && passkeysReady();
|
||||
$passkeys_on = $passkeys_ready && passkeysOn();
|
||||
$my_passkeys = $passkeys_ready ? passkeyList($session_user_id) : [];
|
||||
$sees_company = $session_contact_primary || $session_contact_is_technical_contact; // they see every ticket at their company
|
||||
|
||||
// Setting up two-step sign-in: one secret, kept until a code from it is checked
|
||||
@@ -334,6 +338,60 @@ $csrf = escapeHtml($_SESSION['csrf_token']);
|
||||
<div class="itflow-portal-panel-body border-top small text-body-secondary py-2"><?= escapeHtml($session_company_name) ?> asks everyone to use it, so it stays on. Lost your phone? Ask us to reset it.</div>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ($passkeys_ready && ($passkeys_on || $my_passkeys)) { ?>
|
||||
<!-- Passkeys - signing in without the password (js/passkey.js) -->
|
||||
<ul class="itflow-portal-list border-top">
|
||||
<li class="itflow-portal-ticket">
|
||||
<?= portalTile('fa-fingerprint') ?>
|
||||
<span class="itflow-portal-ticket-main">
|
||||
<span class="itflow-portal-ticket-subject d-block">Passkeys</span>
|
||||
<span class="itflow-portal-ticket-meta"><span><?= $my_passkeys ? 'Sign in with your fingerprint, face or PIN - no password needed' : 'Sign in with your fingerprint, face or PIN instead of your password' ?></span></span>
|
||||
</span>
|
||||
<?php if ($passkeys_on && !portalViewingAs()) { ?>
|
||||
<button type="button" class="btn btn-sm btn-primary text-nowrap" data-bs-toggle="collapse" data-bs-target="#passkeyForm" aria-expanded="false" aria-controls="passkeyForm">Add</button>
|
||||
<?php } ?>
|
||||
</li>
|
||||
<?php foreach ($my_passkeys as $passkey) { ?>
|
||||
<li class="itflow-portal-ticket">
|
||||
<span class="itflow-portal-ticket-main ps-1">
|
||||
<span class="itflow-portal-ticket-subject d-block text-truncate"><i class="fas fa-fw fa-key text-body-secondary me-1"></i><?= escapeHtml($passkey['passkey_name']) ?></span>
|
||||
<span class="itflow-portal-ticket-meta"><span><?= passkeyMetaHtml($passkey, false) ?></span></span>
|
||||
</span>
|
||||
<?php if (!portalViewingAs()) { ?>
|
||||
<a class="btn btn-sm btn-outline-secondary text-nowrap confirm-link" href="post.php?portal_passkey_remove=<?= intval($passkey['passkey_id']) ?>&csrf_token=<?= $csrf ?>">Remove</a>
|
||||
<?php } ?>
|
||||
</li>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
<?php if ($passkeys_on && !portalViewingAs()) { ?>
|
||||
<form class="collapse itflow-portal-panel-body border-top" id="passkeyForm" action="post.php" method="post" autocomplete="off" data-passkey-add data-options-url="post.php" data-csrf="<?= $csrf ?>">
|
||||
<input type="hidden" name="csrf_token" value="<?= $csrf ?>">
|
||||
<input type="hidden" name="portal_passkey_add" value="1">
|
||||
<input type="hidden" name="passkey_client_data" value="">
|
||||
<input type="hidden" name="passkey_attestation" value="">
|
||||
<input type="hidden" name="passkey_transports" value="">
|
||||
<input type="hidden" name="passkey_prf" value="">
|
||||
<p class="small text-body-secondary">Your browser asks where to keep it - this device, your phone, a security key or your password manager - and for your fingerprint, face or PIN.</p>
|
||||
<div data-passkey-message></div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label" for="passkeyName">Name</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text"><i class="fas fa-fw fa-tag"></i></span>
|
||||
<input type="text" class="form-control" id="passkeyName" name="passkey_name" maxlength="<?= PASSKEY_NAME_MAX ?>" placeholder="<?= escapeHtml(passkeyDefaultName($_SERVER['HTTP_USER_AGENT'] ?? '')) ?>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label" for="passkeyPassword">Your current password</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text"><i class="fas fa-fw fa-lock"></i></span>
|
||||
<input type="password" class="form-control" id="passkeyPassword" name="current_password" autocomplete="current-password" required>
|
||||
</div>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary"><i class="fas fa-fingerprint me-2"></i>Add Passkey</button>
|
||||
</form>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ($session_mfa_on && $remembered) { ?>
|
||||
<form class="itflow-portal-panel-body border-top d-flex align-items-center justify-content-between gap-2" action="post.php" method="post" data-portal-once>
|
||||
<input type="hidden" name="csrf_token" value="<?= $csrf ?>">
|
||||
@@ -402,4 +460,8 @@ $csrf = escapeHtml($_SESSION['csrf_token']);
|
||||
</div>
|
||||
|
||||
<?php
|
||||
if ($passkeys_on) { ?>
|
||||
<script src="<?= staticFileUrl('/js/passkey.js') ?>"></script>
|
||||
<?php }
|
||||
|
||||
require_once 'includes/footer.php';
|
||||
|
||||
Reference in New Issue
Block a user