Skip to content

ui-react: a passkey-only login screen starts conditional UI with no autofill field and burns the options rate limit #2555

Closed

Description

@schlessera

Context

LoginScreen (packages/ui-react/src/components/connectivity/login-screen.tsx:71-111) asks /auth/methods which methods are available. When the server reports passkey: true, password: false, it sets passwordAvailable to false (line 84). That removes the password field, the only input with autoComplete="current-password webauthn" (packages/ui-react/src/components/connectivity/login-form.tsx:76-90). The effect then starts the conditional-UI ceremony anyway (lines 89-105).

loginWithPasskey (packages/ui-react/src/lib/passkeys.ts:35-48) first calls api.passkeyLoginOptions(). Only after that does @simplewebauthn/browser 13.x startAuthentication look for input[autocomplete$='webauthn']. Finding none, it throws Error('No <input> with "webauthn" as the only or last value in its autocomplete attribute was detected'). That error is not a user cancel, so line 103 logs console.warn("[passkeys] conditional UI failed:", …).

Every load of a passkey-only login screen therefore:

  • spends one token of the login-options budget, 10 per IP per minute (OPTIONS_RATE_LIMIT, packages/ui-server/src/middleware/passkeys.ts:77, consumed at line 322). Reloading a few times locks the explicit "Sign in with a passkey" button out with a 429.
  • leaves an unused authentication challenge in the capped pending store (putChallenge, packages/ui-server/src/middleware/passkeys.ts:129-139, called at line 334).
  • logs a warning to the console.

Guide security/passkey-authentication: conditional mediation is for offering passkeys "natively when users focus on sign-in fields". With no field there is nothing to attach the suggestion to.

Scope

  • Start the conditional-UI ceremony only when the login form renders an input whose autocomplete includes webauthn. Today that input exists exactly when methods.password is true. Gate on that before api.passkeyLoginOptions() is called.
  • Leave the explicit passkey button flow (onPasskeyClick, lines 130-146) unchanged.

Out of scope

Acceptance criteria

  • With /auth/methods returning { password: false, passkey: true }, loading the login screen makes no POST /api/auth/passkey/login-options request and logs no [passkeys] console warning.
  • With { password: true, passkey: true }, conditional UI still starts: exactly one login-options request on load, and the password field's autofill offers the passkey.
  • The "Sign in with a passkey" button still completes sign-in on a passkey-only deployment.
  • A test with a stub API that counts passkeyLoginOptions calls fails on the tree before the change (count 1 on passkey-only) and passes after (count 0).
  • A real-Chrome runtime test (Playwright plus the CDP WebAuthn.addVirtualAuthenticator virtual authenticator, following packages/ui-react/tests/auth-expiry-runtime.test.ts) proves the first three criteria against real ui-server routes. The PR records a mutation: remove the gate, watch the passkey-only case fail on the request-count assertion, restore.

Verification

bun run test packages/ui-react/tests/passkey-login-runtime.test.ts   # new; BRAIN_REQUIRE_CHROME=1 in CI
bun run test
bun run typecheck
bun run lint

Contract impact

  • This touches the integration contract, so it needs the contract label, a CONTRACT: commit prefix, and the doc updated in the same commit.
  • This changes a published package's behaviour, so it needs a changeset.

None for the contract: no route, field or exported signature changes.

Activity

  1. added
    type: fix
    area: ui-react
    priority: p1
    agent-ready
    on Oct 22, 2026
  2. self-assigned this
    on Nov 17, 2026
  3. schlessera commented on Nov 17, 2026

    @schlessera
    OwnerAuthor

    Claimed for implementation. Claim token: claim-f25aa04e. Branch: fix/2555-passkey-conditional-gate.

    Collisions: closure reports only, no PR edits login-screen.tsx or passkeys.ts. #2556 (unclaimed) must keep this gate.

  4. added this to the 0.45.0 milestone on Nov 17, 2026
  5. schlessera commented on Nov 17, 2026

    @schlessera
    OwnerAuthor

    Delivered in #4183 (squash 2158875). LoginScreen now starts conditional UI only when the methods report a password, and so only when the webauthn autofill field renders. A passkey-only screen spends no login-options token, leaves no challenge and logs no warning, and its "Sign in with a passkey" button works as before. A render test counts the login-options calls. A real-Chrome runtime test with a CDP virtual authenticator (packages/ui-react/tests/passkey-login-runtime.test.ts) proves the passkey-only case and the button sign-in. It also proves that beside a password field, the field's autofill signs in with the passkey after one login-options request. The PR records the gate mutation failing on the request-count assertion. #2556 must keep this gate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

agent-readyarea: ui-reactpriority: p1type: fix

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions