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

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions apps/dev/nextjs/prisma/schema.prisma
Expand Up @@ -34,9 +34,9 @@ model Session {
}

model User {
id String @id @default(cuid())
id String @id @default(cuid())
name String?
email String? @unique
email String? @unique
emailVerified DateTime?
image String?
accounts Account[]
Expand All @@ -62,6 +62,7 @@ model Authenticator {
credentialDeviceType String
credentialBackedUp Boolean
transports String?
credentialAAGUID String?

user User @relation(fields: [userId], references: [id], onDelete: Cascade)
}
3 changes: 2 additions & 1 deletion packages/core/src/lib/utils/webauthn-utils.ts
Expand Up @@ -377,7 +377,7 @@ export async function verifyRegister(
}

// Build a new authenticator
const authenticator = {
const authenticator: Authenticator = {
providerAccountId: account.providerAccountId,
counter: verification.registrationInfo.counter,
credentialID: toBase64(verification.registrationInfo.credentialID),
Expand All @@ -390,6 +390,7 @@ export async function verifyRegister(
(data as RegistrationResponseJSON).response
.transports as AuthenticatorTransport[]
),
credentialAAGUID: verification.registrationInfo.aaguid,
}

// Return created stuff
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/types.ts
Expand Up @@ -396,6 +396,10 @@ export interface Authenticator {
* Device type of the authenticator.
*/
credentialDeviceType: string
/**
* AAGUID of the authenticator. Useful to identify authenticators in the UI, see: https://github.com/passkeydeveloper/passkey-authenticator-aaguids
*/
credentialAAGUID: string
}

/** @internal */
Expand Down