From 41e1d9155850581be85d11e4b74088aa022f8381 Mon Sep 17 00:00:00 2001 From: Ike <137194738+ike-kottlowski@users.noreply.github.com> Date: Tue, 25 Jun 2024 11:09:45 -0700 Subject: [PATCH] [PM-5156] [PM-5216] Duo v2 removal (#9513) * remove library and update package and webpack * update 2fa flow and remove feature flag * update request and response models * fix merge conflicts --- .github/renovate.json | 9 +- .../src/auth/popup/two-factor.component.html | 15 +- apps/browser/src/auth/scripts/duo.js | 418 ------------------ .../src/auth/two-factor.component.html | 25 +- .../auth/settings/two-factor-duo.component.ts | 8 +- .../src/app/auth/two-factor.component.html | 29 +- apps/web/src/connectors/duo.html | 17 - apps/web/src/connectors/duo.scss | 18 - apps/web/src/connectors/duo.ts | 47 -- apps/web/webpack.config.js | 6 - .../auth/components/two-factor.component.ts | 44 +- .../request/update-two-factor-duo.request.ts | 4 +- .../response/two-factor-duo.response.ts | 8 +- package-lock.json | 13 - package.json | 2 - 15 files changed, 36 insertions(+), 627 deletions(-) delete mode 100644 apps/browser/src/auth/scripts/duo.js delete mode 100644 apps/web/src/connectors/duo.html delete mode 100644 apps/web/src/connectors/duo.scss delete mode 100644 apps/web/src/connectors/duo.ts diff --git a/.github/renovate.json b/.github/renovate.json index 95fd2dc11e..e202e02667 100644 --- a/.github/renovate.json +++ b/.github/renovate.json @@ -69,14 +69,7 @@ "reviewers": ["team:team-admin-console-dev"] }, { - "matchPackageNames": [ - "@types/duo_web_sdk", - "@types/node-ipc", - "duo_web_sdk", - "node-ipc", - "qrious", - "regedit" - ], + "matchPackageNames": ["@types/node-ipc", "node-ipc", "qrious", "regedit"], "description": "Auth owned dependencies", "commitMessagePrefix": "[deps] Auth:", "reviewers": ["team:team-auth-dev"] diff --git a/apps/browser/src/auth/popup/two-factor.component.html b/apps/browser/src/auth/popup/two-factor.component.html index 3047ddfd7e..126b0ea5a9 100644 --- a/apps/browser/src/auth/popup/two-factor.component.html +++ b/apps/browser/src/auth/popup/two-factor.component.html @@ -111,7 +111,7 @@ -
+

{{ "duoRequiredForAccount" | i18n }}

@@ -127,17 +127,6 @@
- -
- -
- - -
-
@@ -158,7 +147,7 @@
- +
@@ -148,10 +140,7 @@
-
+
diff --git a/apps/web/src/connectors/duo.html b/apps/web/src/connectors/duo.html deleted file mode 100644 index 8d315219c2..0000000000 --- a/apps/web/src/connectors/duo.html +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - Bitwarden Duo Connector - - - - diff --git a/apps/web/src/connectors/duo.scss b/apps/web/src/connectors/duo.scss deleted file mode 100644 index 0fa97956ee..0000000000 --- a/apps/web/src/connectors/duo.scss +++ /dev/null @@ -1,18 +0,0 @@ -html, -body { - margin: 0; - padding: 0; -} - -body { - background: #efeff4 url("../images/loading.svg") 0 0 no-repeat; -} - -iframe { - display: block; - width: 100%; - height: 400px; - border: none; - margin: 0; - padding: 0; -} diff --git a/apps/web/src/connectors/duo.ts b/apps/web/src/connectors/duo.ts deleted file mode 100644 index b041c0d6a2..0000000000 --- a/apps/web/src/connectors/duo.ts +++ /dev/null @@ -1,47 +0,0 @@ -import * as DuoWebSDK from "duo_web_sdk"; - -import { getQsParam } from "./common"; - -require("./duo.scss"); - -document.addEventListener("DOMContentLoaded", () => { - const frameElement = document.createElement("iframe"); - frameElement.setAttribute("id", "duo_iframe"); - setFrameHeight(); - document.body.appendChild(frameElement); - - const hostParam = getQsParam("host"); - const requestParam = getQsParam("request"); - - const hostUrl = new URL("https://" + hostParam); - if ( - !hostUrl.hostname.endsWith(".duosecurity.com") && - !hostUrl.hostname.endsWith(".duofederal.com") - ) { - return; - } - - DuoWebSDK.init({ - iframe: "duo_iframe", - host: hostUrl.hostname, - sig_request: requestParam, - submit_callback: (form: any) => { - invokeCSCode(form.elements.sig_response.value); - }, - }); - - window.onresize = setFrameHeight; - - function setFrameHeight() { - frameElement.style.height = window.innerHeight + "px"; - } -}); - -function invokeCSCode(data: string) { - try { - (window as any).invokeCSharpAction(data); - } catch (err) { - // eslint-disable-next-line - console.log(err); - } -} diff --git a/apps/web/webpack.config.js b/apps/web/webpack.config.js index f22d98f081..884a0bc997 100644 --- a/apps/web/webpack.config.js +++ b/apps/web/webpack.config.js @@ -91,11 +91,6 @@ const plugins = [ chunks: ["theme_head", "app/polyfills", "app/vendor", "app/main"], }), new HtmlWebpackInjector(), - new HtmlWebpackPlugin({ - template: "./src/connectors/duo.html", - filename: "duo-connector.html", - chunks: ["connectors/duo"], - }), new HtmlWebpackPlugin({ template: "./src/connectors/webauthn.html", filename: "webauthn-connector.html", @@ -324,7 +319,6 @@ const webpackConfig = { "app/main": "./src/main.ts", "connectors/webauthn": "./src/connectors/webauthn.ts", "connectors/webauthn-fallback": "./src/connectors/webauthn-fallback.ts", - "connectors/duo": "./src/connectors/duo.ts", "connectors/sso": "./src/connectors/sso.ts", "connectors/captcha": "./src/connectors/captcha.ts", "connectors/duo-redirect": "./src/connectors/duo-redirect.ts", diff --git a/libs/angular/src/auth/components/two-factor.component.ts b/libs/angular/src/auth/components/two-factor.component.ts index 687fd3fb6f..4ef18985d8 100644 --- a/libs/angular/src/auth/components/two-factor.component.ts +++ b/libs/angular/src/auth/components/two-factor.component.ts @@ -1,6 +1,5 @@ import { Directive, Inject, OnDestroy, OnInit } from "@angular/core"; import { ActivatedRoute, NavigationExtras, Router } from "@angular/router"; -import * as DuoWebSDK from "duo_web_sdk"; import { firstValueFrom } from "rxjs"; import { first } from "rxjs/operators"; @@ -53,7 +52,6 @@ export class TwoFactorComponent extends CaptchaProtectedComponent implements OnI emailPromise: Promise; orgIdentifier: string = null; - duoFrameless = false; duoFramelessUrl: string = null; duoResultListenerInitialized = false; @@ -177,42 +175,14 @@ export class TwoFactorComponent extends CaptchaProtectedComponent implements OnI break; case TwoFactorProviderType.Duo: case TwoFactorProviderType.OrganizationDuo: - // 2 Duo 2FA flows available - // 1. Duo Web SDK (iframe) - existing, to be deprecated - // 2. Duo Frameless (new tab) - new - - // AuthUrl only exists for new Duo Frameless flow - if (providerData.AuthUrl) { - this.duoFrameless = true; - // Setup listener for duo-redirect.ts connector to send back the code - - if (!this.duoResultListenerInitialized) { - // setup client specific duo result listener - this.setupDuoResultListener(); - this.duoResultListenerInitialized = true; - } - - // flow must be launched by user so they can choose to remember the device or not. - this.duoFramelessUrl = providerData.AuthUrl; - } else { - // Duo Web SDK (iframe) flow - // TODO: remove when we remove the "duo-redirect" feature flag - setTimeout(() => { - DuoWebSDK.init({ - iframe: undefined, - host: providerData.Host, - sig_request: providerData.Signature, - submit_callback: async (f: HTMLFormElement) => { - const sig = f.querySelector('input[name="sig_response"]') as HTMLInputElement; - if (sig != null) { - this.token = sig.value; - await this.submit(); - } - }, - }); - }, 0); + // Setup listener for duo-redirect.ts connector to send back the code + if (!this.duoResultListenerInitialized) { + // setup client specific duo result listener + this.setupDuoResultListener(); + this.duoResultListenerInitialized = true; } - + // flow must be launched by user so they can choose to remember the device or not. + this.duoFramelessUrl = providerData.AuthUrl; break; case TwoFactorProviderType.Email: this.twoFactorEmail = providerData.Email; diff --git a/libs/common/src/auth/models/request/update-two-factor-duo.request.ts b/libs/common/src/auth/models/request/update-two-factor-duo.request.ts index d113715b37..c67b111741 100644 --- a/libs/common/src/auth/models/request/update-two-factor-duo.request.ts +++ b/libs/common/src/auth/models/request/update-two-factor-duo.request.ts @@ -1,7 +1,7 @@ import { SecretVerificationRequest } from "./secret-verification.request"; export class UpdateTwoFactorDuoRequest extends SecretVerificationRequest { - integrationKey: string; - secretKey: string; + clientId: string; + clientSecret: string; host: string; } diff --git a/libs/common/src/auth/models/response/two-factor-duo.response.ts b/libs/common/src/auth/models/response/two-factor-duo.response.ts index b91c9f0fb6..a195aa236d 100644 --- a/libs/common/src/auth/models/response/two-factor-duo.response.ts +++ b/libs/common/src/auth/models/response/two-factor-duo.response.ts @@ -3,14 +3,14 @@ import { BaseResponse } from "../../../models/response/base.response"; export class TwoFactorDuoResponse extends BaseResponse { enabled: boolean; host: string; - secretKey: string; - integrationKey: string; + clientSecret: string; + clientId: string; constructor(response: any) { super(response); this.enabled = this.getResponseProperty("Enabled"); this.host = this.getResponseProperty("Host"); - this.secretKey = this.getResponseProperty("SecretKey"); - this.integrationKey = this.getResponseProperty("IntegrationKey"); + this.clientSecret = this.getResponseProperty("ClientSecret"); + this.clientId = this.getResponseProperty("ClientId"); } } diff --git a/package-lock.json b/package-lock.json index 78ed8111e0..991849fd01 100644 --- a/package-lock.json +++ b/package-lock.json @@ -39,7 +39,6 @@ "chalk": "4.1.2", "commander": "11.1.0", "core-js": "3.36.1", - "duo_web_sdk": "github:duosecurity/duo_web_sdk", "form-data": "4.0.0", "https-proxy-agent": "7.0.2", "inquirer": "8.2.6", @@ -97,7 +96,6 @@ "@storybook/testing-library": "0.2.2", "@types/argon2-browser": "1.18.1", "@types/chrome": "0.0.262", - "@types/duo_web_sdk": "2.7.1", "@types/firefox-webext-browser": "111.0.5", "@types/inquirer": "8.2.10", "@types/jest": "29.5.12", @@ -11352,12 +11350,6 @@ "dev": true, "license": "MIT" }, - "node_modules/@types/duo_web_sdk": { - "version": "2.7.1", - "resolved": "https://registry.npmjs.org/@types/duo_web_sdk/-/duo_web_sdk-2.7.1.tgz", - "integrity": "sha512-DePanZjFww36yGSxXwC8B3AsjrrDuPxEcufeh4gTqVsUMpCYByxjX4PERiYZdW0typzKSt9E4I14PPp+PrSIQA==", - "dev": true - }, "node_modules/@types/ejs": { "version": "3.1.5", "resolved": "https://registry.npmjs.org/@types/ejs/-/ejs-3.1.5.tgz", @@ -18249,11 +18241,6 @@ "node": ">=12" } }, - "node_modules/duo_web_sdk": { - "version": "2.7.0", - "resolved": "git+ssh://git@github.com/duosecurity/duo_web_sdk.git#29cad7338eff2cd909a361ecdd525458862938be", - "license": "SEE LICENSE IN LICENSE" - }, "node_modules/duplexer": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.2.tgz", diff --git a/package.json b/package.json index 70c3803aba..c835300fcc 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,6 @@ "@storybook/testing-library": "0.2.2", "@types/argon2-browser": "1.18.1", "@types/chrome": "0.0.262", - "@types/duo_web_sdk": "2.7.1", "@types/firefox-webext-browser": "111.0.5", "@types/inquirer": "8.2.10", "@types/jest": "29.5.12", @@ -176,7 +175,6 @@ "chalk": "4.1.2", "commander": "11.1.0", "core-js": "3.36.1", - "duo_web_sdk": "github:duosecurity/duo_web_sdk", "form-data": "4.0.0", "https-proxy-agent": "7.0.2", "inquirer": "8.2.6",