mirror of
https://github.com/bitwarden/browser
synced 2025-12-11 22:03:36 +00: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:
@@ -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";
|
import { ExtensionTwoFactorAuthWebAuthnComponentService } from "./extension-two-factor-auth-webauthn-component.service";
|
||||||
|
|
||||||
describe("ExtensionTwoFactorAuthWebAuthnComponentService", () => {
|
describe("ExtensionTwoFactorAuthWebAuthnComponentService", () => {
|
||||||
let extensionTwoFactorAuthWebAuthnComponentService: ExtensionTwoFactorAuthWebAuthnComponentService;
|
let extensionTwoFactorAuthWebAuthnComponentService: ExtensionTwoFactorAuthWebAuthnComponentService;
|
||||||
|
|
||||||
let platformUtilsService: MockProxy<PlatformUtilsService>;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.clearAllMocks();
|
jest.clearAllMocks();
|
||||||
|
|
||||||
platformUtilsService = mock<PlatformUtilsService>();
|
|
||||||
|
|
||||||
extensionTwoFactorAuthWebAuthnComponentService =
|
extensionTwoFactorAuthWebAuthnComponentService =
|
||||||
new ExtensionTwoFactorAuthWebAuthnComponentService(platformUtilsService);
|
new ExtensionTwoFactorAuthWebAuthnComponentService();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("shouldOpenWebAuthnInNewTab", () => {
|
describe("shouldOpenWebAuthnInNewTab", () => {
|
||||||
it("should return false if the browser is Chrome", () => {
|
it("should return true", () => {
|
||||||
// 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);
|
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const result = extensionTwoFactorAuthWebAuthnComponentService.shouldOpenWebAuthnInNewTab();
|
const result = extensionTwoFactorAuthWebAuthnComponentService.shouldOpenWebAuthnInNewTab();
|
||||||
|
|
||||||
|
|||||||
@@ -2,29 +2,18 @@ import {
|
|||||||
DefaultTwoFactorAuthWebAuthnComponentService,
|
DefaultTwoFactorAuthWebAuthnComponentService,
|
||||||
TwoFactorAuthWebAuthnComponentService,
|
TwoFactorAuthWebAuthnComponentService,
|
||||||
} from "@bitwarden/auth/angular";
|
} from "@bitwarden/auth/angular";
|
||||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
|
||||||
|
|
||||||
export class ExtensionTwoFactorAuthWebAuthnComponentService
|
export class ExtensionTwoFactorAuthWebAuthnComponentService
|
||||||
extends DefaultTwoFactorAuthWebAuthnComponentService
|
extends DefaultTwoFactorAuthWebAuthnComponentService
|
||||||
implements TwoFactorAuthWebAuthnComponentService
|
implements TwoFactorAuthWebAuthnComponentService
|
||||||
{
|
{
|
||||||
constructor(private platformUtilsService: PlatformUtilsService) {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In the browser extension, we open webAuthn in a new web client tab sometimes due to inline
|
* In the browser extension, we open webAuthn in a new web client tab due to inline
|
||||||
* WebAuthn Iframe's not working in some browsers. We open a 2FA popout upon successful
|
* WebAuthn Iframe's not working due "WebAuthn is not supported on sites with TLS certificate errors".
|
||||||
* completion of WebAuthn submission with query parameters to finish the 2FA process.
|
* We open a 2FA popout upon successful completion of WebAuthn submission with query parameters to finish the 2FA process.
|
||||||
* @returns boolean
|
* @returns boolean
|
||||||
*/
|
*/
|
||||||
shouldOpenWebAuthnInNewTab(): 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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -558,7 +558,7 @@ const safeProviders: SafeProvider[] = [
|
|||||||
safeProvider({
|
safeProvider({
|
||||||
provide: TwoFactorAuthWebAuthnComponentService,
|
provide: TwoFactorAuthWebAuthnComponentService,
|
||||||
useClass: ExtensionTwoFactorAuthWebAuthnComponentService,
|
useClass: ExtensionTwoFactorAuthWebAuthnComponentService,
|
||||||
deps: [PlatformUtilsService],
|
deps: [],
|
||||||
}),
|
}),
|
||||||
safeProvider({
|
safeProvider({
|
||||||
provide: TwoFactorAuthDuoComponentService,
|
provide: TwoFactorAuthDuoComponentService,
|
||||||
|
|||||||
@@ -108,6 +108,8 @@ export class TwoFactorAuthWebAuthnComponent implements OnInit, OnDestroy {
|
|||||||
this.webAuthnResultEmitter.emit({ token });
|
this.webAuthnResultEmitter.emit({ token });
|
||||||
},
|
},
|
||||||
(error: string) => {
|
(error: string) => {
|
||||||
|
this.logService.error("WebAuthn error: ", error);
|
||||||
|
|
||||||
this.toastService.showToast({
|
this.toastService.showToast({
|
||||||
variant: "error",
|
variant: "error",
|
||||||
title: this.i18nService.t("errorOccurred"),
|
title: this.i18nService.t("errorOccurred"),
|
||||||
|
|||||||
Reference in New Issue
Block a user