Skip to content

Modern Docker Management, Designed for Everyone

fix: prevent passkey MFA failures caused by reactive options (#3926)

Kyle Mendell95e5a3bc1470
diff --git a/frontend/src/lib/components/auth/mfa-challenge.svelte b/frontend/src/lib/components/auth/mfa-challenge.svelte
index 6e4503969..c770707cb 100644
--- a/frontend/src/lib/components/auth/mfa-challenge.svelte
+++ b/frontend/src/lib/components/auth/mfa-challenge.svelte
@@ -38,7 +38,7 @@
const operationResult1 = await tryCatch(
(async () => {
const credential = await startAuthentication({
- optionsJSON: challenge.options as unknown as PublicKeyCredentialRequestOptionsJSON
+ optionsJSON: $state.snapshot(challenge.options) as unknown as PublicKeyCredentialRequestOptionsJSON
});
const response = await passkeyService.finishMFA(challenge.transactionId, credential);
await onComplete(response);
diff --git a/frontend/src/routes/(auth)/mobile/passkey/+page.svelte b/frontend/src/routes/(auth)/mobile/passkey/+page.svelte
index 22a81edaf..817a6b79b 100644
--- a/frontend/src/routes/(auth)/mobile/passkey/+page.svelte
+++ b/frontend/src/routes/(auth)/mobile/passkey/+page.svelte
@@ -78,7 +78,7 @@
let credential: MobilePasskeyCredential;
if (ceremonyRequest.operation === 'authenticate') {
credential = await startAuthentication({
- optionsJSON: ceremonyRequest.options as unknown as PublicKeyCredentialRequestOptionsJSON
+ optionsJSON: $state.snapshot(ceremonyRequest.options) as unknown as PublicKeyCredentialRequestOptionsJSON
});
if (ceremonyRequest.mobileLogin) {
const completion = await passkeyService.finishMobileLogin(
@@ -91,7 +91,7 @@
}
} else {
credential = await startRegistration({
- optionsJSON: ceremonyRequest.options as unknown as PublicKeyCredentialCreationOptionsJSON
+ optionsJSON: $state.snapshot(ceremonyRequest.options) as unknown as PublicKeyCredentialCreationOptionsJSON
});
}
diff --git a/tests/spec/account.spec.ts b/tests/spec/account.spec.ts
index 4c53a456b..8082e5b33 100644
--- a/tests/spec/account.spec.ts
+++ b/tests/spec/account.spec.ts
@@ -435,11 +435,26 @@ test('registers, renames, authenticates with, and removes a passkey with MFA', a
await dangerZone.getByRole('button', { name: 'Log out', exact: true }).click();
await expect(passkeyPage).toHaveURL('/login');
- await passkeyPage.getByRole('button', { name: 'Passkey', exact: true }).click();
+ await login(passkeyPage, username, password, '/login');
const usePasskeyButton = passkeyPage.getByRole('button', {
name: 'Use passkey',
exact: true
});
+ await expect(usePasskeyButton).toBeVisible();
+ const mfaFinishResponsePromise = passkeyPage.waitForResponse(
+ (response) =>
+ response.request().method() === 'POST' &&
+ new URL(response.url()).pathname === '/api/auth/mfa/passkey/finish'
+ );
+ await usePasskeyButton.click();
+ expect((await mfaFinishResponsePromise).ok()).toBe(true);
+ await expect(passkeyPage).toHaveURL('/dashboard');
+ await expect(passkeyPage.locator('main').first()).toBeVisible();
+
+ await passkeyPage.goto('/account');
+ await dangerZone.getByRole('button', { name: 'Log out', exact: true }).click();
+ await expect(passkeyPage).toHaveURL('/login');
+ await passkeyPage.getByRole('button', { name: 'Passkey', exact: true }).click();
if (await usePasskeyButton.isVisible().catch(() => false)) {
await usePasskeyButton.click();
}