1
0
mirror of https://github.com/bitwarden/browser.git synced 2025-03-13 13:49:37 +01:00

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
This commit is contained in:
Jared Snider 2025-03-06 14:49:49 -05:00 committed by GitHub
parent e327816bc4
commit 5588e1a1a1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 8 additions and 39 deletions

View File

@ -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<PlatformUtilsService>;
beforeEach(() => {
jest.clearAllMocks();
platformUtilsService = mock<PlatformUtilsService>();
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();

View File

@ -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;
}
}

View File

@ -558,7 +558,7 @@ const safeProviders: SafeProvider[] = [
safeProvider({
provide: TwoFactorAuthWebAuthnComponentService,
useClass: ExtensionTwoFactorAuthWebAuthnComponentService,
deps: [PlatformUtilsService],
deps: [],
}),
safeProvider({
provide: TwoFactorAuthDuoComponentService,

View File

@ -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"),