Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for WebAuthn's conditional create #582

Closed
MasterKale opened this issue Jun 13, 2024 · 12 comments · Fixed by #623
Closed

Add support for WebAuthn's conditional create #582

MasterKale opened this issue Jun 13, 2024 · 12 comments · Fixed by #623

Comments

@MasterKale
Copy link
Owner

MasterKale commented Jun 13, 2024

Describe the issue

At WWDC 24 this week Apple debuted macOS Sequioa Dev Beta 1, which includes Safari 18.0 Beta. According to the WebKit blog, Safari 18.0 Beta supports "conditional create" added to WebAuthn L3. This is what Apple is referring to when it mentions "automatic passkey upgrades."

This new capability allows an RP to "silently" trigger a passkey registration after a successful traditional authentication (i.e. username+password auth) without the user needing to click through any browser modals. From that point on the RP could switch the user to passkeys at the next login.

Supporting this isn't much different than supporting conditional UI during auth; it's an otherwise normal call to navigator.credentials.create() with some specific options passed in. I can easily add such a capability to @simplewebauthn/browser's startRegistration() method similar to how I added conditional UI support with startAuthentication(..., true).

Additional Resources

Safari flow chart for when an RP can trigger conditional create:

Screenshot 2024-06-11 at 1 17 58 PM

@lmarschall
Copy link

Hey @MasterKale,

a few months ago, I was trying to implement the conditional UI flow with the browser package, but I wasn't able to get it working properly without eventual fails.

https://simplewebauthn.dev/docs/packages/browser#browser-autofill-aka-conditional-ui

As you described here, we should add the startAuthentication workflow in the head section or let the UI wait some n seconds, is this workaround still required, or are there any better solutions, because I find it quite unpleasant to implement the startAuthentication in the head section or wait n seconds 😞

@lmarschall
Copy link

lmarschall commented Aug 15, 2024

@MasterKale

Would it be possible to create a new passkey on login with an existing passkey, with Conditional Create, as well?

@MasterKale
Copy link
Owner Author

As you described here, we should add the startAuthentication workflow in the head section or let the UI wait some n seconds, is this workaround still required, or are there any better solutions, because I find it quite unpleasant to implement the startAuthentication in the head section or wait n seconds 😞

Good question @lmarschall, let me ask around and see what the consensus is.

Would it be possible to create a new passkey on login with an existing passkey, with Conditional Create, as well?

Hmm, conditional create in the L3 draft says this...

It is up to the user agent to decide when it believes an authentication ceremony has been completed. That authentication ceremony MAY be performed via other means than the Web Authentication API.

Which means the answer is "maybe, but it's up to the browser" 🤔

@lmarschall
Copy link

@MasterKale
Sound great, I'm looking forward to tinker a bit with the conditional create workflow, presenting users with only one webauthn dialogue in the browser when switching devices would be awesome.

@MasterKale
Copy link
Owner Author

I'm gearing up to tackle this Soon™ and realized that I need to consider how to allow the user presence bit to be false. Conditional create makes this a first for WebAuthn; it's otherwise required to be true.

@MasterKale
Copy link
Owner Author

MasterKale commented Sep 22, 2024

I need to add a new option to startRegistration() like useBrowserAutofill in startAuthentication(). For those following this issue, I need to decide on a name for the new option. This is a flag to "silently request the creation of a WebAuthn credential from the password manager (which is also a passkey provider) that the user just used to facilitate login."

Potential candidates include:

  • silentlyCreate
  • useAutomaticUpgrade (very Apple-centric though; maybe I try to coin a new term?)
  • useQuietCreation maybe? 🤔

I'm open to suggestions.

@lmarschall
Copy link

lmarschall commented Sep 22, 2024

Maybe useCredentialsUpgrade gives a more broader term for this use case, because in the end an authenticated users credentials gets upgraded to passkeys.

@MasterKale
Copy link
Owner Author

I went with useAutoRegister in #623, this'll go out as part of a v11 major release (after I close another issue or two)

@MasterKale
Copy link
Owner Author

@lmarschall Check out the new @simplewebauthn/[email protected] - startRegistration() has the new useAutoRegister option that should enable use of conditional create.

Just a heads up, the API of startRegistration() changed to accept a single argument object, with the positional arguments as properties within. See the CHANGELOG for more info about this:

https://github.com/MasterKale/SimpleWebAuthn/blob/master/CHANGELOG.md#browser-positional-arguments-in-startregistration-and-startauthentication-have-been-replaced-by-a-single-object

@swagliquido
Copy link

swagliquido commented Oct 18, 2024

EDIT: nevermind, I realized it requires Apple passwords and enabling "Allow automatic passkey upgrades", so it's an apple only thing, wasn't clear from the changelog

@MasterKale Hi, sorry for the noob question, I wanted to try this new functionality even tho it's not documented yet, but adding useAutoRegister to startRegistration doesn't seem to do anything on chrome browser v130 on both windows 11 and android, am i missing something? Maybe this is expected to work only on Safari 18? This is how I added it, but it works just the same as if I just passed options alone, so the UI to create passkeys is being displayed.

attestationResponse = await SimpleWebAuthnBrowser.startRegistration({ optionsJSON: options, useAutoRegister: true });

@lmarschall
Copy link

@MasterKale Thank you for the advancements in this project, definitely going to take a look at the new functions this week 👍

@MasterKale
Copy link
Owner Author

EDIT: nevermind, I realized it requires Apple passwords and enabling "Allow automatic passkey upgrades", so it's an apple only thing, wasn't clear from the changelog

@swagliquido Support for conditional create must exist in the passkey provider and the operating system (and/or browser depending on what's talking to the passkey provider.) Right now Apple's operating system and iCloud Keychain are the first combination of that I know of to have pretty reliable support for this. Microsoft and Google will gradually implement support in Windows and Android respectively, and it's likely Chrome will be able to broker some of this as well/in the meantime while the OSs get updated.

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 a pull request may close this issue.

3 participants