Sunil Mohan Adapa 9d6c74c887
users: Add support for logging in with passkeys
Tests:

- Login
  - Login using passkeys works on testing container and stable container.
  - Login page show 'Log in with passkey' button as expected along with key
    icon.
  - On GNOME's Web browser, the login page does not show an error on load.
    Clicking on 'Log in with passkey' shows the error: 'Logging in with passkey
    failed: Browser does not support passkeys.'
  - On Chromium browser, with invalid TLS certficiate, the login page does not
    show an error on load. Clicking on 'Log in with passkey' shows the error:
    'Logging in with passkey failed: NotAllowedError: WebAuthn is not supported
    on sites with TLS certificate errors.'
  - Raising an error in the passkey_login_begin() method shows the error message
    when login page is loaded. Raising an error in the passkey_login_complete
    method shows the error message after passkey is unlocked. In both cases, 500
    is HTTP status code.
  - With primary hardware key register passkey each for 'tester' and 'tester2'
    accounts.
  - With secondary hardware key register passkey for 'tester' account.
  - In login page, loading the page shows the console message 'Signing in with a
    passkey. Condition: true'.
  - In login page, when username field is clicked, 'passkey' is shown in the
    autofill popup options. Selecting it prompts for hardware PIN and touch.
    User is logged in.
  - In login page, when 'Log in with passkey' is clicked, console message is
    show 'Log in initiated with button, conditional mediation aborted.'.
    Hardware PIN and touch is prompted. User is logged in.
  - During autofill login, canceling the hardware key PIN shows no error alert.
    Autofill passkey login is not available.
  - During autofill login, canceling the hardware touch prompt shows no error
    alert. Autofill passkey login is not available.
  - During button login, canceling the hardware key PIN shows '...user denied
    permission' error alert. Autofill passkey login is not available.
  - During button login, canceling the hardware touch prompt shows no '...user
    denied permission' error alert. Autofill passkey login is not available.
  - When multiple attempts fail, multiple error alerts are shown.
  - During login, with primary key account selection dialog is shown. Selecting
    'tester' logs into 'tester' account. Selecting 'tester2' logs into 'tester2'
    account.
  - During login, with secondary key, account selection dialog is not shown.
    User is logged into the 'tester' account.
  - Password based login continues to work as usual on Firefox, Chromium, and
    GNOME's web.
  - Logout, then visit /freedombox/sys/. This redirects to login page. After
    login with passkey the browser is redirected to /freedombox/sys page.
  - After passkey login, 'Last Used' for that key is updated. The value is not
    updated for remaining keys of the account.
  - After successful login, database is updated with the latest signature
    counter.
  - After successful login, for a user account with Spanish set as language, the
    UI language changes to Spanish.
  - If a key has been removed from list of passkeys and that passkey is
    attempted for login, 'Passkey used is not known' error alert is shown.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2026-03-31 07:48:54 -04:00
..