From 8469e3541abb0968dc3017087ae2c45f854f8a07 Mon Sep 17 00:00:00 2001 From: Jared Snider Date: Mon, 30 Sep 2024 16:04:04 -0400 Subject: [PATCH] PM-8111 - (1) Cleanup DefaultLoginComponentService (2) Sso Connector now checks client id property instead of reading it from state --- apps/web/src/connectors/sso.ts | 3 ++- .../login/default-login-component.service.ts | 16 ++++------------ 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/apps/web/src/connectors/sso.ts b/apps/web/src/connectors/sso.ts index e049c64e5d9..44ead1dc184 100644 --- a/apps/web/src/connectors/sso.ts +++ b/apps/web/src/connectors/sso.ts @@ -6,10 +6,11 @@ window.addEventListener("load", () => { const code = getQsParam("code"); const state = getQsParam("state"); const lastpass = getQsParam("lp"); + const clientId = getQsParam("clientId"); if (lastpass === "1") { initiateBrowserSso(code, state, true); - } else if (state != null && state.includes(":clientId=browser")) { + } else if (state != null && clientId == "browser") { initiateBrowserSso(code, state, false); } else { window.location.href = window.location.origin + "/#/sso?code=" + code + "&state=" + state; diff --git a/libs/auth/src/angular/login/default-login-component.service.ts b/libs/auth/src/angular/login/default-login-component.service.ts index dde205dae20..620d328d5df 100644 --- a/libs/auth/src/angular/login/default-login-component.service.ts +++ b/libs/auth/src/angular/login/default-login-component.service.ts @@ -48,11 +48,7 @@ export class DefaultLoginComponentService implements LoginComponentService { special: false, }; - let state = await this.passwordGenerationService.generatePassword(passwordOptions); - // TODO-rr-bw: verify this is correct. Pulling this from original browser login component launchSsoBrowser method - if (clientId === "browser") { - state += ":clientId=browser"; - } + const state = await this.passwordGenerationService.generatePassword(passwordOptions); const codeVerifier = await this.passwordGenerationService.generatePassword(passwordOptions); const codeVerifierHash = await this.cryptoFunctionService.hash(codeVerifier, "sha256"); @@ -64,20 +60,16 @@ export class DefaultLoginComponentService implements LoginComponentService { // Build URL const env = await firstValueFrom(this.environmentService.environment$); - let url = env.getWebVaultUrl(); - // TODO-rr-bw: verify this is correct. Pulling this from original browser login component launchSsoBrowser method - if (url == null) { - url = "https://vault.bitwarden.com"; - } + const webVaultUrl = env.getWebVaultUrl(); const redirectUri = clientId === "browser" - ? url + "/sso-connector.html" // Browser + ? webVaultUrl + "/sso-connector.html" // Browser : "bitwarden://sso-callback"; // Desktop // Launch browser window with URL this.platformUtilsService.launchUri( - url + + webVaultUrl + "/#/sso?clientId=" + clientId + "&redirectUri=" +