↑↓ to navigate Enter to open "…" all these words ANDOR to combine

Architecture Decision Record

ADR-139: Passkeys (WebAuthn) as an Opt-In Sign-In and Second Factor

Status

Accepted (2026-11-08). Ships in MMCA.Common v1.281.0 as a new package, MMCA.Common.Passkeys (the package list and count are owned by MMCA.Common/FACTS.md). Off unless the host calls AddPasskeys and sets Passkeys:Enabled (MMCA.Common/Source/Core/MMCA.Common.Application/Auth/Passkeys/PasskeySettings.cs:24-25, default false). Amended 2026-11-12: MMCA.ADC is the first consumer to carry the code path, switched off in production (see Consequences). Revised 2026-11-23: a passkey sign-in mints through the private IssueTokensCoreAsync (the issuance choke point), not the protected IssueTokensAsync wrapper that now runs a second-factor challenge first; Fido2 is at 4.3.3; anchors refreshed.

Context

A password plus a TOTP code is phishable: a convincing proxy page collects both and replays them within the code's window. The only passwordless path the framework offered was the emailed sign-in link (ADR-116, item 14), which is as strong as the mailbox. Nothing in MMCA.Common spoke WebAuthn.

Five forces shaped the decision:

  • The token path already has one choke point. Every interactive sign-in mints through the private AuthenticationServiceBase.IssueTokensCoreAsync, which refuses a service account and hands off to AuthSessionIssuer.IssueAsync (MMCA.Common/Source/Core/MMCA.Common.Application/Auth/AuthenticationServiceBase.cs:725-743), which opens a refresh session (ADR-097). The framework's own sign-ins call it directly (AuthenticationServiceBase.cs:281, :397, :585, :626); an app-level sign-in goes through the protected IssueTokensAsync wrapper, which runs the second-factor challenge first (AuthenticationServiceBase.cs:691-713). A new app-level sign-in method that mints through IssueTokensAsync (and so reaches IssueTokensCoreAsync) inherits sessions, sign-in history and revocation with no second path.
  • The second-factor claim already exists. mfa is an amr-style claim whose presence is the assertion and whose value names the method (otp, recovery; MMCA.Common/Source/Core/MMCA.Common.Shared/Auth/AuthClaimTypes.cs:49-69), and a refresh carries it over (AuthenticationServiceBase.cs:445-450).
  • WebAuthn verification is security-critical parsing. Attestation and assertion verification means CBOR, COSE keys, signature formats and origin binding. The maintained .NET library for it, Fido2NetLib, pulls NSec.Cryptography and the native libsodium.
  • Native code stays out of the core. ADR-134 keeps third-party SDKs in adapter packages a host opts into, and every consumer references Infrastructure, so a dependency there ships in every host whether or not it uses passkeys.
  • Common has no user entity. The user row is the app's (ADR-116), so a credential table owned by the framework has to key on the user id alone and ask the app whatever it needs to know about the account.

Decision

Passkeys are a framework opt-in: WebAuthn verification lives in its own package, credentials in a gated framework table, and a passkey sign-in mints the normal token pair with mfa=passkey. Registering a passkey needs an interactive sign-in under ten minutes old, judged by a new auth_time claim. Web heads only.

  1. One package holds the WebAuthn library, behind a core contract. MMCA.Common.Passkeys references Application and the Fido2 package and nothing else (MMCA.Common/Source/Core/MMCA.Common.Passkeys/MMCA.Common.Passkeys.csproj:7-13), at 4.3.3 (MMCA.Common/Directory.Packages.props:153; the comment at :148-152 states why it is kept to one reviewed version and inside this package). The CPM entry is a bare version, which NuGet reads as a floor ([4.3.3, )); what holds it to 4.3.3 is the committed lock file (MMCA.Common/Source/Core/MMCA.Common.Passkeys/packages.lock.json:7-8) restored with --locked-mode in CI (MMCA.Common/.github/workflows/ci.yml:146). It supplies the internal Fido2PasskeyCeremony behind the core IPasskeyCeremony (MMCA.Common/Source/Core/MMCA.Common.Passkeys/Fido2PasskeyCeremony.cs:17). Two gates keep the boundary true:
    • Build time. EnforcePasskeysBoundary fails any other MMCA.Common.* project that references MMCA.Common.Passkeys or declares a Fido2, NSec or libsodium package reference (MMCA.Common/Source/Build/MMCA.Common.LayerEnforcement.targets:157-180).
    • Test time. PasskeysIsolationTests asserts that no core layer, nor Aspire, the testing packages or the MCP package, names a type from MMCA.Common.Passkeys, Fido2NetLib or NSec, or references an assembly with those prefixes or libsodium (MMCA.Common/Tests/Architecture/MMCA.Common.Architecture.Tests/Passkeys/PasskeysIsolationTests.cs:14-25, :29-50).
  2. One call registers it. services.AddPasskeys(configuration) binds the Passkeys section with ValidateOnStart and a validator that names a missing key, and registers the ceremony, the challenge store and IPasskeyService (MMCA.Common/Source/Core/MMCA.Common.Passkeys/PasskeysServiceCollectionExtensions.cs:37-56). The section carries Enabled, RelyingPartyId, RelyingPartyName, Origins and DataSourceName (PasskeySettings.cs:24-46).
  3. A startup tripwire catches the silent half-configuration. Passkeys:Enabled true with no IPasskeyCeremony registered fails startup naming the package and the call (MMCA.Common/Source/Core/MMCA.Common.Infrastructure/Configuration/CloudAdapterTripwire.cs:42, :64-69), the same check native push already had, because without it every passkey route would answer 404 and nothing would say why.
  4. Credentials live in a gated, hard-deleted framework table. PasskeyCredential is flat bookkeeping beside RefreshSession: no audit stamps, no soft-delete flag, deleted outright (MMCA.Common/Source/Core/MMCA.Common.Domain/Auth/PasskeyCredential.cs:8-14); the EF store removes the row (MMCA.Common/Source/Core/MMCA.Common.Infrastructure/Persistence/Auth/EFPasskeyCredentialStore.cs:74-78). Nothing in the row is secret (PasskeyCredential.cs:15-18). PasskeyCredentials is mapped only while Passkeys:Enabled is true and only on the source Passkeys:DataSourceName names (MMCA.Common/Source/Core/MMCA.Common.Infrastructure/Persistence/DbContexts/ApplicationDbContext.cs:588-592, :1113-1118), the view-as grants shape; DesignTimeDbContextOptions.EnablePasskeys opens the same gate for dotnet ef (MMCA.Common/Source/Core/MMCA.Common.Infrastructure/Persistence/DbContexts/Design/DesignTimeDbContextOptions.cs:129).
  5. Challenges are single-use, five minutes, in the shared store. PasskeyChallenges.IssueAsync stores the issued options under a random 32-hex flow id for Lifetime (5 minutes), and RedeemAsync reads and burns the entry inside lock:passkeys:challenge:{flowId}, reading the shared store so a flow burned on one replica misses on every other (MMCA.Common/Source/Core/MMCA.Common.Application/Auth/Passkeys/PasskeyChallenges.cs:24, :38-47, :56-83), the OAuth exchange-code pattern (ADR-036).
  6. The signature counter must advance. PasskeyCredential.IsSignCountAcceptable admits a counter above the stored one, or zero on both sides (an authenticator that does not count, which synced passkeys are); anything else is a cloned key and RecordUse refuses it (PasskeyCredential.cs:114-146). PasskeyService applies the rule itself as well as through the library, so it does not depend on the library's own check (MMCA.Common/Source/Core/MMCA.Common.Application/Auth/Passkeys/PasskeyService.cs:264-271).
  7. A passkey sign-in is a normal sign-in with mfa=passkey. AuthenticationServiceBase.SignInWithPasskeyAsync runs the app's login-candidate check, sets the method to AuthClaimTypes.MultiFactorMethodPasskey and mints through IssueTokensCoreAsync (AuthenticationServiceBase.cs:603-632, candidate check :617-621, method :623, mint :626; AuthClaimTypes.cs:71-76), so the token pair, the refresh session and the sign-in history are the ones every other sign-in produces. A passkey is possession plus the authenticator's own user verification, so it satisfies the second factor itself, which is why it skips the second-factor challenge IssueTokensAsync would run (AuthenticationServiceBase.cs:596-600). Failures answer one vague AssertionFailed to the caller and log the specific reason as a Warning with no key material (PasskeyService.cs:18-24, :277-281).
  8. Registration needs a recent interactive sign-in, judged by auth_time. Every interactive sign-in that opens a session stamps auth_time (Unix seconds), and a refresh carries it UNCHANGED (AuthClaimTypes.cs:98-111; AuthenticationServiceBase.cs:452-455; MMCA.Common/Source/Core/MMCA.Common.Application/Auth/Sessions/AuthSessionIssuer.cs:173-190). PasskeyStepUp.IsSatisfiedBy admits a caller whose auth_time is at most MaxSignInAge (10 minutes) old; a token with no auth_time never qualifies (MMCA.Common/Source/Core/MMCA.Common.Application/Auth/Passkeys/PasskeyStepUp.cs:6-30). Both registration actions check it (MMCA.Common/Source/Presentation/MMCA.Common.API/Controllers/Passkeys/PasskeysControllerBase.cs:81, :132). This is stricter than "a token under 10 minutes old, or one that carries mfa": both of those ride every refresh (a refresh resets iat and carries mfa over), so either would let a stolen refresh token keep a session fresh enough to plant its own passkey indefinitely (PasskeyStepUp.cs:10-15).
  9. The controller base. PasskeysControllerBase (abstract; the app routes it at auth/passkeys) serves register/options and register for a signed-in caller, GET, PATCH {id} and DELETE {id}, and anonymous signin/options and signin on the auth-ip rate-limit policy with discoverable credentials (PasskeysControllerBase.cs:41, :62-64, :110-112, :144-145, :170-171, :204-205, :229-232, :254-257). Every action answers 404 while passkeys are disabled (:54). The last passkey can be deleted only while the account still has a password or an external login, under a per-account lock so two concurrent deletes cannot both see "one more remains" (PasskeyService.cs:153-179; PasskeyChallenges.cs:92-94); the app answers the external half by overriding HasExternalLoginAsync, which HasSignInMethodBesidesPasskeysAsync asks (AuthenticationServiceBase.cs:640-652; the virtual at :654-664, default false).
  10. One more token-issuing proxy path. auth/passkeys/signin joins the same-origin proxy's default token-issuing paths (MMCA.Common/Source/Presentation/MMCA.Common.UI.Web/SameOriginProxy/SameOriginApiProxySettings.cs:33, ADR-131).
  11. Web only. IPasskeyCapability defaults to UnavailablePasskeyCapability, so a MAUI head hides the passkey button and the add-passkey action; AddBrowserDeviceCapabilities swaps in the browser implementation over passkeys.js (MMCA.Common/Source/Presentation/MMCA.Common.UI/Services/Capabilities/DependencyInjection.cs:60, :119). The login page offers passkeys only when SignIn:OfferPasskeys is true, the capability is available and an IPasskeyUIService is registered (MMCA.Common/Source/Presentation/MMCA.Common.UI/Pages/Auth/Login.razor.cs:196-203), and browser autofill asks for a challenge only where conditional mediation is available (MMCA.Common/Source/Presentation/MMCA.Common.UI/wwwroot/passkeys.js:137-143).
  12. Service accounts never sign in with a passkey. SignInWithPasskeyAsync treats an account whose IAuthUser.IsServiceAccount is true as vanished (AuthenticationServiceBase.cs:609-615; ADR-140).

Rationale

  • A library over hand-rolled verification. The parsing is where WebAuthn implementations fail, and a maintained library with its own conformance work is the cheaper and safer owner of it.
  • A separate package keeps native code where ADR-134 puts vendor code. A host that does not reference MMCA.Common.Passkeys restores no Fido2, NSec or libsodium, and the core layers stay free of a native dependency; the two gates make that a build failure rather than a review comment.
  • The existing choke point and claim. Minting through IssueTokensCoreAsync with a new mfa value means sessions, sign-in history, revocation and every IRequiresMfa use case treat a passkey sign-in correctly with no change.
  • auth_time measures the thing that matters. "Recently signed in" is a property of the sign-in, not of the access token; the claim that survives a refresh unchanged is the only one that cannot be kept fresh by refreshing.
  • Hard delete matches the meaning. A removed passkey must never sign in again; a soft-deleted row is one query-filter mistake from doing so, and the row is a public key, not an audit record.

Trade-offs

  • A new third-party dependency in the auth path, with a native library behind it. Mitigated by the committed lock file restored in locked mode (decision 1), the package boundary and the fact that a host opts in by reference.
  • Passkeys are bound to the relying party id. A credential registered under one Passkeys:RelyingPartyId is never offered for another, so a later domain change orphans every passkey (PasskeySettings.cs:13-17). The production domain has to be settled before the feature is turned on.
  • One gated table migration where enabled, on the Identity database only.
  • Login protection does not meter passkey failures by account. Login protection is keyed by email, which a discoverable sign-in does not carry before the assertion, so failures are metered per IP by the auth-ip policy and logged as Warnings instead (PasskeyService.cs:19-24).
  • A token minted before the claim shipped cannot register a passkey until its holder signs in again, because it has no auth_time.
  • An app with external logins must override HasExternalLoginAsync, or the last-passkey rule ignores the external login and refuses a delete it could allow.

Alternatives rejected

  • Writing CBOR/COSE attestation and assertion verification ourselves (2026-11-08). A security-critical parser for no gain over a maintained library.
  • ASP.NET Core Identity's passkey support (2026-11-08). It is built on Identity's UserManager and stores, which MMCA.Common does not use; the user row is the app's.
  • Fido2NetLib inside MMCA.Common.Infrastructure (2026-11-08). Every host references Infrastructure, so every host would carry NSec and the native libsodium whether it offers passkeys or not.
  • Judging registration by token age, or by the presence of mfa (2026-11-08). Both survive a refresh, so a stolen refresh token could keep either satisfied forever; auth_time cannot be refreshed.
  • A sign-in method column on RefreshSession (2026-11-08). It would be a migration in every consumer's Identity database for a fact the token's mfa value already carries.
  • MAUI native passkeys now (2026-11-08). Credential Manager on Android, associated domains on iOS and asset links for a need no user has raised. Recorded in the Enterprise-scale register of the Common backlog. Revisit: mobile users asking for passkeys, or a store-review requirement.

Consequences

  • A host opts in by referencing MMCA.Common.Passkeys from its Identity service, calling AddPasskeys, setting Passkeys:Enabled, Passkeys:RelyingPartyId and Passkeys:Origins, adding the PasskeyCredentials migration with EnablePasskeys, routing a PasskeysControllerBase subclass, setting SignIn:OfferPasskeys and placing PasskeysPanel on the profile page (MMCA.Common/UPGRADING.md:544-560).
  • MMCA.ADC is the first consumer to carry the code path, and carries it switched OFF in production. Its Identity service references the package (MMCA.ADC/Source/Services/MMCA.ADC.Identity.Service/MMCA.ADC.Identity.Service.csproj:34) and calls AddPasskeys (MMCA.ADC/Source/Services/MMCA.ADC.Identity.Service/Program.cs:190-194), but its base appsettings.json sets Passkeys:Enabled false (MMCA.ADC/Source/Services/MMCA.ADC.Identity.Service/appsettings.json:133-134). Only the service's appsettings.Development.json (:33-34 of that file) and the AppHost (MMCA.ADC/Source/Hosting/MMCA.ADC.AppHost/Program.cs:483-484) turn it on, and no file under MMCA.ADC/infra/ sets Passkeys or SignIn:OfferPasskeys, so in production every passkey route answers 404 (PasskeysControllerBase.cs:53-54, :71-73). SignIn:OfferPasskeys is true only in the web head's Development settings (MMCA.ADC/Source/Hosts/UI/MMCA.ADC.UI.Web/appsettings.Development.json:13) and through the AppHost (MMCA.ADC/Source/Hosting/MMCA.ADC.AppHost/Program.cs:486). The base web-head settings state it as false so the client config always carries it (MMCA.ADC/Source/Hosts/UI/MMCA.ADC.UI.Web/appsettings.json:48-54), and the framework client-config endpoint forwards the SignIn section to the browser with no ADC line (MMCA.ADC/Source/Hosts/UI/MMCA.ADC.UI.Web/Program.cs:117-124; :128 on net11.0, :130-134 on the gated net10.0 line), so the framework login page's passkey button and ADC's profile Passkeys card (MMCA.ADC/Source/Modules/Identity/MMCA.ADC.Identity.UI/Pages/Users/Profile/Profile.razor:110) never render where it is false; the login button also needs an available passkey capability and a registered passkey UI service (Login.razor.cs:196-203). The controller is a sealed PasskeysControllerBase subclass routed at auth/passkeys (MMCA.ADC/Source/Modules/Identity/MMCA.ADC.Identity.API/Controllers/Passkeys/PasskeysController.cs:19-21). The AddPasskeyCredentials migration creates the one PasskeyCredentials table with a unique index on CredentialId and an index on UserId (MMCA.ADC/Source/Hosting/MMCA.ADC.Migrations.SqlServer.Identity/Migrations/20261112192534_AddPasskeyCredentials.cs:14-45), so once the migration runs the table exists, unused, while the switch is off (Program.cs:190-193 of the Identity service). ADC also overrides HasExternalLoginAsync. Turning passkeys on in production waits on a decision about ADC's production domain, because a passkey is bound to the relying-party id (appsettings.json:129-130 of the Identity service; recorded in the ADC backlog). Store and Helpdesk leave it off.
  • MMCA.Common/FACTS.md lists the new package.

Revision (2026-11-23)

Re-verified against current source. The package boundary, the gated hard-deleted table, the single-use challenges, the signature-counter rule, mfa=passkey, the auth_time step-up, the controller base, web-only capability and ADC's switched-off adoption are unchanged. What moved is the name of the issuance choke point, the Fido2 version and most anchors.

  1. The choke point is IssueTokensCoreAsync. IssueTokensAsync is now a protected wrapper that runs a second-factor challenge with no code before issuing (MMCA.Common/Source/Core/MMCA.Common.Application/Auth/AuthenticationServiceBase.cs:691-713); the issuance itself is the private IssueTokensCoreAsync, which refuses a service account and calls AuthSessionIssuer.IssueAsync (AuthenticationServiceBase.cs:725-743). The framework's own sign-ins call it directly (:281, :397, :585), and so does SignInWithPasskeyAsync (:626), so a passkey sign-in deliberately skips the second-factor challenge (:596-600). Context, decision 7 and Rationale now name it.
  2. Fido2 is at 4.3.3 (MMCA.Common/Directory.Packages.props:153). The entry is a bare CPM version (a floor, [4.3.3, ) in MMCA.Common/Source/Core/MMCA.Common.Passkeys/packages.lock.json:7), held to one version by the lock file and the CI --locked-mode restore (MMCA.Common/.github/workflows/ci.yml:146); decision 1 and Trade-offs say so.
  3. The login gate names its third condition. OffersPasskeys() also requires a registered IPasskeyUIService (MMCA.Common/Source/Presentation/MMCA.Common.UI/Pages/Auth/Login.razor.cs:200-203); decision 11 now states it, as Consequences already did.
  4. The web head forwards SignIn through the framework. ADC's web head has no line of its own for OfferPasskeys: the framework client-config endpoint forwards the host's SignIn section (MMCA.ADC/Source/Hosts/UI/MMCA.ADC.UI.Web/Program.cs:117-124; :128 on net11.0, :130-134 on net10.0), and the base appsettings.json states it as false (MMCA.ADC/Source/Hosts/UI/MMCA.ADC.UI.Web/appsettings.json:54).
  5. Anchors re-verified against current source: AuthenticationServiceBase.cs:445-450 (mfa carried on refresh), :452-455 (auth_time carried), :603-632 (SignInWithPasskeyAsync), :609-615 (service account as vanished), :640-652 and :654-664 (HasExternalLoginAsync); AuthClaimTypes.cs:98-111 (AuthTime); ApplicationDbContext.cs:588-592, :1113-1118; MMCA.Common.UI/Services/Capabilities/DependencyInjection.cs:60, :119; Login.razor.cs:196-203; MMCA.Common/UPGRADING.md:544-560; MMCA.ADC.Identity.Service.csproj:34; the Identity service's Program.cs:190-194; MMCA.ADC.AppHost/Program.cs:483-484, :486.

ADR-036 (the exchange-code burn the challenge store copies), ADR-050 (the rotation that carries mfa and auth_time), ADR-097 (the sessions a passkey sign-in opens), ADR-116 (the opt-in shape and the second factor this complements), ADR-131 (the token-issuing proxy list), ADR-134 (the adapter-package shape), ADR-140 (the service accounts this refuses).