mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 16:23:44 +00:00
PM-8111 - (1) Cleanup DefaultLoginComponentService (2) Sso Connector now checks client id property instead of reading it from state
This commit is contained in:
@@ -6,10 +6,11 @@ window.addEventListener("load", () => {
|
|||||||
const code = getQsParam("code");
|
const code = getQsParam("code");
|
||||||
const state = getQsParam("state");
|
const state = getQsParam("state");
|
||||||
const lastpass = getQsParam("lp");
|
const lastpass = getQsParam("lp");
|
||||||
|
const clientId = getQsParam("clientId");
|
||||||
|
|
||||||
if (lastpass === "1") {
|
if (lastpass === "1") {
|
||||||
initiateBrowserSso(code, state, true);
|
initiateBrowserSso(code, state, true);
|
||||||
} else if (state != null && state.includes(":clientId=browser")) {
|
} else if (state != null && clientId == "browser") {
|
||||||
initiateBrowserSso(code, state, false);
|
initiateBrowserSso(code, state, false);
|
||||||
} else {
|
} else {
|
||||||
window.location.href = window.location.origin + "/#/sso?code=" + code + "&state=" + state;
|
window.location.href = window.location.origin + "/#/sso?code=" + code + "&state=" + state;
|
||||||
|
|||||||
@@ -48,11 +48,7 @@ export class DefaultLoginComponentService implements LoginComponentService {
|
|||||||
special: false,
|
special: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
let state = await this.passwordGenerationService.generatePassword(passwordOptions);
|
const 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 codeVerifier = await this.passwordGenerationService.generatePassword(passwordOptions);
|
const codeVerifier = await this.passwordGenerationService.generatePassword(passwordOptions);
|
||||||
const codeVerifierHash = await this.cryptoFunctionService.hash(codeVerifier, "sha256");
|
const codeVerifierHash = await this.cryptoFunctionService.hash(codeVerifier, "sha256");
|
||||||
@@ -64,20 +60,16 @@ export class DefaultLoginComponentService implements LoginComponentService {
|
|||||||
|
|
||||||
// Build URL
|
// Build URL
|
||||||
const env = await firstValueFrom(this.environmentService.environment$);
|
const env = await firstValueFrom(this.environmentService.environment$);
|
||||||
let url = env.getWebVaultUrl();
|
const webVaultUrl = 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 redirectUri =
|
const redirectUri =
|
||||||
clientId === "browser"
|
clientId === "browser"
|
||||||
? url + "/sso-connector.html" // Browser
|
? webVaultUrl + "/sso-connector.html" // Browser
|
||||||
: "bitwarden://sso-callback"; // Desktop
|
: "bitwarden://sso-callback"; // Desktop
|
||||||
|
|
||||||
// Launch browser window with URL
|
// Launch browser window with URL
|
||||||
this.platformUtilsService.launchUri(
|
this.platformUtilsService.launchUri(
|
||||||
url +
|
webVaultUrl +
|
||||||
"/#/sso?clientId=" +
|
"/#/sso?clientId=" +
|
||||||
clientId +
|
clientId +
|
||||||
"&redirectUri=" +
|
"&redirectUri=" +
|
||||||
|
|||||||
Reference in New Issue
Block a user