mirror of
https://github.com/bitwarden/browser
synced 2025-12-12 14:23:32 +00:00
feat(sso-config): (Auth) [PM-18470] Pre-populate Key Connector URL (#16536)
On the SSO Config page, when Key Connector is a valid option, setup a listener to changes to the Member Decryption Options form radio selection: - If radio selection is Key Connector: set a default URL - If radio selection is NOT Key Connector: clear the URL
This commit is contained in:
@@ -9,7 +9,7 @@ import {
|
|||||||
Validators,
|
Validators,
|
||||||
} from "@angular/forms";
|
} from "@angular/forms";
|
||||||
import { ActivatedRoute } from "@angular/router";
|
import { ActivatedRoute } from "@angular/router";
|
||||||
import { concatMap, firstValueFrom, Subject, takeUntil } from "rxjs";
|
import { concatMap, firstValueFrom, Subject, switchMap, takeUntil } from "rxjs";
|
||||||
|
|
||||||
import { ControlsOf } from "@bitwarden/angular/types/controls-of";
|
import { ControlsOf } from "@bitwarden/angular/types/controls-of";
|
||||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||||
@@ -34,6 +34,7 @@ import { OrganizationSsoRequest } from "@bitwarden/common/auth/models/request/or
|
|||||||
import { OrganizationSsoResponse } from "@bitwarden/common/auth/models/response/organization-sso.response";
|
import { OrganizationSsoResponse } from "@bitwarden/common/auth/models/response/organization-sso.response";
|
||||||
import { SsoConfigView } from "@bitwarden/common/auth/models/view/sso-config.view";
|
import { SsoConfigView } from "@bitwarden/common/auth/models/view/sso-config.view";
|
||||||
import { getUserId } from "@bitwarden/common/auth/services/account.service";
|
import { getUserId } from "@bitwarden/common/auth/services/account.service";
|
||||||
|
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
|
||||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||||
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
||||||
@@ -203,6 +204,7 @@ export class SsoComponent implements OnInit, OnDestroy {
|
|||||||
private accountService: AccountService,
|
private accountService: AccountService,
|
||||||
private organizationApiService: OrganizationApiServiceAbstraction,
|
private organizationApiService: OrganizationApiServiceAbstraction,
|
||||||
private toastService: ToastService,
|
private toastService: ToastService,
|
||||||
|
private environmentService: EnvironmentService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
@@ -253,6 +255,32 @@ export class SsoComponent implements OnInit, OnDestroy {
|
|||||||
.subscribe();
|
.subscribe();
|
||||||
|
|
||||||
this.showKeyConnectorOptions = this.platformUtilsService.isSelfHost();
|
this.showKeyConnectorOptions = this.platformUtilsService.isSelfHost();
|
||||||
|
|
||||||
|
// Only setup listener if key connector is a possible selection
|
||||||
|
if (this.showKeyConnectorOptions) {
|
||||||
|
this.listenForKeyConnectorSelection();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
listenForKeyConnectorSelection() {
|
||||||
|
this.ssoConfigForm?.controls?.memberDecryptionType.valueChanges
|
||||||
|
.pipe(
|
||||||
|
switchMap(async (memberDecryptionType) => {
|
||||||
|
if (memberDecryptionType === MemberDecryptionType.KeyConnector) {
|
||||||
|
// Pre-populate a default key connector URL (user can still change it)
|
||||||
|
const env = await firstValueFrom(this.environmentService.environment$);
|
||||||
|
const webVaultUrl = env.getWebVaultUrl();
|
||||||
|
const defaultKeyConnectorUrl = webVaultUrl + "/key-connector/";
|
||||||
|
|
||||||
|
this.ssoConfigForm.controls.keyConnectorUrl.setValue(defaultKeyConnectorUrl);
|
||||||
|
} else {
|
||||||
|
// Otherwise clear the key connector URL
|
||||||
|
this.ssoConfigForm.controls.keyConnectorUrl.setValue("");
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
takeUntil(this.destroy$),
|
||||||
|
)
|
||||||
|
.subscribe();
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy(): void {
|
ngOnDestroy(): void {
|
||||||
|
|||||||
Reference in New Issue
Block a user