Add passkey endpoints to MapIdentityApi - #68198
Open
rolandVi wants to merge 1 commit into
Open
Conversation
Member
Author
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). 4 pipeline(s) were filtered out due to trigger conditions. |
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 and sign in with passkeys. 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.POST /passkeys/requestOptionsPOST /passkeys/loginPOST /manage/passkeys/creationOptionsPOST /manage/passkeysExample usage
Design notes
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.
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 the 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.Not included
Listing, renaming and deleting passkeys (#68199)
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 four endpoints through a deterministicIPasskeyHandlerrather than a real authenticator, covering authorization, bearer and both cookie modes, user mismatch, invalid and expired state, unknown emails and custom JSON naming.SignInManagerTestcovers persistent and non-persistent sign-in, the metrics tags and the two ceremony-state failures.Resolves #67301