Skip to content

feat(passkey): add a setting to turn passkeys off (#345) - #347

Open
camarigor wants to merge 8 commits into
ZL154:mainfrom
camarigor:feat/passkeys-enabled-setting
Open

camarigor wants to merge 8 commits into
ZL154:mainfrom
camarigor:feat/passkeys-enabled-setting

Conversation

@camarigor

@camarigor camarigor commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

I added Allow passkeys (PasskeysEnabled), on by default, so an administrator can turn passkeys off for the whole server, for example to keep the authenticator app as the only second factor. While it is off, the server refuses every passkey ceremony, a saved passkey stops counting as a factor, and the login, Setup and admin pages stop offering passkeys. Saved passkeys and each user's #343 choice are kept, so turning the setting back on restores them. Turning it off is refused while some user relies on a passkey for their second factor, and the settings page names those users.

Type of change

  • New feature (non-breaking)

Related issues

Closes #345

The issue offered two ways to handle an account whose only second factor is a passkey, and I went with the first: the save that would turn passkeys off is refused while such accounts exist, and the settings page lists them. That way off means off for everyone, with no account keeping a passkey that the server refuses for everybody else, and nobody loses a second factor without the administrator seeing their name first.

What changes

Setting. PasskeysEnabled sits next to EmailOtpEnabled and defaults to true, so a configuration written by an earlier version (XML or JSON without the field) reads as on and nothing changes on upgrade. Exports carry it. GET /TwoFactorAuth/public-config reports it as passkeysEnabled for the pages; hideBuiltInPasskeyButton keeps meaning only that the login button is hidden.

Refused ceremonies. While it is off, eight endpoints answer HTTP 400 with {"message": "Passkeys are disabled on this server."} before they read user state, start or consume a ceremony, count toward a rate limit or a failed attempt, or write an audit entry: Passkeys/RegisterBegin and Passkeys/RegisterFinish, Passkey/LoginBegin and Passkey/LoginComplete (passwordless sign-in, with or without a username), Verify/Passkey/Begin and Verify/Passkey/Finish (the challenge), and StepUp/UserPasskeyBegin and StepUp/UserPasskeyVerify (the step-up prompt on the Setup page and in the admin modal). A sign-in bridge token minted by a passkey sign-in is refused too. Listing and removing saved passkeys, their diagnostics and the #343 preference keep working, so users can clean up.

Stored passkeys stop counting. While it is off, a saved passkey no longer makes password sign-in ask for a second factor, cannot answer the challenge, no longer counts as an existing factor for the hardened self-service gate or for creating app passwords, and is left out of the security score, the enrollment statistics and the dashboard coverage. With passkeys off, the provider, the middleware and the portal build the challenge from one shared inventory: a verified authenticator app, unused recovery codes, and email codes when email OTP is on and the account has an address or a linked Telegram chat. A linked SSO provider alone cannot answer a local challenge, so it does not count. While passkeys are on, each sign-in entry point keeps exactly the offers it had before this setting existed; the shared inventory is used only while they are off.

Refused turn-off. Only a change from on to off is checked, with the settings the same save would apply. A user with a saved passkey relies on it when any of these holds: nothing in that inventory is left to answer their challenge; their passkey choice was the only reason password sign-in asked for a second factor (no enforcement scope covers them and they have no authenticator app; an email or recovery code can answer the challenge but never makes it required); or the passkey was their only self-service factor, so the step-up would stop asking for proof before a change. Each test is the plugin's own rule: the challenge inventory, the sign-in challenge policy with the user's administrator status, and the self-service factor list. While any user relies on a passkey, the save is refused with HTTP 409 and {"message": ..., "users": [{"id": ..., "name": ...}]}, sorted by name, and nothing in that save is applied. Users deleted from Jellyfin are not counted. The check runs on the exact configuration object Jellyfin deserialized, after the existing step-up filter (which still answers first with its 403) and before secrets are restored or anything is saved. A configuration import that would turn passkeys off is refused the same way before any write, with its existing HTTP 400 shape and the same text, and a full import is checked against the user records it would write.

Emergency lockout. I lost my phone still turns the #343 choice back on from the stored passkeys, whatever the setting says, as it does since #343. That only adds protection, and it keeps an opted out passkey from skipping the challenge if passkeys are turned back on later.

Pages.

  • Admin settings: an Allow passkeys checkbox next to the email code option, with a short help text. A refused save shows a message under Save Settings, built by the page in the admin's language: nothing was saved, these users rely on a passkey for their second factor, and the two ways out (have them add an authenticator app while passkeys still work, or use Reset 2FA (full wipe) in the Users tab). The names go in as text, the form stays as the admin left it (no reload, no checkbox put back), and the hardening fields wait for a save that goes through. A refused save also no longer ends in an uncaught promise rejection. The help text of Hide the "Sign in with passkey" button now says that passkeys stay usable and points to the new setting.
  • Admin step-up modal: it offers the passkey only when the admin has one saved and passkeys are allowed, and reads that again after a save that succeeds, so changing the setting changes the modal without a reload.
  • Login page: no Sign in with passkey button while passkeys are off.
  • Setup page: while passkeys are off there is no way to add a passkey, no feat(auth): let users choose whether a passkey adds a second factor to password sign-in (#339) #343 switch, and the step-up prompt does not offer a passkey. Saved passkeys stay listed, each with its Remove button, under a note saying they are kept but cannot be used; with none saved the card is hidden. The authenticator card stops suggesting a passkey.
  • Challenge page: unchanged. It offers the passkey only when the server lists it for the challenge, which the server no longer does while passkeys are off; a new test pins that.
  • The new strings are in all eight bundles. A missing passkeysEnabled (an older server, or public-config not read) reads as on, and the server refuses passkeys while they are off whatever a page shows.

README. A Turning passkeys off subsection under Settings, with a pointer from the Passkeys section and from the section on hiding the login buttons.

How was this tested?

  • Added or updated unit tests
  • Added or updated integration tests
  • Tested manually against a running Jellyfin server (state version)

Server tested against: none, I did not run a Jellyfin server for this PR.
Clients tested with: none against a server; I looked at the admin and Setup pages in headless Chrome against a local stub of the plugin API, and I did not use a hardware authenticator.

C#: I added tests for the missing field and the XML and JSON round trips, 192 combinations of the factor policy inputs, all eight refused endpoints (no counter, nonce or record change), saved passkey removal and the #343 preference while off, the refused passkey bridge token, status and coverage, the shared inventory and the unchanged offers of each entry point while passkeys are on, and the emergency rearm while off. The save tests go through the real MVC pipeline, the step-up filter and the plugin's update override with Jellyfin's own JSON options, and cover the sorted 409 body, the alternative factor matrix, users whose passkey is the only reason for the challenge (by enforcement scope and administrator status) or their only self-service factor, the email setting changed in the same save, allowed transitions, deleted users and the step-up ordering; the import tests cover both forms, the no-write refusal and full import user records. Before each change I ran the new tests against the previous code and saw them fail. Afterwards I removed the key lines (the enabled check in the passkey rule, the eight early refusals and the bridge refusal, the save guard, the import guard, the use of the incoming configuration, each of the two turn-off conditions for the challenge reason and the self-service factor, the compatibility branch for the enabled state, the emergency rearm) and saw the targeted tests fail again.

Pages: the Node tests run the pages' own code against a stubbed fetch and DOM. tests/passkeys-disabled-admin-page.test.mjs loads the whole admin script over a stand-in DOM and server: the checkbox from a true, false or missing field, the saved value, the 409 rendering (names as text, never markup, in the page language, no configuration reload, checkbox unchanged, nothing else saved), a 409 without users, other failures, and the step-up modal with and without passkeys allowed, including a save that changes the setting. tests/passkeys-disabled-setup-page.test.mjs covers the Passkeys card with and without saved passkeys while off, the removal of the last one, the #343 switch, the step-up prompt and the authenticator card. tests/login-button.test.mjs now covers the passkey button with the field true, false and missing, and tests/passkey-challenge.test.mjs the challenge page offer. Both new files are in ci.yml, and each new string is checked in all eight bundles. The new admin and Setup tests failed on the unchanged pages, and so did the login test for the off state. I then removed the key lines one at a time (the login button condition, the Setup registration gate, its step-up and switch gates, the hidden card, the refusal written as text, the users branch of the refusal, the no-reload rule, the modal cache refresh and its passkey condition) and each change made the targeted tests fail.

Local checks on the final head, with the .NET 9.0.316 SDK pinned:

  • locked restore and Release build of the solution: 0 warnings, 0 errors;
  • whole C# suite: 1,459 passed, 0 failed, 0 skipped (1,211 on main);
  • every node test file listed in ci.yml: 170 passed, 0 failed (143 on main);
  • Jellyfin 12 (net10, .NET 10.0.400 SDK): locked restore and Release build of the plugin, 0 warnings, 0 errors, with a lock file resolved from the project in a scratch folder;
  • no lock file in the repository changed.

Checklist

  • My code follows the existing style
  • I've added comments only where the why isn't obvious from the code
  • I've updated the README / SECURITY.md / docs if behaviour or config changed
  • I've considered backwards compatibility (config migration, file formats, on-disk state)
  • I've checked the security implications (auth bypass, secret handling, input validation)
  • Local equivalents of the CI build and tests pass (dotnet build + dotnet test green)

Screenshots / log slices

SDK for solution checks: 9.0.316
Release solution build: 0 warnings, 0 errors
C# tests: 1,459 passed, 0 failed, 0 skipped
Node tests: 170 passed, 0 failed
SDK for Jellyfin 12: 10.0.400
Jellyfin 12 Release build: 0 warnings, 0 errors
Repository lock files: unchanged

Additional notes

  • A step-up proof issued before the switch keeps working until it is used or expires: it is single use, bound to its user and lives 60 seconds. Its origin is not recorded, so a proof minted with a passkey just before passkeys were turned off can still be redeemed, including in the admin step-up, and that can open an admin verified window, which keeps its configured lifetime (300 seconds by default, 60 to 900). Sessions that are already signed in stay signed in. Recording the origin of step-up proofs would close that window, but it touches every step-up path (code, passkey, OIDC, admin and self-service) for a window of seconds that only exists while an administrator turns passkeys off, so I left it for a separate change.
  • The turn-off check reads the stored state when the configuration is applied. A passkey ceremony already in progress at that moment is not cancelled, but every passkey endpoint checks the setting when it is called.
  • While passkeys are on, the provider, the middleware and the portal keep some small differences between their offers that predate this PR. I kept them on purpose, so enabling the setting changes nothing; they could be aligned separately.
  • The Fido2 bumps (deps: Bump the fido2 group with 1 update #336, deps(fuzz): Bump Fido2 from 4.2.0 to 4.3.2 #337, deps(tests): Bump Fido2 from 4.2.0 to 4.3.1 #282) touch only package and lock files and do not overlap this PR's files. While passkeys are off the refusal happens before any Fido2 call, but a Fido2 bump should still rerun the passkey ceremony tests.

The full verification logs (the last run on this head, each new test failing against the code before its change, and the mutation runs) are in this secret gist: https://gist.github.com/camarigor/923cd82c97c0ece7e7d94508b5f183bc. I can test further changes.

Keep existing installations enabled by default and make the sign-in policy and self-service factor decisions honor the server setting without changing stored credentials.

Refs ZL154#345
Refuse passkey ceremonies before side effects, reject passkey sign-in bridge tokens, and share the effective challenge inventory across the provider, middleware and portal. Keep saved credentials visible for removal while reporting effective coverage and self-service eligibility.

Refs ZL154#345
Check the exact configuration Jellyfin is about to save after the step-up gate and return a conflict listing users who still depend on passkeys. Reuse the challenge inventory for imports and inspect full-import replacement records before writing either configuration or user data.

Refs ZL154#345
Keep each existing sign-in entry point compatible with the enabled default. Use the shared usable-method inventory only for the new disabled state and its turn-off guard, so upgrading does not normalize unrelated legacy challenge behavior.

Refs ZL154#345
EmergencyLockout rearms PasskeyRequiresSecondFactor again from the
stored credentials, as ZL154#343 did. Rearming only adds protection; tying it
to the new switch left an opted-out passkey in place during an emergency
taken while passkeys were off, and that passkey would skip the challenge
once they were turned back on.

Rename PasskeyPolicy.HasEnrolled to HasUsable: it returns false for a
user with enrolled passkeys while the server has them off, so the old
name misled exactly where the distinction matters.

Document PasskeysEnabled, point HideBuiltInPasskeyButton to it, comment
the public-config field, say when SignInFactors uses the shared
inventory, and fix the whitespace of the new test files.

Refs ZL154#345
…in pages

The server refuses passkeys while PasskeysEnabled is off, so the pages
stop offering them. inject.js leaves out the passkey sign-in button. The
Setup page drops the registration controls, the ZL154#343 switch and the
passkey option of its step-up prompt, and keeps saved passkeys listed
with a notice so users can still remove them. The admin page gets the
"Allow passkeys" setting next to email codes, offers the passkey in its
step-up modal only while passkeys are allowed, and reads that again
after a save.

A save the server refuses with 409, because some users would be left
without another way to verify their sign-in, now names those users as
text in the page language and leaves the form as the admin left it. A
refused save no longer ends in an uncaught promise rejection.

The challenge page needs no change: it offers the passkey only when the
server lists it, which a new test pins. New strings in all eight
bundles, Node tests for each page, and the two new test files in CI.

Refs ZL154#345
Explain what turning passkeys off does on the server and on the pages,
why turning it off is refused while a user depends on a passkey, the
two ways out, and how it differs from hiding the passkey button. Point
to it from the passkey section and from the hide-buttons section.

Refs ZL154#345
@camarigor camarigor mentioned this pull request Nov 7, 2026
2 tasks done
The turn-off guard only looked for users with nothing left to answer the
sign-in challenge. Two other ways the switch could quietly drop a second
factor slipped through:

- an email or recovery code answers the challenge but never makes it
  required, so a user whose passkey choice was the only reason password
  sign-in asked for a second factor would be left with the password alone;
- a recovery code or a Telegram chat answers the challenge but is not a
  self-service factor, so the Setup page step-up would stop asking for
  proof.

The guard now lists a user with stored passkeys when any of the three
holds, through the challenge inventory, the sign-in challenge policy
(with the user's administrator status for the enforcement scope) and the
self-service factor list as they are. The refusal, the settings help text
and the README now say that these users rely on a passkey for their
second factor.

Also drop a needless cast and simplify an assertion in the save tests.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feat] A setting to turn passkeys off

2 participants