Repository navigation
Add passkey endpoints to MapIdentityApi - #68198
Merged
Merged
Conversation
Contributor
Author
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). 4 pipeline(s) were filtered out due to trigger conditions. |
rolandVi
requested review from
Youssef1313,
cincuranet and
davpetr
as code owners
September 4, 2026 13:58
Contributor
Author
|
/azp run aspnetcore-ci |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
6 tasks
rokonec
approved these changes
Sep 21, 2026
rokonec
approved these changes
Sep 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
API proposal in #68197.
SPA and mobile apps that use
MapIdentityApi()can now register a passkey, sign in with one, and list, rename and revoke the ones on their account. Today those endpoints only do passwords, so a JavaScript or MAUI client either drops passkeys or hand-writes both WebAuthn ceremonies againstSignInManageritself, including the challenge state that has to survive between the two requests.Design notes
/passkeys/requestOptionsreturns an emptyallowCredentials. Filling it with the account's credential IDs whenever the email matched made the endpoint an enumeration oracle: a populated list is a hard yes, and it hands out the credential IDs and transport hints with it. Empty says nothing either way, and sign-in falls back to discoverable credentials.The options endpoints return the handler's JSON verbatim instead of round-tripping it through a DTO, so an app's
JsonNamingPolicycannot rename properties whose names WebAuthn fixes.Registration compares the attested user entity ID against the signed-in user before storing, so a client cannot register a passkey onto another account by replaying someone else's attestation state.
Rename and delete resolve the user, then look the credential up scoped to that user, and 404 before mutating anything. This is load-bearing rather than tidy:
UserStore.AddOrUpdatePasskeyAsyncresolves a credential ID globally with no user filter, andRemovePasskeyCoreAsynchas no existence check, so trusting the route value would be an IDOR on rename and a 200 that deleted nothing on delete. Unknown and foreign credential IDs are both 404 so the two cannot be told apart.A malformed credential ID is a 400 with
InvalidCredentialId, not a 404. Base64Url validity is decidable offline, so it leaks nothing, and the handler never reaches a lookup, so 404 would be a claim it cannot back up.GETdoes not sort. Neither EF store promises an order, and the tests match entries by credential ID rather than position so they cannot go flaky on it.Rename is read, set name, upsert. A delete committing inside that window re-creates the row through the store's upsert. Passkey sign-in already does the same thing on every assertion to update the sign count, so the race predates this change and closing it needs a new method on the shipped
IUserPasskeyStore<TUser>. I have left it and will file it separately.Missing or expired ceremony state comes back as a 400. Taking too long between the two requests is a normal thing for a user to do, not a bug. A new internal
PasskeyAuthenticationStateExceptionmarks that case; it derives fromInvalidOperationException, so existingcatchblocks are unaffected. Whether it should be public is an open question on the proposal.A missing cookie scheme still throws, unlike expired state. It means the app was never configured for this, the same developer error as
/login?useCookies=trueon a bearer-only setup, and it already throws there.The bearer and cookie selection in
/loginmoved into a private helper that/passkeys/loginshares./loginbehaves exactly as before.Template
The Blazor template's
/Account/PasskeyRequestOptionshad the same leak and gets the same one-line fix.Deliberately not here
Deleting the last passkey is allowed even on an account with no password. That is an open question on the proposal, not an oversight.
The list response carries credential ID, name and creation time only.
TransportsandIsBackedUpwould let a UI distinguish synced from device-bound credentials, but they are additive later.The endpoints need the
Identity.TwoFactorUserIdcookie scheme to hold ceremony state between the two requests.AddIdentityApiEndpointsregisters it, but an app wired for bearer tokens only cannot use passkeys.Testing
MapIdentityApiTestsdrives all seven endpoints through a deterministicIPasskeyHandlerrather than a real authenticator, covering authorization on every verb, bearer and both cookie modes, user mismatch, invalid and expired state, unknown emails, custom JSON naming, the exact set of fields on a listed passkey, rename and name clearing, delete, another user's credential, malformed IDs and unknown IDs.SignInManagerTestcovers persistent and non-persistent sign-in, the metrics tags and the two ceremony-state failures.The template's end-to-end test: virtual authenticator, register, log out, then log back in with the passkey.
Resolves #67301
Resolves #68199