mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 16:53:34 +00:00
Merge branch 'main' into autofill/pm-8322-firefox-inline-autofill-not-propagating-correctly-when-switching-tabs
This commit is contained in:
@@ -1,18 +1,19 @@
|
|||||||
import { Component, OnInit, ViewChild, ViewContainerRef } from "@angular/core";
|
import { Component, OnInit, ViewChild, ViewContainerRef } from "@angular/core";
|
||||||
import { ActivatedRoute, Router } from "@angular/router";
|
import { ActivatedRoute } from "@angular/router";
|
||||||
|
import { lastValueFrom } from "rxjs";
|
||||||
import { first } from "rxjs/operators";
|
import { first } from "rxjs/operators";
|
||||||
|
|
||||||
import { ModalService } from "@bitwarden/angular/services/modal.service";
|
|
||||||
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
|
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
|
||||||
import { PolicyApiServiceAbstraction } from "@bitwarden/common/admin-console/abstractions/policy/policy-api.service.abstraction";
|
import { PolicyApiServiceAbstraction } from "@bitwarden/common/admin-console/abstractions/policy/policy-api.service.abstraction";
|
||||||
import { PolicyType } from "@bitwarden/common/admin-console/enums";
|
import { PolicyType } from "@bitwarden/common/admin-console/enums";
|
||||||
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
|
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
|
||||||
import { PolicyResponse } from "@bitwarden/common/admin-console/models/response/policy.response";
|
import { PolicyResponse } from "@bitwarden/common/admin-console/models/response/policy.response";
|
||||||
|
import { DialogService } from "@bitwarden/components";
|
||||||
|
|
||||||
import { PolicyListService } from "../../core/policy-list.service";
|
import { PolicyListService } from "../../core/policy-list.service";
|
||||||
import { BasePolicy } from "../policies";
|
import { BasePolicy } from "../policies";
|
||||||
|
|
||||||
import { PolicyEditComponent } from "./policy-edit.component";
|
import { PolicyEditComponent, PolicyEditDialogResult } from "./policy-edit.component";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "app-org-policies",
|
selector: "app-org-policies",
|
||||||
@@ -33,11 +34,10 @@ export class PoliciesComponent implements OnInit {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private modalService: ModalService,
|
|
||||||
private organizationService: OrganizationService,
|
private organizationService: OrganizationService,
|
||||||
private policyApiService: PolicyApiServiceAbstraction,
|
private policyApiService: PolicyApiServiceAbstraction,
|
||||||
private policyListService: PolicyListService,
|
private policyListService: PolicyListService,
|
||||||
private router: Router,
|
private dialogService: DialogService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
@@ -83,21 +83,17 @@ export class PoliciesComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async edit(policy: BasePolicy) {
|
async edit(policy: BasePolicy) {
|
||||||
const [modal] = await this.modalService.openViewRef(
|
const dialogRef = PolicyEditComponent.open(this.dialogService, {
|
||||||
PolicyEditComponent,
|
data: {
|
||||||
this.editModalRef,
|
policy: policy,
|
||||||
(comp) => {
|
organizationId: this.organizationId,
|
||||||
comp.policy = policy;
|
policiesEnabledMap: this.policiesEnabledMap,
|
||||||
comp.organizationId = this.organizationId;
|
|
||||||
comp.policiesEnabledMap = this.policiesEnabledMap;
|
|
||||||
// eslint-disable-next-line rxjs-angular/prefer-takeuntil
|
|
||||||
comp.onSavedPolicy.subscribe(() => {
|
|
||||||
modal.close();
|
|
||||||
// FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling.
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
||||||
this.load();
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
);
|
});
|
||||||
|
|
||||||
|
const result = await lastValueFrom(dialogRef.closed);
|
||||||
|
if (result === PolicyEditDialogResult.Saved) {
|
||||||
|
await this.load();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,49 +1,28 @@
|
|||||||
<div class="modal fade" role="dialog" aria-modal="true" aria-labelledby="policiesEditTitle">
|
<form [formGroup]="formGroup" [bitSubmit]="submit" [appApiAction]="formPromise">
|
||||||
<div class="modal-dialog modal-dialog-scrollable" role="document">
|
<bit-dialog [loading]="loading">
|
||||||
<form
|
<span bitDialogTitle>{{ "editPolicy" | i18n }} - {{ policy.name | i18n }}</span>
|
||||||
class="modal-content"
|
|
||||||
#form
|
|
||||||
(ngSubmit)="submit()"
|
|
||||||
[appApiAction]="formPromise"
|
|
||||||
ngNativeValidate
|
|
||||||
>
|
|
||||||
<div class="modal-header">
|
|
||||||
<h1 class="modal-title" id="policiesEditTitle">
|
|
||||||
{{ "editPolicy" | i18n }} - {{ policy.name | i18n }}
|
|
||||||
</h1>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
class="close"
|
|
||||||
data-dismiss="modal"
|
|
||||||
appA11yTitle="{{ 'close' | i18n }}"
|
|
||||||
>
|
|
||||||
<span aria-hidden="true">×</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="modal-body">
|
<ng-container bitDialogContent>
|
||||||
<div class="modal-body" *ngIf="loading">
|
<div *ngIf="loading">
|
||||||
<i
|
<i
|
||||||
class="bwi bwi-spinner bwi-spin text-muted"
|
class="bwi bwi-spinner bwi-spin tw-text-muted"
|
||||||
title="{{ 'loading' | i18n }}"
|
title="{{ 'loading' | i18n }}"
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
></i>
|
></i>
|
||||||
<span class="sr-only">{{ "loading" | i18n }}</span>
|
<span class="tw-sr-only">{{ "loading" | i18n }}</span>
|
||||||
</div>
|
|
||||||
<div [hidden]="loading">
|
|
||||||
<p>{{ policy.description | i18n }}</p>
|
|
||||||
<ng-template #policyForm></ng-template>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div [hidden]="loading">
|
||||||
<button type="submit" class="btn btn-primary btn-submit" [disabled]="form.loading">
|
<p bitTypography="body1">{{ policy.description | i18n }}</p>
|
||||||
<i class="bwi bwi-spinner bwi-spin" title="{{ 'loading' | i18n }}" aria-hidden="true"></i>
|
<ng-template #policyForm></ng-template>
|
||||||
<span>{{ "save" | i18n }}</span>
|
|
||||||
</button>
|
|
||||||
<button type="button" class="btn btn-outline-secondary" data-dismiss="modal">
|
|
||||||
{{ "cancel" | i18n }}
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</ng-container>
|
||||||
</div>
|
<ng-container bitDialogFooter>
|
||||||
</div>
|
<button bitButton buttonType="primary" bitFormButton type="submit">
|
||||||
|
{{ "save" | i18n }}
|
||||||
|
</button>
|
||||||
|
<button bitButton buttonType="secondary" bitDialogClose type="button">
|
||||||
|
{{ "cancel" | i18n }}
|
||||||
|
</button>
|
||||||
|
</ng-container>
|
||||||
|
</bit-dialog>
|
||||||
|
</form>
|
||||||
|
|||||||
@@ -1,33 +1,34 @@
|
|||||||
import {
|
import { DIALOG_DATA, DialogConfig, DialogRef } from "@angular/cdk/dialog";
|
||||||
ChangeDetectorRef,
|
import { ChangeDetectorRef, Component, Inject, ViewChild, ViewContainerRef } from "@angular/core";
|
||||||
Component,
|
import { FormBuilder } from "@angular/forms";
|
||||||
EventEmitter,
|
|
||||||
Input,
|
|
||||||
Output,
|
|
||||||
ViewChild,
|
|
||||||
ViewContainerRef,
|
|
||||||
} from "@angular/core";
|
|
||||||
|
|
||||||
import { PolicyApiServiceAbstraction } from "@bitwarden/common/admin-console/abstractions/policy/policy-api.service.abstraction";
|
import { PolicyApiServiceAbstraction } from "@bitwarden/common/admin-console/abstractions/policy/policy-api.service.abstraction";
|
||||||
import { PolicyType } from "@bitwarden/common/admin-console/enums";
|
import { PolicyType } from "@bitwarden/common/admin-console/enums";
|
||||||
import { PolicyRequest } from "@bitwarden/common/admin-console/models/request/policy.request";
|
import { PolicyRequest } from "@bitwarden/common/admin-console/models/request/policy.request";
|
||||||
import { PolicyResponse } from "@bitwarden/common/admin-console/models/response/policy.response";
|
import { PolicyResponse } from "@bitwarden/common/admin-console/models/response/policy.response";
|
||||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
|
||||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||||
|
import { DialogService } from "@bitwarden/components";
|
||||||
|
|
||||||
import { BasePolicy, BasePolicyComponent } from "../policies";
|
import { BasePolicy, BasePolicyComponent } from "../policies";
|
||||||
|
|
||||||
|
export type PolicyEditDialogData = {
|
||||||
|
/** Returns policy abstracts. */
|
||||||
|
policy: BasePolicy;
|
||||||
|
/** Returns a unique organization id */
|
||||||
|
organizationId: string;
|
||||||
|
/** A map indicating whether each policy type is enabled or disabled. */
|
||||||
|
policiesEnabledMap: Map<PolicyType, boolean>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export enum PolicyEditDialogResult {
|
||||||
|
Saved = "saved",
|
||||||
|
}
|
||||||
@Component({
|
@Component({
|
||||||
selector: "app-policy-edit",
|
selector: "app-policy-edit",
|
||||||
templateUrl: "policy-edit.component.html",
|
templateUrl: "policy-edit.component.html",
|
||||||
})
|
})
|
||||||
export class PolicyEditComponent {
|
export class PolicyEditComponent {
|
||||||
@Input() policy: BasePolicy;
|
|
||||||
@Input() organizationId: string;
|
|
||||||
@Input() policiesEnabledMap: Map<PolicyType, boolean> = new Map<PolicyType, boolean>();
|
|
||||||
@Output() onSavedPolicy = new EventEmitter();
|
|
||||||
|
|
||||||
@ViewChild("policyForm", { read: ViewContainerRef, static: true })
|
@ViewChild("policyForm", { read: ViewContainerRef, static: true })
|
||||||
policyFormRef: ViewContainerRef;
|
policyFormRef: ViewContainerRef;
|
||||||
|
|
||||||
@@ -39,22 +40,29 @@ export class PolicyEditComponent {
|
|||||||
policyComponent: BasePolicyComponent;
|
policyComponent: BasePolicyComponent;
|
||||||
|
|
||||||
private policyResponse: PolicyResponse;
|
private policyResponse: PolicyResponse;
|
||||||
|
formGroup = this.formBuilder.group({
|
||||||
|
enabled: [this.enabled],
|
||||||
|
});
|
||||||
constructor(
|
constructor(
|
||||||
|
@Inject(DIALOG_DATA) protected data: PolicyEditDialogData,
|
||||||
private policyApiService: PolicyApiServiceAbstraction,
|
private policyApiService: PolicyApiServiceAbstraction,
|
||||||
private i18nService: I18nService,
|
private i18nService: I18nService,
|
||||||
private platformUtilsService: PlatformUtilsService,
|
private platformUtilsService: PlatformUtilsService,
|
||||||
private cdr: ChangeDetectorRef,
|
private cdr: ChangeDetectorRef,
|
||||||
private logService: LogService,
|
private formBuilder: FormBuilder,
|
||||||
|
private dialogRef: DialogRef<PolicyEditDialogResult>,
|
||||||
) {}
|
) {}
|
||||||
|
get policy(): BasePolicy {
|
||||||
|
return this.data.policy;
|
||||||
|
}
|
||||||
|
|
||||||
async ngAfterViewInit() {
|
async ngAfterViewInit() {
|
||||||
await this.load();
|
await this.load();
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
|
|
||||||
this.policyComponent = this.policyFormRef.createComponent(this.policy.component)
|
this.policyComponent = this.policyFormRef.createComponent(this.data.policy.component)
|
||||||
.instance as BasePolicyComponent;
|
.instance as BasePolicyComponent;
|
||||||
this.policyComponent.policy = this.policy;
|
this.policyComponent.policy = this.data.policy;
|
||||||
this.policyComponent.policyResponse = this.policyResponse;
|
this.policyComponent.policyResponse = this.policyResponse;
|
||||||
|
|
||||||
this.cdr.detectChanges();
|
this.cdr.detectChanges();
|
||||||
@@ -63,8 +71,8 @@ export class PolicyEditComponent {
|
|||||||
async load() {
|
async load() {
|
||||||
try {
|
try {
|
||||||
this.policyResponse = await this.policyApiService.getPolicy(
|
this.policyResponse = await this.policyApiService.getPolicy(
|
||||||
this.organizationId,
|
this.data.organizationId,
|
||||||
this.policy.type,
|
this.data.policy.type,
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e.statusCode === 404) {
|
if (e.statusCode === 404) {
|
||||||
@@ -75,30 +83,29 @@ export class PolicyEditComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async submit() {
|
submit = async () => {
|
||||||
let request: PolicyRequest;
|
let request: PolicyRequest;
|
||||||
try {
|
try {
|
||||||
request = await this.policyComponent.buildRequest(this.policiesEnabledMap);
|
request = await this.policyComponent.buildRequest(this.data.policiesEnabledMap);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.platformUtilsService.showToast("error", null, e.message);
|
this.platformUtilsService.showToast("error", null, e.message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
this.formPromise = this.policyApiService.putPolicy(
|
||||||
|
this.data.organizationId,
|
||||||
|
this.data.policy.type,
|
||||||
|
request,
|
||||||
|
);
|
||||||
|
await this.formPromise;
|
||||||
|
this.platformUtilsService.showToast(
|
||||||
|
"success",
|
||||||
|
null,
|
||||||
|
this.i18nService.t("editedPolicyId", this.i18nService.t(this.data.policy.name)),
|
||||||
|
);
|
||||||
|
this.dialogRef.close(PolicyEditDialogResult.Saved);
|
||||||
|
};
|
||||||
|
|
||||||
try {
|
static open = (dialogService: DialogService, config: DialogConfig<PolicyEditDialogData>) => {
|
||||||
this.formPromise = this.policyApiService.putPolicy(
|
return dialogService.open<PolicyEditDialogResult>(PolicyEditComponent, config);
|
||||||
this.organizationId,
|
};
|
||||||
this.policy.type,
|
|
||||||
request,
|
|
||||||
);
|
|
||||||
await this.formPromise;
|
|
||||||
this.platformUtilsService.showToast(
|
|
||||||
"success",
|
|
||||||
null,
|
|
||||||
this.i18nService.t("editedPolicyId", this.i18nService.t(this.policy.name)),
|
|
||||||
);
|
|
||||||
this.onSavedPolicy.emit();
|
|
||||||
} catch (e) {
|
|
||||||
this.logService.error(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,47 +1,29 @@
|
|||||||
<div [formGroup]="form">
|
<div [formGroup]="form">
|
||||||
<div class="form-group">
|
<bit-form-field>
|
||||||
<label for="vaultTimeout">{{ "vaultTimeout" | i18n }}</label>
|
<bit-label>{{ "vaultTimeout" | i18n }}</bit-label>
|
||||||
<select
|
<bit-select formControlName="vaultTimeout">
|
||||||
id="vaultTimeout"
|
<bit-option
|
||||||
name="VaultTimeout"
|
*ngFor="let o of vaultTimeoutOptions"
|
||||||
formControlName="vaultTimeout"
|
[value]="o.value"
|
||||||
class="form-control"
|
[label]="o.name"
|
||||||
>
|
></bit-option>
|
||||||
<option *ngFor="let o of vaultTimeoutOptions" [ngValue]="o.value">{{ o.name }}</option>
|
</bit-select>
|
||||||
</select>
|
<bit-hint class="tw-text-sm">{{
|
||||||
<small class="form-text text-muted">{{
|
|
||||||
((canLockVault$ | async) ? "vaultTimeoutDesc" : "vaultTimeoutLogoutDesc") | i18n
|
((canLockVault$ | async) ? "vaultTimeoutDesc" : "vaultTimeoutLogoutDesc") | i18n
|
||||||
}}</small>
|
}}</bit-hint>
|
||||||
</div>
|
</bit-form-field>
|
||||||
<div class="form-group" *ngIf="showCustom" formGroupName="custom">
|
<div class="tw-grid tw-grid-cols-12 tw-gap-4" *ngIf="showCustom" formGroupName="custom">
|
||||||
<label for="customVaultTimeout">{{ "customVaultTimeout" | i18n }}</label>
|
<bit-form-field class="tw-col-span-6">
|
||||||
<div class="row">
|
<bit-label>{{ "customVaultTimeout" | i18n }}</bit-label>
|
||||||
<div class="col-6">
|
<input bitInput type="number" min="0" formControlName="hours" />
|
||||||
<input
|
<bit-hint>{{ "hours" | i18n }}</bit-hint>
|
||||||
id="hours"
|
</bit-form-field>
|
||||||
class="form-control"
|
<bit-form-field class="tw-col-span-6 tw-self-end">
|
||||||
type="number"
|
<input bitInput type="number" min="0" name="minutes" formControlName="minutes" />
|
||||||
min="0"
|
<bit-hint>{{ "minutes" | i18n }}</bit-hint>
|
||||||
name="hours"
|
</bit-form-field>
|
||||||
formControlName="hours"
|
|
||||||
/>
|
|
||||||
<small>{{ "hours" | i18n }}</small>
|
|
||||||
</div>
|
|
||||||
<div class="col-6">
|
|
||||||
<input
|
|
||||||
id="minutes"
|
|
||||||
class="form-control"
|
|
||||||
type="number"
|
|
||||||
min="0"
|
|
||||||
name="minutes"
|
|
||||||
formControlName="minutes"
|
|
||||||
/>
|
|
||||||
<small>{{ "minutes" | i18n }}</small>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<small *ngIf="!exceedsMinimumTimout" class="tw-text-danger">
|
|
||||||
<i class="bwi bwi-error" aria-hidden="true"></i> {{ "vaultCustomTimeoutMinimum" | i18n }}
|
|
||||||
</small>
|
|
||||||
</div>
|
</div>
|
||||||
|
<small *ngIf="!exceedsMinimumTimout" class="tw-text-danger">
|
||||||
|
<i class="bwi bwi-error" aria-hidden="true"></i> {{ "vaultCustomTimeoutMinimum" | i18n }}
|
||||||
|
</small>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,39 +1,21 @@
|
|||||||
<app-header></app-header>
|
<app-header></app-header>
|
||||||
|
|
||||||
<p>{{ "scimDescription" | i18n }}</p>
|
<p bitTypography="body1">{{ "scimDescription" | i18n }}</p>
|
||||||
|
|
||||||
<div *ngIf="loading">
|
<div *ngIf="loading">
|
||||||
<i
|
<i
|
||||||
class="bwi bwi-spinner bwi-spin text-muted"
|
class="bwi bwi-spinner bwi-spin tw-text-muted"
|
||||||
title="{{ 'loading' | i18n }}"
|
title="{{ 'loading' | i18n }}"
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
></i>
|
></i>
|
||||||
<span class="sr-only">{{ "loading" | i18n }}</span>
|
<span class="tw-sr-only">{{ "loading" | i18n }}</span>
|
||||||
</div>
|
</div>
|
||||||
<form
|
<form [bitSubmit]="submit" [formGroup]="formData" *ngIf="!loading">
|
||||||
#form
|
<bit-form-control>
|
||||||
(ngSubmit)="submit()"
|
<input type="checkbox" bitCheckbox [formControl]="enabled" />
|
||||||
[appApiAction]="formPromise"
|
<bit-label>{{ "scimEnabledCheckboxDesc" | i18n }}</bit-label>
|
||||||
[formGroup]="formData"
|
<bit-hint>{{ "scimEnabledCheckboxDescHelpText" | i18n }}</bit-hint>
|
||||||
*ngIf="!loading"
|
</bit-form-control>
|
||||||
>
|
|
||||||
<div class="form-group">
|
|
||||||
<div class="form-check">
|
|
||||||
<input
|
|
||||||
class="form-check-input"
|
|
||||||
type="checkbox"
|
|
||||||
id="enabled"
|
|
||||||
[formControl]="enabled"
|
|
||||||
name="Enabled"
|
|
||||||
aria-describedby="scimEnabledCheckboxDescHelpText"
|
|
||||||
/>
|
|
||||||
<label class="form-check-label" for="enabled">{{ "scimEnabledCheckboxDesc" | i18n }}</label>
|
|
||||||
<div id="scimEnabledCheckboxDescHelpText">
|
|
||||||
<small class="form-text text-muted">{{ "scimEnabledCheckboxDescHelpText" | i18n }}</small>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<bit-form-field *ngIf="showScimSettings">
|
<bit-form-field *ngIf="showScimSettings">
|
||||||
<bit-label>{{ "scimUrl" | i18n }}</bit-label>
|
<bit-label>{{ "scimUrl" | i18n }}</bit-label>
|
||||||
<input bitInput type="text" formControlName="endpointUrl" />
|
<input bitInput type="text" formControlName="endpointUrl" />
|
||||||
@@ -41,7 +23,7 @@
|
|||||||
type="button"
|
type="button"
|
||||||
bitSuffix
|
bitSuffix
|
||||||
bitIconButton="bwi-clone"
|
bitIconButton="bwi-clone"
|
||||||
(click)="copyScimUrl()"
|
[bitAction]="copyScimUrl"
|
||||||
[appA11yTitle]="'copyScimUrl' | i18n"
|
[appA11yTitle]="'copyScimUrl' | i18n"
|
||||||
></button>
|
></button>
|
||||||
</bit-form-field>
|
</bit-form-field>
|
||||||
@@ -54,44 +36,32 @@
|
|||||||
formControlName="clientSecret"
|
formControlName="clientSecret"
|
||||||
id="clientSecret"
|
id="clientSecret"
|
||||||
/>
|
/>
|
||||||
<ng-container>
|
<button
|
||||||
<button
|
type="button"
|
||||||
type="button"
|
bitSuffix
|
||||||
bitSuffix
|
[bitIconButton]="showScimKey ? 'bwi-eye-slash' : 'bwi-eye'"
|
||||||
[disabled]="$any(rotateButton).loading"
|
[bitAction]="toggleScimKey"
|
||||||
[bitIconButton]="showScimKey ? 'bwi-eye-slash' : 'bwi-eye'"
|
[appA11yTitle]="'toggleVisibility' | i18n"
|
||||||
(click)="toggleScimKey()"
|
></button>
|
||||||
[appA11yTitle]="'toggleVisibility' | i18n"
|
<button
|
||||||
></button>
|
type="button"
|
||||||
</ng-container>
|
bitSuffix
|
||||||
<ng-container #rotateButton [appApiAction]="rotatePromise">
|
bitIconButton="bwi-generate"
|
||||||
<!-- TODO: Convert to async actions -->
|
[bitAction]="rotateScimKey"
|
||||||
<button
|
bitFormButton
|
||||||
[loading]="$any(rotateButton).loading"
|
[appA11yTitle]="'rotateScimKey' | i18n"
|
||||||
type="button"
|
></button>
|
||||||
bitSuffix
|
|
||||||
bitIconButton="bwi-generate"
|
|
||||||
(click)="rotateScimKey()"
|
|
||||||
[appA11yTitle]="'rotateScimKey' | i18n"
|
|
||||||
></button>
|
|
||||||
</ng-container>
|
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
bitSuffix
|
bitSuffix
|
||||||
bitIconButton="bwi-clone"
|
bitIconButton="bwi-clone"
|
||||||
(click)="copyScimKey()"
|
[bitAction]="copyScimKey"
|
||||||
[appA11yTitle]="'copyScimKey' | i18n"
|
[appA11yTitle]="'copyScimKey' | i18n"
|
||||||
></button>
|
></button>
|
||||||
<bit-hint>{{ "scimApiKeyHelperText" | i18n }}</bit-hint>
|
<bit-hint>{{ "scimApiKeyHelperText" | i18n }}</bit-hint>
|
||||||
</bit-form-field>
|
</bit-form-field>
|
||||||
|
|
||||||
<button
|
<button type="submit" buttonType="primary" bitButton bitFormButton>
|
||||||
type="submit"
|
|
||||||
buttonType="primary"
|
|
||||||
bitButton
|
|
||||||
[loading]="form.loading"
|
|
||||||
[disabled]="form.loading"
|
|
||||||
>
|
|
||||||
{{ "save" | i18n }}
|
{{ "save" | i18n }}
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import { OrganizationApiKeyRequest } from "@bitwarden/common/admin-console/model
|
|||||||
import { OrganizationConnectionRequest } from "@bitwarden/common/admin-console/models/request/organization-connection.request";
|
import { OrganizationConnectionRequest } from "@bitwarden/common/admin-console/models/request/organization-connection.request";
|
||||||
import { ScimConfigRequest } from "@bitwarden/common/admin-console/models/request/scim-config.request";
|
import { ScimConfigRequest } from "@bitwarden/common/admin-console/models/request/scim-config.request";
|
||||||
import { OrganizationConnectionResponse } from "@bitwarden/common/admin-console/models/response/organization-connection.response";
|
import { OrganizationConnectionResponse } from "@bitwarden/common/admin-console/models/response/organization-connection.response";
|
||||||
import { ApiKeyResponse } from "@bitwarden/common/auth/models/response/api-key.response";
|
|
||||||
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.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";
|
||||||
@@ -29,8 +28,6 @@ export class ScimComponent implements OnInit {
|
|||||||
loading = true;
|
loading = true;
|
||||||
organizationId: string;
|
organizationId: string;
|
||||||
existingConnectionId: string;
|
existingConnectionId: string;
|
||||||
formPromise: Promise<OrganizationConnectionResponse<ScimConfigApi>>;
|
|
||||||
rotatePromise: Promise<ApiKeyResponse>;
|
|
||||||
enabled = new FormControl(false);
|
enabled = new FormControl(false);
|
||||||
showScimSettings = false;
|
showScimSettings = false;
|
||||||
showScimKey = false;
|
showScimKey = false;
|
||||||
@@ -82,11 +79,11 @@ export class ScimComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async copyScimUrl() {
|
copyScimUrl = async () => {
|
||||||
this.platformUtilsService.copyToClipboard(await this.getScimEndpointUrl());
|
this.platformUtilsService.copyToClipboard(await this.getScimEndpointUrl());
|
||||||
}
|
};
|
||||||
|
|
||||||
async rotateScimKey() {
|
rotateScimKey = async () => {
|
||||||
const confirmed = await this.dialogService.openSimpleDialog({
|
const confirmed = await this.dialogService.openSimpleDialog({
|
||||||
title: { key: "rotateScimKey" },
|
title: { key: "rotateScimKey" },
|
||||||
content: { key: "rotateScimKeyWarning" },
|
content: { key: "rotateScimKeyWarning" },
|
||||||
@@ -102,62 +99,50 @@ export class ScimComponent implements OnInit {
|
|||||||
request.type = OrganizationApiKeyType.Scim;
|
request.type = OrganizationApiKeyType.Scim;
|
||||||
request.masterPasswordHash = "N/A";
|
request.masterPasswordHash = "N/A";
|
||||||
|
|
||||||
this.rotatePromise = this.organizationApiService.rotateApiKey(this.organizationId, request);
|
const response = await this.organizationApiService.rotateApiKey(this.organizationId, request);
|
||||||
|
this.formData.setValue({
|
||||||
|
endpointUrl: await this.getScimEndpointUrl(),
|
||||||
|
clientSecret: response.apiKey,
|
||||||
|
});
|
||||||
|
this.platformUtilsService.showToast("success", null, this.i18nService.t("scimApiKeyRotated"));
|
||||||
|
};
|
||||||
|
|
||||||
try {
|
copyScimKey = async () => {
|
||||||
const response = await this.rotatePromise;
|
|
||||||
this.formData.setValue({
|
|
||||||
endpointUrl: await this.getScimEndpointUrl(),
|
|
||||||
clientSecret: response.apiKey,
|
|
||||||
});
|
|
||||||
this.platformUtilsService.showToast("success", null, this.i18nService.t("scimApiKeyRotated"));
|
|
||||||
} catch {
|
|
||||||
// Logged by appApiAction, do nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
this.rotatePromise = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
async copyScimKey() {
|
|
||||||
this.platformUtilsService.copyToClipboard(this.formData.get("clientSecret").value);
|
this.platformUtilsService.copyToClipboard(this.formData.get("clientSecret").value);
|
||||||
}
|
};
|
||||||
|
|
||||||
async submit() {
|
submit = async () => {
|
||||||
try {
|
const request = new OrganizationConnectionRequest(
|
||||||
const request = new OrganizationConnectionRequest(
|
this.organizationId,
|
||||||
this.organizationId,
|
OrganizationConnectionType.Scim,
|
||||||
OrganizationConnectionType.Scim,
|
true,
|
||||||
true,
|
new ScimConfigRequest(this.enabled.value),
|
||||||
new ScimConfigRequest(this.enabled.value),
|
);
|
||||||
|
let response: OrganizationConnectionResponse<ScimConfigApi>;
|
||||||
|
|
||||||
|
if (this.existingConnectionId == null) {
|
||||||
|
response = await this.apiService.createOrganizationConnection(request, ScimConfigApi);
|
||||||
|
} else {
|
||||||
|
response = await this.apiService.updateOrganizationConnection(
|
||||||
|
request,
|
||||||
|
ScimConfigApi,
|
||||||
|
this.existingConnectionId,
|
||||||
);
|
);
|
||||||
if (this.existingConnectionId == null) {
|
|
||||||
this.formPromise = this.apiService.createOrganizationConnection(request, ScimConfigApi);
|
|
||||||
} else {
|
|
||||||
this.formPromise = this.apiService.updateOrganizationConnection(
|
|
||||||
request,
|
|
||||||
ScimConfigApi,
|
|
||||||
this.existingConnectionId,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
const response = (await this.formPromise) as OrganizationConnectionResponse<ScimConfigApi>;
|
|
||||||
await this.setConnectionFormValues(response);
|
|
||||||
this.platformUtilsService.showToast("success", null, this.i18nService.t("scimSettingsSaved"));
|
|
||||||
} catch (e) {
|
|
||||||
// Logged by appApiAction, do nothing
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.formPromise = null;
|
await this.setConnectionFormValues(response);
|
||||||
}
|
this.platformUtilsService.showToast("success", null, this.i18nService.t("scimSettingsSaved"));
|
||||||
|
};
|
||||||
|
|
||||||
async getScimEndpointUrl() {
|
async getScimEndpointUrl() {
|
||||||
const env = await firstValueFrom(this.environmentService.environment$);
|
const env = await firstValueFrom(this.environmentService.environment$);
|
||||||
return env.getScimUrl() + "/" + this.organizationId;
|
return env.getScimUrl() + "/" + this.organizationId;
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleScimKey() {
|
toggleScimKey = () => {
|
||||||
this.showScimKey = !this.showScimKey;
|
this.showScimKey = !this.showScimKey;
|
||||||
document.getElementById("clientSecret").focus();
|
document.getElementById("clientSecret").focus();
|
||||||
}
|
};
|
||||||
|
|
||||||
private async setConnectionFormValues(connection: OrganizationConnectionResponse<ScimConfigApi>) {
|
private async setConnectionFormValues(connection: OrganizationConnectionResponse<ScimConfigApi>) {
|
||||||
this.existingConnectionId = connection?.id;
|
this.existingConnectionId = connection?.id;
|
||||||
|
|||||||
8
package-lock.json
generated
8
package-lock.json
generated
@@ -99,7 +99,7 @@
|
|||||||
"@types/firefox-webext-browser": "111.0.5",
|
"@types/firefox-webext-browser": "111.0.5",
|
||||||
"@types/inquirer": "8.2.10",
|
"@types/inquirer": "8.2.10",
|
||||||
"@types/jest": "29.5.12",
|
"@types/jest": "29.5.12",
|
||||||
"@types/jquery": "3.5.29",
|
"@types/jquery": "3.5.30",
|
||||||
"@types/jsdom": "21.1.6",
|
"@types/jsdom": "21.1.6",
|
||||||
"@types/koa": "2.14.0",
|
"@types/koa": "2.14.0",
|
||||||
"@types/koa__multer": "2.0.7",
|
"@types/koa__multer": "2.0.7",
|
||||||
@@ -10340,9 +10340,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/@types/jquery": {
|
"node_modules/@types/jquery": {
|
||||||
"version": "3.5.29",
|
"version": "3.5.30",
|
||||||
"resolved": "https://registry.npmjs.org/@types/jquery/-/jquery-3.5.29.tgz",
|
"resolved": "https://registry.npmjs.org/@types/jquery/-/jquery-3.5.30.tgz",
|
||||||
"integrity": "sha512-oXQQC9X9MOPRrMhPHHOsXqeQDnWeCDT3PelUIg/Oy8FAbzSZtFHRjc7IpbfFVmpLtJ+UOoywpRsuO5Jxjybyeg==",
|
"integrity": "sha512-nbWKkkyb919DOUxjmRVk8vwtDb0/k8FKncmUKFi+NY+QXqWltooxTrswvz4LspQwxvLdvzBN1TImr6cw3aQx2A==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/sizzle": "*"
|
"@types/sizzle": "*"
|
||||||
|
|||||||
@@ -60,7 +60,7 @@
|
|||||||
"@types/firefox-webext-browser": "111.0.5",
|
"@types/firefox-webext-browser": "111.0.5",
|
||||||
"@types/inquirer": "8.2.10",
|
"@types/inquirer": "8.2.10",
|
||||||
"@types/jest": "29.5.12",
|
"@types/jest": "29.5.12",
|
||||||
"@types/jquery": "3.5.29",
|
"@types/jquery": "3.5.30",
|
||||||
"@types/jsdom": "21.1.6",
|
"@types/jsdom": "21.1.6",
|
||||||
"@types/koa": "2.14.0",
|
"@types/koa": "2.14.0",
|
||||||
"@types/koa__multer": "2.0.7",
|
"@types/koa__multer": "2.0.7",
|
||||||
|
|||||||
Reference in New Issue
Block a user