2020-07-16 15:18:25 +02:00
|
|
|
import { Component } from "@angular/core";
|
|
|
|
import { ActivatedRoute, Router } from "@angular/router";
|
2021-10-15 00:59:43 +02:00
|
|
|
import { first } from "rxjs/operators";
|
|
|
|
|
2022-06-14 17:10:53 +02:00
|
|
|
import { SsoComponent as BaseSsoComponent } from "@bitwarden/angular/components/sso.component";
|
|
|
|
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
|
|
|
import { AuthService } from "@bitwarden/common/abstractions/auth.service";
|
|
|
|
import { CryptoFunctionService } from "@bitwarden/common/abstractions/cryptoFunction.service";
|
|
|
|
import { EnvironmentService } from "@bitwarden/common/abstractions/environment.service";
|
|
|
|
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
|
|
|
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
|
|
|
import { PasswordGenerationService } from "@bitwarden/common/abstractions/passwordGeneration.service";
|
|
|
|
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
|
|
|
import { StateService } from "@bitwarden/common/abstractions/state.service";
|
2020-07-16 15:18:25 +02:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: "app-sso",
|
|
|
|
templateUrl: "sso.component.html",
|
|
|
|
})
|
2020-08-13 20:32:07 +02:00
|
|
|
export class SsoComponent extends BaseSsoComponent {
|
|
|
|
constructor(
|
|
|
|
authService: AuthService,
|
|
|
|
router: Router,
|
|
|
|
i18nService: I18nService,
|
|
|
|
route: ActivatedRoute,
|
2021-12-14 17:10:26 +01:00
|
|
|
stateService: StateService,
|
|
|
|
platformUtilsService: PlatformUtilsService,
|
|
|
|
apiService: ApiService,
|
|
|
|
cryptoFunctionService: CryptoFunctionService,
|
|
|
|
environmentService: EnvironmentService,
|
|
|
|
passwordGenerationService: PasswordGenerationService,
|
|
|
|
logService: LogService
|
|
|
|
) {
|
|
|
|
super(
|
|
|
|
authService,
|
|
|
|
router,
|
|
|
|
i18nService,
|
|
|
|
route,
|
|
|
|
stateService,
|
|
|
|
platformUtilsService,
|
2021-10-20 18:30:04 +02:00
|
|
|
apiService,
|
2021-10-15 00:59:43 +02:00
|
|
|
cryptoFunctionService,
|
2021-12-14 17:10:26 +01:00
|
|
|
environmentService,
|
|
|
|
passwordGenerationService,
|
2021-10-20 18:30:04 +02:00
|
|
|
logService
|
2021-12-14 17:10:26 +01:00
|
|
|
);
|
|
|
|
this.redirectUri = window.location.origin + "/sso-connector.html";
|
2020-08-20 22:39:05 +02:00
|
|
|
this.clientId = "web";
|
|
|
|
}
|
|
|
|
|
|
|
|
async ngOnInit() {
|
|
|
|
super.ngOnInit();
|
|
|
|
this.route.queryParams.pipe(first()).subscribe(async (qParams) => {
|
|
|
|
if (qParams.identifier != null) {
|
2021-12-14 17:10:26 +01:00
|
|
|
this.identifier = qParams.identifier;
|
|
|
|
} else {
|
|
|
|
const storedIdentifier = await this.stateService.getSsoOrgIdentifier();
|
2020-11-25 22:57:11 +01:00
|
|
|
if (storedIdentifier != null) {
|
2020-12-22 17:28:58 +01:00
|
|
|
this.identifier = storedIdentifier;
|
2020-11-25 22:57:11 +01:00
|
|
|
}
|
2021-12-17 15:57:11 +01:00
|
|
|
}
|
2020-08-20 22:39:05 +02:00
|
|
|
});
|
2021-12-17 15:57:11 +01:00
|
|
|
}
|
|
|
|
|
2020-08-20 22:39:05 +02:00
|
|
|
async submit() {
|
|
|
|
await this.stateService.setSsoOrganizationIdentifier(this.identifier);
|
2020-11-25 22:57:11 +01:00
|
|
|
if (this.clientId === "browser") {
|
2020-12-22 17:28:58 +01:00
|
|
|
document.cookie = `ssoHandOffMessage=${this.i18nService.t("ssoHandOff")};SameSite=strict`;
|
2020-08-20 22:39:05 +02:00
|
|
|
}
|
|
|
|
super.submit();
|
2021-12-17 15:57:11 +01:00
|
|
|
}
|
2020-07-16 15:18:25 +02:00
|
|
|
}
|