From 853db233d945bea11bef45fb6df31491a610c50b Mon Sep 17 00:00:00 2001 From: Thomas Rittson <31796059+eliykat@users.noreply.github.com> Date: Wed, 4 Dec 2024 11:50:39 +1000 Subject: [PATCH] Remove AddPolicyDefinitions feature flag (#12172) --- .../policies/base-policy.component.ts | 2 +- .../policies/policies.component.ts | 1 - .../policies/policy-edit.component.ts | 6 +-- .../policies/require-sso.component.ts | 27 +----------- .../policies/single-org.component.ts | 42 +------------------ .../maximum-vault-timeout.component.ts | 13 ++---- libs/common/src/enums/feature-flag.enum.ts | 2 - 7 files changed, 8 insertions(+), 85 deletions(-) diff --git a/apps/web/src/app/admin-console/organizations/policies/base-policy.component.ts b/apps/web/src/app/admin-console/organizations/policies/base-policy.component.ts index d6576985fd9..968068e1058 100644 --- a/apps/web/src/app/admin-console/organizations/policies/base-policy.component.ts +++ b/apps/web/src/app/admin-console/organizations/policies/base-policy.component.ts @@ -45,7 +45,7 @@ export abstract class BasePolicyComponent implements OnInit { return null; } - buildRequest(policiesEnabledMap: Map) { + buildRequest() { const request = new PolicyRequest(); request.enabled = this.enabled.value; request.type = this.policy.type; diff --git a/apps/web/src/app/admin-console/organizations/policies/policies.component.ts b/apps/web/src/app/admin-console/organizations/policies/policies.component.ts index 782db231c69..4c35fef409a 100644 --- a/apps/web/src/app/admin-console/organizations/policies/policies.component.ts +++ b/apps/web/src/app/admin-console/organizations/policies/policies.component.ts @@ -87,7 +87,6 @@ export class PoliciesComponent implements OnInit { data: { policy: policy, organizationId: this.organizationId, - policiesEnabledMap: this.policiesEnabledMap, }, }); diff --git a/apps/web/src/app/admin-console/organizations/policies/policy-edit.component.ts b/apps/web/src/app/admin-console/organizations/policies/policy-edit.component.ts index 6a869aff227..a0a747811ff 100644 --- a/apps/web/src/app/admin-console/organizations/policies/policy-edit.component.ts +++ b/apps/web/src/app/admin-console/organizations/policies/policy-edit.component.ts @@ -15,7 +15,6 @@ import { PolicyType } from "@bitwarden/common/admin-console/enums"; import { PolicyRequest } from "@bitwarden/common/admin-console/models/request/policy.request"; import { PolicyResponse } from "@bitwarden/common/admin-console/models/response/policy.response"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; -import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service"; import { DialogService, ToastService } from "@bitwarden/components"; import { BasePolicy, BasePolicyComponent } from "../policies"; @@ -25,8 +24,6 @@ export type PolicyEditDialogData = { policy: BasePolicy; /** Returns a unique organization id */ organizationId: string; - /** A map indicating whether each policy type is enabled or disabled. */ - policiesEnabledMap: Map; }; export enum PolicyEditDialogResult { @@ -55,7 +52,6 @@ export class PolicyEditComponent implements AfterViewInit { @Inject(DIALOG_DATA) protected data: PolicyEditDialogData, private policyApiService: PolicyApiServiceAbstraction, private i18nService: I18nService, - private platformUtilsService: PlatformUtilsService, private cdr: ChangeDetectorRef, private formBuilder: FormBuilder, private dialogRef: DialogRef, @@ -99,7 +95,7 @@ export class PolicyEditComponent implements AfterViewInit { submit = async () => { let request: PolicyRequest; try { - request = await this.policyComponent.buildRequest(this.data.policiesEnabledMap); + request = await this.policyComponent.buildRequest(); } catch (e) { this.toastService.showToast({ variant: "error", title: null, message: e.message }); return; diff --git a/apps/web/src/app/admin-console/organizations/policies/require-sso.component.ts b/apps/web/src/app/admin-console/organizations/policies/require-sso.component.ts index 80335eb5d81..ea85168f986 100644 --- a/apps/web/src/app/admin-console/organizations/policies/require-sso.component.ts +++ b/apps/web/src/app/admin-console/organizations/policies/require-sso.component.ts @@ -2,10 +2,6 @@ import { Component } from "@angular/core"; import { PolicyType } from "@bitwarden/common/admin-console/enums"; import { Organization } from "@bitwarden/common/admin-console/models/domain/organization"; -import { PolicyRequest } from "@bitwarden/common/admin-console/models/request/policy.request"; -import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum"; -import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service"; -import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { BasePolicy, BasePolicyComponent } from "./base-policy.component"; @@ -24,25 +20,4 @@ export class RequireSsoPolicy extends BasePolicy { selector: "policy-require-sso", templateUrl: "require-sso.component.html", }) -export class RequireSsoPolicyComponent extends BasePolicyComponent { - constructor( - private i18nService: I18nService, - private configService: ConfigService, - ) { - super(); - } - - async buildRequest(policiesEnabledMap: Map): Promise { - if (await this.configService.getFeatureFlag(FeatureFlag.Pm13322AddPolicyDefinitions)) { - // We are now relying on server-side validation only - return super.buildRequest(policiesEnabledMap); - } - - const singleOrgEnabled = policiesEnabledMap.get(PolicyType.SingleOrg) ?? false; - if (this.enabled.value && !singleOrgEnabled) { - throw new Error(this.i18nService.t("requireSsoPolicyReqError")); - } - - return super.buildRequest(policiesEnabledMap); - } -} +export class RequireSsoPolicyComponent extends BasePolicyComponent {} diff --git a/apps/web/src/app/admin-console/organizations/policies/single-org.component.ts b/apps/web/src/app/admin-console/organizations/policies/single-org.component.ts index 9a854795e0f..b3a537f08da 100644 --- a/apps/web/src/app/admin-console/organizations/policies/single-org.component.ts +++ b/apps/web/src/app/admin-console/organizations/policies/single-org.component.ts @@ -2,10 +2,8 @@ import { Component, OnInit } from "@angular/core"; import { firstValueFrom, Observable } from "rxjs"; import { PolicyType } from "@bitwarden/common/admin-console/enums"; -import { PolicyRequest } from "@bitwarden/common/admin-console/models/request/policy.request"; import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum"; import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service"; -import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { BasePolicy, BasePolicyComponent } from "./base-policy.component"; @@ -21,10 +19,7 @@ export class SingleOrgPolicy extends BasePolicy { templateUrl: "single-org.component.html", }) export class SingleOrgPolicyComponent extends BasePolicyComponent implements OnInit { - constructor( - private i18nService: I18nService, - private configService: ConfigService, - ) { + constructor(private configService: ConfigService) { super(); } @@ -44,39 +39,4 @@ export class SingleOrgPolicyComponent extends BasePolicyComponent implements OnI this.enabled.disable(); } } - - async buildRequest(policiesEnabledMap: Map): Promise { - if (await this.configService.getFeatureFlag(FeatureFlag.Pm13322AddPolicyDefinitions)) { - // We are now relying on server-side validation only - return super.buildRequest(policiesEnabledMap); - } - - if (!this.enabled.value) { - if (policiesEnabledMap.get(PolicyType.RequireSso) ?? false) { - throw new Error( - this.i18nService.t("disableRequiredError", this.i18nService.t("requireSso")), - ); - } - - if (policiesEnabledMap.get(PolicyType.MaximumVaultTimeout) ?? false) { - throw new Error( - this.i18nService.t( - "disableRequiredError", - this.i18nService.t("maximumVaultTimeoutLabel"), - ), - ); - } - - if ( - (await firstValueFrom(this.accountDeprovisioningEnabled$)) && - !this.policyResponse.canToggleState - ) { - throw new Error( - this.i18nService.t("disableRequiredError", this.i18nService.t("singleOrg")), - ); - } - } - - return super.buildRequest(policiesEnabledMap); - } } diff --git a/bitwarden_license/bit-web/src/app/admin-console/policies/maximum-vault-timeout.component.ts b/bitwarden_license/bit-web/src/app/admin-console/policies/maximum-vault-timeout.component.ts index 6e99a223234..8abe0092ef7 100644 --- a/bitwarden_license/bit-web/src/app/admin-console/policies/maximum-vault-timeout.component.ts +++ b/bitwarden_license/bit-web/src/app/admin-console/policies/maximum-vault-timeout.component.ts @@ -63,17 +63,12 @@ export class MaximumVaultTimeoutPolicyComponent extends BasePolicyComponent { }; } - buildRequest(policiesEnabledMap: Map): Promise { - const singleOrgEnabled = policiesEnabledMap.get(PolicyType.SingleOrg) ?? false; - if (this.enabled.value && !singleOrgEnabled) { - throw new Error(this.i18nService.t("requireSsoPolicyReqError")); - } - - const data = this.buildRequestData(); - if (data?.minutes == null || data?.minutes <= 0) { + async buildRequest(): Promise { + const request = await super.buildRequest(); + if (request.data?.minutes == null || request.data?.minutes <= 0) { throw new Error(this.i18nService.t("invalidMaximumVaultTimeout")); } - return super.buildRequest(policiesEnabledMap); + return request; } } diff --git a/libs/common/src/enums/feature-flag.enum.ts b/libs/common/src/enums/feature-flag.enum.ts index 6b8af3ef78d..f9630aba04f 100644 --- a/libs/common/src/enums/feature-flag.enum.ts +++ b/libs/common/src/enums/feature-flag.enum.ts @@ -32,7 +32,6 @@ export enum FeatureFlag { VerifiedSsoDomainEndpoint = "pm-12337-refactor-sso-details-endpoint", PM11901_RefactorSelfHostingLicenseUploader = "PM-11901-refactor-self-hosting-license-uploader", AccessIntelligence = "pm-13227-access-intelligence", - Pm13322AddPolicyDefinitions = "pm-13322-add-policy-definitions", CriticalApps = "pm-14466-risk-insights-critical-application", TrialPaymentOptional = "PM-8163-trial-payment", SecurityTasks = "security-tasks", @@ -82,7 +81,6 @@ export const DefaultFeatureFlagValue = { [FeatureFlag.VerifiedSsoDomainEndpoint]: FALSE, [FeatureFlag.PM11901_RefactorSelfHostingLicenseUploader]: FALSE, [FeatureFlag.AccessIntelligence]: FALSE, - [FeatureFlag.Pm13322AddPolicyDefinitions]: FALSE, [FeatureFlag.CriticalApps]: FALSE, [FeatureFlag.TrialPaymentOptional]: FALSE, [FeatureFlag.SecurityTasks]: FALSE,