What passkey support does ASP.NET Core Identity add in .NET 10, and what must an existing Identity app change to store and use passkeys?
answer
- new in ASP.NET Core 10
- SignInManager makes options, then performs
- UserManager.AddOrUpdatePasskeyAsync stores
- IdentitySchemaVersions.Version3 adds AspNetUserPasskeys
- IdentityPasskeyOptions.ServerDomain
basics
~20 sASP.NET Core 10 Identity adds passkey registration and sign-in through SignInManager and UserManager. An existing app must set Stores.SchemaVersion to IdentitySchemaVersions.Version3, migrate to get the AspNetUserPasskeys table, and build its own passkey pages and endpoints.
solid answer
~30 sIn ASP.NET Core 10, `SignInManager<TUser>` gains `MakePasskeyCreationOptionsAsync(PasskeyUserEntity)` and `PerformPasskeyAttestationAsync(credentialJson)` for registration, `MakePasskeyRequestOptionsAsync(user)` for sign-in options, and `PasskeySignInAsync(credentialJson)`, which returns a `SignInResult` and issues the usual cookie. `UserManager.AddOrUpdatePasskeyAsync(user, passkey)` and `GetPasskeysAsync` persist credentials through `IUserPasskeyStore<TUser>`. The EF Core store only models the `AspNetUserPasskeys` table when `IdentityOptions.Stores.SchemaVersion` is `IdentitySchemaVersions.Version3`; without it, passkey operations throw an `InvalidOperationException` naming that setting. So an existing app sets Version3, adds a migration, and writes the browser side and endpoints itself: only the Blazor Web App template ships passkey UI, while the Razor Pages default UI and `MapIdentityApi` have none. `IdentityPasskeyOptions` sets `ServerDomain`, timeouts and verification requirements.
code
csharp · 18 linesbuilder.Services.AddIdentity<GardenUser, IdentityRole>(o =>
{
o.SignIn.RequireConfirmedAccount = true;
o.Stores.SchemaVersion = IdentitySchemaVersions.Version3;
})
.AddEntityFrameworkStores<GardenDbContext>()
.AddDefaultTokenProviders();
builder.Services.Configure<IdentityPasskeyOptions>(o =>
o.ServerDomain = "plots.example.org");
app.MapPost("/account/passkey/login", async (PasskeyForm form, SignInManager<GardenUser> signIn) =>
{
var result = await signIn.PasskeySignInAsync(form.CredentialJson);
return result.Succeeded ? Results.Ok() : Results.Unauthorized();
});
record PasskeyForm(string CredentialJson);go deeper
Know that passkeys are new in ASP.NET Core 10 Identity and that the Blazor Web App template ships them ready to use.
Name the SignInManager and UserManager calls for registering and signing in, and the Version3 schema setting with its migration.
Plan adoption in an existing app: schema version and migration, your own endpoints and script outside Blazor, ServerDomain pinning, and attestation left unvalidated by default.
Decide whether passkeys sit beside passwords or replace them, and what recovery path remains when a member loses every device.
## What arrived in ASP.NET Core 10 A **passkey** is a WebAuthn credential: a key pair whose private half stays on the user's device and whose public half the site stores. ASP.NET Core 10 builds passkey support into Identity itself, scoped to registering passkeys and signing in with them. It is not a general WebAuthn library, and it does not validate attestation statements unless you supply a hook. ## The API surface Two ceremonies, each a pair of calls around the browser's WebAuthn API: | Step | Server call | Returns | |---|---|---| | Registration options | `SignInManager.MakePasskeyCreationOptionsAsync(PasskeyUserEntity)` | JSON for `navigator.credentials.create` | | Registration result | `SignInManager.PerformPasskeyAttestationAsync(credentialJson)` | `PasskeyAttestationResult` (`Succeeded`, `Passkey`) | | Store it | `UserManager.AddOrUpdatePasskeyAsync(user, result.Passkey)` | `IdentityResult` | | Sign-in options | `SignInManager.MakePasskeyRequestOptionsAsync(user)` | JSON for `navigator.credentials.get` | | Sign in | `SignInManager.PasskeySignInAsync(credentialJson)` | `SignInResult`, cookie issued on success | Between the two calls of a ceremony, `SignInManager` keeps the challenge state in the short-lived `Identity.TwoFactorUserId` cookie, so the second call must come from the same browser. `PasskeyUserEntity` carries the `Id`, `Name` and `DisplayName` the authenticator shows. `UserManager.GetPasskeysAsync` lists a user's credentials for a management page. ## Storage and the schema version Passkeys need a table. Identity's EF Core model is versioned: - `IdentitySchemaVersions.Version1` — the original tables. - `Version2` — Version1 with key columns defaulting to 128 characters and a length limit on `PhoneNumber`. - **`Version3`** — Version2 plus the **`AspNetUserPasskeys`** entity. `IdentityUserContext` falls back to Version1 when `Stores.SchemaVersion` is left at its default, so an older app's model has no passkey table. A passkey call then throws an `InvalidOperationException` telling you to set `IdentityOptions.Stores.SchemaVersion` to `IdentitySchemaVersions.Version3`. For the community-garden site the change is: 1. Set the schema version in the Identity setup action. 2. Add an EF Core migration and apply it, creating `AspNetUserPasskeys`. 3. Add endpoints that return the options JSON and accept the credential JSON. 4. Add the JavaScript that calls `navigator.credentials.create` and `get`. ## Where the UI comes from - **Blazor Web App template, Individual accounts:** ships passkey registration, rename and sign-in components, and sets `Version3` with `AddIdentityCore`, `AddSignInManager` and `AddDefaultTokenProviders`. - **Razor Pages default UI (`AddDefaultIdentity`):** no passkey pages. - **`MapIdentityApi`:** no passkey endpoints. Everyone outside the Blazor template writes the endpoints and script around the `SignInManager` calls. ## `IdentityPasskeyOptions` Configured with `services.Configure<IdentityPasskeyOptions>(...)`: - `ServerDomain` — the relying-party id. Default `null`, which derives it from the request's host, so set it explicitly or make sure the host header is validated. - `AuthenticatorTimeout` — 5 minutes, a hint to the browser. - `ChallengeSize` — 32 bytes. - `UserVerificationRequirement` — `"required"`; `ResidentKeyRequirement` — `"preferred"`. - `VerifyAttestationStatement`, `ValidateOrigin`, `IsAllowedAlgorithm` — hooks for stricter policies. Passkeys sit beside passwords: a member can add one to an existing password account. `PasskeySignInAsync` runs the same pre-sign-in check as the password path, so confirmation and lockout rules still apply; it skips the second factor, since the passkey already proves possession of a device, and signs in with a non-persistent cookie. It also updates the stored passkey with the authenticator's latest sign count.
- A passkey call throws InvalidOperationException mentioning SchemaVersion. What fixes it?The `DbContext` model has no passkey entity because `Stores.SchemaVersion` is below `Version3`. Set `o.Stores.SchemaVersion = IdentitySchemaVersions.Version3` in the Identity options, add and apply an EF Core migration to create `AspNetUserPasskeys`, and redeploy.
- Why set IdentityPasskeyOptions.ServerDomain explicitly?Left `null`, the relying-party id is taken from the request's host header, so passkeys become scoped to whatever host the request claimed. Pinning `ServerDomain` to the real domain, or validating host headers in front of the app, prevents credentials being created for an unexpected host.
- ASP.NET Core 8 Identity already supports passkeys through MapIdentityApi.
- Passkeys work with any IdentityDbContext without a schema change.
- AddDefaultIdentity's Razor Pages UI includes passkey pages in .NET 10.
- Identity validates authenticator attestation statements by default.
- PasskeySignInAsync bypasses lockout and confirmation checks.
Assumes ASP.NET Core 10, which introduced passkey support in Identity and IdentitySchemaVersions.Version3; earlier releases have no passkey APIs.