Skip to content

Commit 7386a4f

Browse files
[PM-19306] - [Vault] In Admin Console Policies area add the remove card item type policy (#15065)
* WIP - add restricted item types policy * admin console restricted item types * add comment * update feature flag * fix comment
1 parent 0032d14 commit 7386a4f

File tree

7 files changed

+49
-1
lines changed

7 files changed

+49
-1
lines changed

apps/web/src/app/admin-console/organizations/policies/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ export { SingleOrgPolicy } from "./single-org.component";
1111
export { TwoFactorAuthenticationPolicy } from "./two-factor-authentication.component";
1212
export { PoliciesComponent } from "./policies.component";
1313
export { RemoveUnlockWithPinPolicy } from "./remove-unlock-with-pin.component";
14+
export { RestrictedItemTypesPolicy } from "./restricted-item-types.component";

apps/web/src/app/admin-console/organizations/policies/policies.component.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import { Organization } from "@bitwarden/common/admin-console/models/domain/orga
1515
import { PolicyResponse } from "@bitwarden/common/admin-console/models/response/policy.response";
1616
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
1717
import { OrganizationBillingServiceAbstraction } from "@bitwarden/common/billing/abstractions";
18+
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
19+
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
1820
import { DialogService } from "@bitwarden/components";
1921
import {
2022
ChangePlanDialogResultType,
@@ -23,7 +25,7 @@ import {
2325
import { All } from "@bitwarden/web-vault/app/vault/individual-vault/vault-filter/shared/models/routed-vault-filter.model";
2426

2527
import { PolicyListService } from "../../core/policy-list.service";
26-
import { BasePolicy } from "../policies";
28+
import { BasePolicy, RestrictedItemTypesPolicy } from "../policies";
2729
import { CollectionDialogTabType } from "../shared/components/collection-dialog";
2830

2931
import { PolicyEditComponent, PolicyEditDialogResult } from "./policy-edit.component";
@@ -51,6 +53,7 @@ export class PoliciesComponent implements OnInit {
5153
private policyListService: PolicyListService,
5254
private organizationBillingService: OrganizationBillingServiceAbstraction,
5355
private dialogService: DialogService,
56+
private configService: ConfigService,
5457
) {}
5558

5659
async ngOnInit() {
@@ -91,6 +94,12 @@ export class PoliciesComponent implements OnInit {
9194
}
9295

9396
async load() {
97+
if (
98+
(await this.configService.getFeatureFlag(FeatureFlag.RemoveCardItemTypePolicy)) &&
99+
this.policyListService.getPolicies().every((p) => !(p instanceof RestrictedItemTypesPolicy))
100+
) {
101+
this.policyListService.addPolicies([new RestrictedItemTypesPolicy()]);
102+
}
94103
const response = await this.policyApiService.getPolicies(this.organizationId);
95104
this.orgPolicies = response.data != null && response.data.length > 0 ? response.data : [];
96105
this.orgPolicies.forEach((op) => {

apps/web/src/app/admin-console/organizations/policies/policies.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { PolicyEditComponent } from "./policy-edit.component";
1111
import { RemoveUnlockWithPinPolicyComponent } from "./remove-unlock-with-pin.component";
1212
import { RequireSsoPolicyComponent } from "./require-sso.component";
1313
import { ResetPasswordPolicyComponent } from "./reset-password.component";
14+
import { RestrictedItemTypesPolicyComponent } from "./restricted-item-types.component";
1415
import { SendOptionsPolicyComponent } from "./send-options.component";
1516
import { SingleOrgPolicyComponent } from "./single-org.component";
1617
import { TwoFactorAuthenticationPolicyComponent } from "./two-factor-authentication.component";
@@ -30,6 +31,7 @@ import { TwoFactorAuthenticationPolicyComponent } from "./two-factor-authenticat
3031
PoliciesComponent,
3132
PolicyEditComponent,
3233
RemoveUnlockWithPinPolicyComponent,
34+
RestrictedItemTypesPolicyComponent,
3335
],
3436
exports: [
3537
DisableSendPolicyComponent,
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<bit-form-control>
2+
<input type="checkbox" bitCheckbox [formControl]="enabled" id="enabled" />
3+
<bit-label>{{ "turnOn" | i18n }}</bit-label>
4+
</bit-form-control>
5+
<!-- To allow for multiple item types we can add a data formGroup, iterate over the
6+
cipher types as checkboxes/multi-select and use that as a means to track which types are restricted -->
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { Component } from "@angular/core";
2+
3+
import { PolicyType } from "@bitwarden/common/admin-console/enums";
4+
5+
import { BasePolicy, BasePolicyComponent } from "./base-policy.component";
6+
7+
export class RestrictedItemTypesPolicy extends BasePolicy {
8+
name = "restrictedItemTypesPolicy";
9+
description = "restrictedItemTypesPolicyDesc";
10+
type = PolicyType.RestrictedItemTypesPolicy;
11+
component = RestrictedItemTypesPolicyComponent;
12+
}
13+
14+
@Component({
15+
selector: "policy-restricted-item-types",
16+
templateUrl: "restricted-item-types.component.html",
17+
standalone: false,
18+
})
19+
export class RestrictedItemTypesPolicyComponent extends BasePolicyComponent {
20+
constructor() {
21+
super();
22+
}
23+
}

apps/web/src/locales/en/messages.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2154,6 +2154,12 @@
21542154
"twoStepLoginRecoveryWarning": {
21552155
"message": "Setting up two-step login can permanently lock you out of your Bitwarden account. A recovery code allows you to access your account in the event that you can no longer use your normal two-step login provider (example: you lose your device). Bitwarden support will not be able to assist you if you lose access to your account. We recommend you write down or print the recovery code and keep it in a safe place."
21562156
},
2157+
"restrictedItemTypesPolicy": {
2158+
"message": "Remove card item type"
2159+
},
2160+
"restrictedItemTypesPolicyDesc": {
2161+
"message": "Do not allow members to create card item types."
2162+
},
21572163
"yourSingleUseRecoveryCode": {
21582164
"message": "Your single-use recovery code can be used to turn off two-step login in the event that you lose access to your two-step login provider. Bitwarden recommends you write down the recovery code and keep it in a safe place."
21592165
},

libs/common/src/admin-console/enums/policy-type.enum.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ export enum PolicyType {
1616
AutomaticAppLogIn = 12, // Enables automatic log in of apps from configured identity provider
1717
FreeFamiliesSponsorshipPolicy = 13, // Disables free families plan for organization
1818
RemoveUnlockWithPin = 14, // Do not allow members to unlock their account with a PIN.
19+
RestrictedItemTypesPolicy = 15, // Restricts item types that can be created within an organization
1920
}

0 commit comments

Comments
 (0)