mirror of
https://github.com/bitwarden/browser.git
synced 2025-03-12 13:39:14 +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:
parent
e327816bc4
commit
5588e1a1a1
@ -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();
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -558,7 +558,7 @@ const safeProviders: SafeProvider[] = [
|
||||
safeProvider({
|
||||
provide: TwoFactorAuthWebAuthnComponentService,
|
||||
useClass: ExtensionTwoFactorAuthWebAuthnComponentService,
|
||||
deps: [PlatformUtilsService],
|
||||
deps: [],
|
||||
}),
|
||||
safeProvider({
|
||||
provide: TwoFactorAuthDuoComponentService,
|
||||
|
@ -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"),
|
||||
|
Loading…
Reference in New Issue
Block a user