Skip to content

Commit 7fa5b06

Browse files
committed
refactor: Simplify WebAuthn configuration and authenticator selection
- Updated authentication and registration routes to use more consistent WebAuthn configuration - Removed explicit authenticator selection from utils.server.ts - Set user verification to 'preferred' in authentication and registration flows
1 parent 4312db2 commit 7fa5b06

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

app/routes/_auth+/webauthn+/authentication.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export async function loader({ request }: Route.LoaderArgs) {
1616
const config = getWebAuthnConfig(request)
1717
const options = await generateAuthenticationOptions({
1818
rpID: config.rpID,
19-
userVerification: config.authenticatorSelection.userVerification,
19+
userVerification: 'preferred',
2020
})
2121

2222
const cookieHeader = await passkeyCookie.serialize({

app/routes/_auth+/webauthn+/registration.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ export async function loader({ request }: Route.LoaderArgs) {
3333
userDisplayName: user.name ?? user.email,
3434
attestationType: 'none',
3535
excludeCredentials: passkeys,
36-
authenticatorSelection: config.authenticatorSelection,
36+
authenticatorSelection: {
37+
residentKey: 'preferred',
38+
userVerification: 'preferred',
39+
},
3740
})
3841

3942
return Response.json(

app/routes/_auth+/webauthn+/utils.server.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,10 @@ export const PasskeyLoginBodySchema = z.object({
8080

8181
export function getWebAuthnConfig(request: Request) {
8282
const url = new URL(getDomainUrl(request))
83+
8384
return {
8485
rpName: url.hostname,
8586
rpID: url.hostname,
8687
origin: url.origin,
87-
authenticatorSelection: {
88-
residentKey: 'preferred',
89-
userVerification: 'preferred',
90-
},
9188
} as const
9289
}

0 commit comments

Comments
 (0)