How to Configure Strict Web Authentication (WebAuthn) Conditional UI in Google Chrome

Modern web security is rapidly transitioning from legacy passwords to cryptographic passkeys backed by public key cryptography. The W3C Web Authentication (WebAuthn) Level 3 standard introduces Conditional UI (passkey autofill). Rather than requiring users to manually click a dedicated “Sign in with a passkey” button, Google Chrome’s autofill subsystem seamlessly displays discoverable credentials directly inside the username input field alongside traditional saved passwords. Implementing Conditional UI correctly requires coordination between HTML form attributes, client-side JavaScript invocation, and server-side challenge verification.

Understanding WebAuthn Conditional UI Architecture

Conditional UI operates by issuing a passive authentication request that remains dormant until the user interacts with an input field:

  • autocomplete="username webauthn": Signals to Chromium’s password manager that the input field accepts both standard username strings and discoverable passkey credentials.
  • mediation: 'conditional': Passed to navigator.credentials.get(). Instructs Chrome to avoid displaying a modal dialogue immediately, allowing the user to browse normally until selecting a passkey suggestion from the dropdown.
  • PublicKeyCredential.isConditionalMediationAvailable(): Feature detection method verifying whether the browser and operating system support conditional passkey autofill.

Configuring HTML Form Elements for Passkey Autofill

Annotate your login form inputs with the standardised webauthn autocomplete token:

<form id="login-form" method="post" action="/api/login">
  <label for="username">Email or Username</label>
  <input 
    type="text" 
    id="username" 
    name="username" 
    autocomplete="username webauthn" 
    required>

  <label for="password">Password</label>
  <input 
    type="password" 
    id="password" 
    name="password" 
    autocomplete="current-password">

  <button type="submit" id="submit-btn">Sign In</button>
</form>

Authoring the Client-Side JavaScript Conditional Handler

Implement the conditional authentication workflow with graceful fallback to modal authentication:

async function initPasskeyAutofill() {
    // 1. Verify browser and platform support
    if (!window.PublicKeyCredential || 
        !PublicKeyCredential.isConditionalMediationAvailable) {
        console.info("Conditional WebAuthn mediation not supported.");
        return;
    }

    const isAvailable = await PublicKeyCredential.isConditionalMediationAvailable();
    if (!isAvailable) {
        console.info("Passkey autofill unavailable on this platform.");
        return;
    }

    try {
        // 2. Fetch authentication options and challenge from backend
        const response = await fetch('/api/auth/generate-options');
        const options = await response.json();

        // 3. Initiate non-modal conditional credential request
        const assertion = await navigator.credentials.get({
            mediation: 'conditional',
            publicKey: {
                challenge: Uint8Array.from(atob(options.challenge), c => c.charCodeAt(0)),
                rpId: window.location.hostname,
                timeout: 60000,
                userVerification: 'preferred'
            }
        });

        if (assertion) {
            // 4. Send signed credential assertion to verification endpoint
            const verifyRes = await fetch('/api/auth/verify-assertion', {
                method: 'POST',
                headers: { 'Content-Type': 'application/json' },
                body: JSON.stringify({
                    id: assertion.id,
                    rawId: btoa(String.fromCharCode(...new Uint8Array(assertion.rawId))),
                    clientDataJSON: btoa(String.fromCharCode(...new Uint8Array(assertion.response.clientDataJSON))),
                    authenticatorData: btoa(String.fromCharCode(...new Uint8Array(assertion.response.authenticatorData))),
                    signature: btoa(String.fromCharCode(...new Uint8Array(assertion.response.signature))),
                    userHandle: assertion.response.userHandle ? 
                        btoa(String.fromCharCode(...new Uint8Array(assertion.response.userHandle))) : null
                })
            });

            const result = await verifyRes.json();
            if (result.success) {
                window.location.href = '/dashboard';
            }
        }
    } catch (err) {
        if (err.name !== 'AbortError') {
            console.error("Passkey conditional autofill failed:", err);
        }
    }
}

// Initialise upon DOM load
document.addEventListener('DOMContentLoaded', initPasskeyAutofill);

Debugging Passkeys with Chrome DevTools Virtual Authenticator

Google Chrome provides a built-in WebAuthn emulator to simulate biometric touches and security keys without physical hardware:

  1. In Chrome, open DevTools via F12.
  2. Click the three vertical dots (Customize DevTools) in the top right > More tools > WebAuthn.
  3. Tick Enable virtual authenticator environment.
  4. Click New authenticator, select ctap2 protocol, transport internal, and tick Supports resident keys and Supports user verification.
  5. Reload your login page and click inside the username field; Chrome immediately displays the simulated virtual passkey in the autofill dropdown.
  6. Selecting the passkey tests the complete cryptographic challenge-response loop inside your development environment.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.