next-auth icon indicating copy to clipboard operation
next-auth copied to clipboard

feat(webauthn): Extend authenticator model to store AAGUID and origin

Open 0arm opened this issue 1 year ago • 10 comments

☕️ Reasoning

I've extended the Authenticator type to include two new fields:

  • credentialAAGUID - This is used to identify the type of authenticator that was registered, this would mostly just help with displaying a name for authenticators in application UI for users. See: https://github.com/passkeydeveloper/passkey-authenticator-aaguids
  • credentialOrigin - The origin of the website that the authenticator was registered at. This would be useful for keeping track of authenticators that were registered in different environments (e.g. localhost, preview, production) as they all have different origins.

🧢 Checklist

  • [x] Documentation
  • [ ] Tests
  • [ ] Ready to be merged

🎫 Affected issues

📌 Resources

0arm avatar Mar 25 '24 13:03 0arm

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
auth-docs ❌ Failed (Inspect) May 28, 2024 3:16pm
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
next-auth-docs ⬜️ Ignored (Inspect) Visit Preview May 28, 2024 3:16pm

vercel[bot] avatar Mar 25 '24 13:03 vercel[bot]

@kyb3r is attempting to deploy a commit to the authjs Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Mar 25 '24 13:03 vercel[bot]

Awesome addition of the AAGUID, this will make buildling UI around the passkeys providver much nicer.

Regarding the credentialsOrigin though, wouldn't that always just always be the origin of the user's application? Like the app the user is using auth.js with?

ndom91 avatar Mar 25 '24 18:03 ndom91

Regarding the origin, especially in the case of developing locally and having a preview deployment up, you can’t reuse passkeys across origins.

So the same passkey won’t work across preview/development using the same database. So to do testing you have to register a seperate passkey for each origin you are testing on.

Storing the origin associated with the authenticator would simply make it easier to keep track of your different passkeys in the ui.

But at the same time this wouldn’t be difficult for users to implement as a custom adapter method in createAuthenticator by just checking which env and relaying party you are using currently.

What are your thoughts? @ndom91

0arm avatar Mar 25 '24 18:03 0arm

Without this PR, this is how I'm currently getting the same functionality. It's kind of wacky but the end result is worth it :)

Screenshot 2024-03-26 at 8 28 50 pm

In my custom adapter I can inject values into the Authenticator table

Screenshot 2024-03-26 at 8 29 25 pm

All of this lets us show some good guesses for what the authenticator may be in the ui:

Screenshot 2024-03-26 at 9 52 27 pm

I really hope the way I implemented this is not stupid lol, if an easier way flew over my head let me know haha

0arm avatar Mar 26 '24 11:03 0arm

Hmm okay I get what you're getting at with the origin field I think. However, I'd wager that most people also have separate databases for their dev / prod instances (or at least I'd hope so :sweat_smile:). So I'm not totally convinced that we need that field.

What are you using it for in your use-case exactly? Just to tell the difference between staging / dev / prod passkeys as you're sharing a DB between the different environments?

ndom91 avatar Mar 26 '24 15:03 ndom91

Hmm okay I get what you're getting at with the origin field I think. However, I'd wager that most people also have separate databases for their dev / prod instances (or at least I'd hope so 😅). So I'm not totally convinced that we need that field.

What are you using it for in your use-case exactly? Just to tell the difference between staging / dev / prod passkeys as you're sharing a DB between the different environments?

Yes i’m sharing a database between environments.

Yeah I totally get it, I can remove the origin field if needed. But the AAGUID field is pretty useful i’d say.

0arm avatar Mar 26 '24 19:03 0arm

@kyb3r okay awesome, yeah let's do that then. AAGUID only, no origin 👍

ndom91 avatar Mar 27 '24 10:03 ndom91

@ndom91 Done

0arm avatar Mar 28 '24 00:03 0arm

Any updates?

0arm avatar Apr 17 '24 04:04 0arm

Gonna be honest, I don't really have the time to do this unfortunately. I think it will be faster to take over since the changes are very minimal.

0arm avatar Jun 02 '24 07:06 0arm

Gonna be honest, I don't really have the time to do this unfortunately. I think it will be faster to take over since the changes are very minimal.

Yeah no worries, thanks for getting back to us

ndom91 avatar Jun 02 '24 11:06 ndom91