From 5588e1a1a18a61745d744cdfcc25f1765934685a Mon Sep 17 00:00:00 2001 From: Jared Snider <116684653+JaredSnider-Bitwarden@users.noreply.github.com> Date: Thu, 6 Mar 2025 14:49:49 -0500 Subject: [PATCH] fix(auth): Auth/pm 18836 - UI Refresh - Chrome extension - WebAuthn 2FA revert inline iframe for chromium (#13709) * PM-18836 - (1) Extension Two Factor Webauthn - revert supporting inline webauthn 2fa as it doesn't work outside of local still (2) Extension 2FA Webauthn comp - add log of webauthn errors to help diagnose future issues * PM-18836 - Extension - Services module - ExtensionTwoFactorAuthWebAuthnComponentService - remove unused dep --- ...or-auth-webauthn-component.service.spec.ts | 26 ++----------------- ...-factor-auth-webauthn-component.service.ts | 17 +++--------- .../src/popup/services/services.module.ts | 2 +- .../two-factor-auth-webauthn.component.ts | 2 ++ 4 files changed, 8 insertions(+), 39 deletions(-) diff --git a/apps/browser/src/auth/services/extension-two-factor-auth-webauthn-component.service.spec.ts b/apps/browser/src/auth/services/extension-two-factor-auth-webauthn-component.service.spec.ts index b53f05172c..dfbf69f1a7 100644 --- a/apps/browser/src/auth/services/extension-two-factor-auth-webauthn-component.service.spec.ts +++ b/apps/browser/src/auth/services/extension-two-factor-auth-webauthn-component.service.spec.ts @@ -1,39 +1,17 @@ -import { MockProxy, mock } from "jest-mock-extended"; - -import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service"; - import { ExtensionTwoFactorAuthWebAuthnComponentService } from "./extension-two-factor-auth-webauthn-component.service"; describe("ExtensionTwoFactorAuthWebAuthnComponentService", () => { let extensionTwoFactorAuthWebAuthnComponentService: ExtensionTwoFactorAuthWebAuthnComponentService; - let platformUtilsService: MockProxy; - beforeEach(() => { jest.clearAllMocks(); - platformUtilsService = mock(); - extensionTwoFactorAuthWebAuthnComponentService = - new ExtensionTwoFactorAuthWebAuthnComponentService(platformUtilsService); + new ExtensionTwoFactorAuthWebAuthnComponentService(); }); describe("shouldOpenWebAuthnInNewTab", () => { - it("should return false if the browser is Chrome", () => { - // Arrange - platformUtilsService.isChrome.mockReturnValue(true); - - // Act - const result = extensionTwoFactorAuthWebAuthnComponentService.shouldOpenWebAuthnInNewTab(); - - // Assert - expect(result).toBe(false); - }); - - it("should return true if the browser is not Chrome", () => { - // Arrange - platformUtilsService.isChrome.mockReturnValue(false); - + it("should return true", () => { // Act const result = extensionTwoFactorAuthWebAuthnComponentService.shouldOpenWebAuthnInNewTab(); diff --git a/apps/browser/src/auth/services/extension-two-factor-auth-webauthn-component.service.ts b/apps/browser/src/auth/services/extension-two-factor-auth-webauthn-component.service.ts index 84a54cbc12..2af3dbe3f2 100644 --- a/apps/browser/src/auth/services/extension-two-factor-auth-webauthn-component.service.ts +++ b/apps/browser/src/auth/services/extension-two-factor-auth-webauthn-component.service.ts @@ -2,29 +2,18 @@ import { DefaultTwoFactorAuthWebAuthnComponentService, TwoFactorAuthWebAuthnComponentService, } from "@bitwarden/auth/angular"; -import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service"; export class ExtensionTwoFactorAuthWebAuthnComponentService extends DefaultTwoFactorAuthWebAuthnComponentService implements TwoFactorAuthWebAuthnComponentService { - constructor(private platformUtilsService: PlatformUtilsService) { - super(); - } - /** - * In the browser extension, we open webAuthn in a new web client tab sometimes due to inline - * WebAuthn Iframe's not working in some browsers. We open a 2FA popout upon successful - * completion of WebAuthn submission with query parameters to finish the 2FA process. + * In the browser extension, we open webAuthn in a new web client tab due to inline + * WebAuthn Iframe's not working due "WebAuthn is not supported on sites with TLS certificate errors". + * We open a 2FA popout upon successful completion of WebAuthn submission with query parameters to finish the 2FA process. * @returns boolean */ shouldOpenWebAuthnInNewTab(): boolean { - const isChrome = this.platformUtilsService.isChrome(); - if (isChrome) { - // Chrome now supports WebAuthn in the iframe in the extension now. - return false; - } - return true; } } diff --git a/apps/browser/src/popup/services/services.module.ts b/apps/browser/src/popup/services/services.module.ts index d6ef1075cf..d49f48c0c6 100644 --- a/apps/browser/src/popup/services/services.module.ts +++ b/apps/browser/src/popup/services/services.module.ts @@ -558,7 +558,7 @@ const safeProviders: SafeProvider[] = [ safeProvider({ provide: TwoFactorAuthWebAuthnComponentService, useClass: ExtensionTwoFactorAuthWebAuthnComponentService, - deps: [PlatformUtilsService], + deps: [], }), safeProvider({ provide: TwoFactorAuthDuoComponentService, diff --git a/libs/auth/src/angular/two-factor-auth/child-components/two-factor-auth-webauthn/two-factor-auth-webauthn.component.ts b/libs/auth/src/angular/two-factor-auth/child-components/two-factor-auth-webauthn/two-factor-auth-webauthn.component.ts index 4987b41707..ae348c27a6 100644 --- a/libs/auth/src/angular/two-factor-auth/child-components/two-factor-auth-webauthn/two-factor-auth-webauthn.component.ts +++ b/libs/auth/src/angular/two-factor-auth/child-components/two-factor-auth-webauthn/two-factor-auth-webauthn.component.ts @@ -108,6 +108,8 @@ export class TwoFactorAuthWebAuthnComponent implements OnInit, OnDestroy { this.webAuthnResultEmitter.emit({ token }); }, (error: string) => { + this.logService.error("WebAuthn error: ", error); + this.toastService.showToast({ variant: "error", title: this.i18nService.t("errorOccurred"),