MasterKale / SimpleWebAuthn

WebAuthn, Simplified. A collection of TypeScript-first libraries for simpler WebAuthn integration. Supports modern browsers, Node, Deno, and more.
https://simplewebauthn.dev
MIT License
1.62k stars 137 forks source link

Sign-in button capabilities like in Googles Demo #574

Closed BananaAcid closed 5 months ago

BananaAcid commented 5 months ago

Describe the issue

I try to implement a sign-in button like on Google's Passkey Demo

Is my conclusion actually correct ?

Documentation

An info in the Readme.md about this being possible or not would be great.

Additional context

The example's code for route "/generate-authentication-options" it states "You need to know the user by this point" index.ts#L221-L222

Same for the "/verify-authentication" route.

... for me, the purpose using sign-in with passkeys is, not having the user logged in by that point ;)

MasterKale commented 5 months ago

There's a couple sections in the docs that might help shed some light on how to pull off an experience like the one on Google's demo site:

Take a look at those and let me know if that helps shed some light on this.

tl;dr: Make sure allowCredentials is an empty array before options make it to navigator.credentials.get(), either manually when calling generateAuthenticationOptions() or by calling startAuthentication(..., true) when using conditional UI.