mirror of
https://github.com/bitwarden/browser
synced 2025-12-06 00:13:28 +00:00
[PM-11360] Remove export permission for providers (#12062)
* Split organization.canAccessImportExport * Fix import permission to include CanCreateNewCollections * Remove provider export permission (feature flagged)
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
import { map, Observable } from "rxjs";
|
||||
|
||||
import { I18nService } from "../../../platform/abstractions/i18n.service";
|
||||
import { Utils } from "../../../platform/misc/utils";
|
||||
import { UserId } from "../../../types/guid";
|
||||
import { OrganizationData } from "../../models/data/organization.data";
|
||||
import { Organization } from "../../models/domain/organization";
|
||||
@@ -16,7 +14,8 @@ export function canAccessSettingsTab(org: Organization): boolean {
|
||||
org.canManagePolicies ||
|
||||
org.canManageSso ||
|
||||
org.canManageScim ||
|
||||
org.canAccessImportExport ||
|
||||
org.canAccessImport ||
|
||||
org.canAccessExport(false) || // Feature flag value doesn't matter here, providers will have access to this group anyway
|
||||
org.canManageDeviceApprovals
|
||||
);
|
||||
}
|
||||
@@ -56,32 +55,6 @@ export function getOrganizationById(id: string) {
|
||||
return map<Organization[], Organization | undefined>((orgs) => orgs.find((o) => o.id === id));
|
||||
}
|
||||
|
||||
export function canAccessAdmin(i18nService: I18nService) {
|
||||
return map<Organization[], Organization[]>((orgs) =>
|
||||
orgs.filter(canAccessOrgAdmin).sort(Utils.getSortFunction(i18nService, "name")),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* To be removed after Flexible Collections.
|
||||
**/
|
||||
export function canAccessImportExport(i18nService: I18nService) {
|
||||
return map<Organization[], Organization[]>((orgs) =>
|
||||
orgs
|
||||
.filter((org) => org.canAccessImportExport)
|
||||
.sort(Utils.getSortFunction(i18nService, "name")),
|
||||
);
|
||||
}
|
||||
|
||||
export function canAccessImport(i18nService: I18nService) {
|
||||
return map<Organization[], Organization[]>((orgs) =>
|
||||
orgs
|
||||
.filter((org) => org.canAccessImportExport || org.canCreateNewCollections)
|
||||
.sort(Utils.getSortFunction(i18nService, "name")),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns `true` if a user is a member of an organization (rather than only being a ProviderUser)
|
||||
* @deprecated Use organizationService.organizations$ with a filter instead
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import { map, Observable } from "rxjs";
|
||||
|
||||
import { I18nService } from "../../../platform/abstractions/i18n.service";
|
||||
import { Utils } from "../../../platform/misc/utils";
|
||||
import { UserId } from "../../../types/guid";
|
||||
import { OrganizationData } from "../../models/data/organization.data";
|
||||
import { Organization } from "../../models/domain/organization";
|
||||
@@ -16,7 +14,8 @@ export function canAccessSettingsTab(org: Organization): boolean {
|
||||
org.canManagePolicies ||
|
||||
org.canManageSso ||
|
||||
org.canManageScim ||
|
||||
org.canAccessImportExport ||
|
||||
org.canAccessImport ||
|
||||
org.canAccessExport(false) || // Feature flag value doesn't matter here, providers will have access to this group anyway
|
||||
org.canManageDeviceApprovals
|
||||
);
|
||||
}
|
||||
@@ -56,20 +55,6 @@ export function getOrganizationById(id: string) {
|
||||
return map<Organization[], Organization | undefined>((orgs) => orgs.find((o) => o.id === id));
|
||||
}
|
||||
|
||||
export function canAccessAdmin(i18nService: I18nService) {
|
||||
return map<Organization[], Organization[]>((orgs) =>
|
||||
orgs.filter(canAccessOrgAdmin).sort(Utils.getSortFunction(i18nService, "name")),
|
||||
);
|
||||
}
|
||||
|
||||
export function canAccessImport(i18nService: I18nService) {
|
||||
return map<Organization[], Organization[]>((orgs) =>
|
||||
orgs
|
||||
.filter((org) => org.canAccessImportExport || org.canCreateNewCollections)
|
||||
.sort(Utils.getSortFunction(i18nService, "name")),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Publishes an observable stream of organizations. This service is meant to
|
||||
* be used widely across Bitwarden as the primary way of fetching organizations.
|
||||
|
||||
@@ -168,8 +168,27 @@ export class Organization {
|
||||
return (this.isAdmin || this.permissions.accessEventLogs) && this.useEvents;
|
||||
}
|
||||
|
||||
get canAccessImportExport() {
|
||||
return this.isAdmin || this.permissions.accessImportExport;
|
||||
get canAccessImport() {
|
||||
return (
|
||||
this.isProviderUser ||
|
||||
this.type === OrganizationUserType.Owner ||
|
||||
this.type === OrganizationUserType.Admin ||
|
||||
this.permissions.accessImportExport ||
|
||||
this.canCreateNewCollections // To allow users to create collections and then import into them
|
||||
);
|
||||
}
|
||||
|
||||
canAccessExport(removeProviderExport: boolean) {
|
||||
if (!removeProviderExport && this.isProviderUser) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return (
|
||||
this.isMember &&
|
||||
(this.type === OrganizationUserType.Owner ||
|
||||
this.type === OrganizationUserType.Admin ||
|
||||
this.permissions.accessImportExport)
|
||||
);
|
||||
}
|
||||
|
||||
get canAccessReports() {
|
||||
|
||||
@@ -40,6 +40,7 @@ export enum FeatureFlag {
|
||||
NewDeviceVerificationTemporaryDismiss = "new-device-temporary-dismiss",
|
||||
NewDeviceVerificationPermanentDismiss = "new-device-permanent-dismiss",
|
||||
DisableFreeFamiliesSponsorship = "PM-12274-disable-free-families-sponsorship",
|
||||
PM11360RemoveProviderExportPermission = "pm-11360-remove-provider-export-permission",
|
||||
}
|
||||
|
||||
export type AllowedFeatureFlagTypes = boolean | number | string;
|
||||
@@ -90,6 +91,7 @@ export const DefaultFeatureFlagValue = {
|
||||
[FeatureFlag.NewDeviceVerificationTemporaryDismiss]: FALSE,
|
||||
[FeatureFlag.NewDeviceVerificationPermanentDismiss]: FALSE,
|
||||
[FeatureFlag.DisableFreeFamiliesSponsorship]: FALSE,
|
||||
[FeatureFlag.PM11360RemoveProviderExportPermission]: FALSE,
|
||||
} satisfies Record<FeatureFlag, AllowedFeatureFlagTypes>;
|
||||
|
||||
export type DefaultFeatureFlagValueType = typeof DefaultFeatureFlagValue;
|
||||
|
||||
@@ -21,10 +21,7 @@ import { JslibModule } from "@bitwarden/angular/jslib.module";
|
||||
import { safeProvider, SafeProvider } from "@bitwarden/angular/platform/utils/safe-provider";
|
||||
import { PinServiceAbstraction } from "@bitwarden/auth/common";
|
||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||
import {
|
||||
canAccessImport,
|
||||
OrganizationService,
|
||||
} from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
|
||||
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
|
||||
import { PolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction";
|
||||
import { PolicyType } from "@bitwarden/common/admin-console/enums";
|
||||
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
|
||||
@@ -226,7 +223,7 @@ export class ImportComponent implements OnInit, OnDestroy, AfterViewInit {
|
||||
this.setImportOptions();
|
||||
|
||||
await this.initializeOrganizations();
|
||||
if (this.organizationId && (await this.canAccessImportExport(this.organizationId))) {
|
||||
if (this.organizationId && (await this.canAccessImport(this.organizationId))) {
|
||||
this.handleOrganizationImportInit();
|
||||
} else {
|
||||
this.handleImportInit();
|
||||
@@ -289,7 +286,7 @@ export class ImportComponent implements OnInit, OnDestroy, AfterViewInit {
|
||||
private async initializeOrganizations() {
|
||||
this.organizations$ = concat(
|
||||
this.organizationService.memberOrganizations$.pipe(
|
||||
canAccessImport(this.i18nService),
|
||||
map((orgs) => orgs.filter((org) => org.canAccessImport)),
|
||||
map((orgs) => orgs.sort(Utils.getSortFunction(this.i18nService, "name"))),
|
||||
),
|
||||
);
|
||||
@@ -375,7 +372,7 @@ export class ImportComponent implements OnInit, OnDestroy, AfterViewInit {
|
||||
importContents,
|
||||
this.organizationId,
|
||||
this.formGroup.controls.targetSelector.value,
|
||||
(await this.canAccessImportExport(this.organizationId)) && this.isFromAC,
|
||||
(await this.canAccessImport(this.organizationId)) && this.isFromAC,
|
||||
);
|
||||
|
||||
//No errors, display success message
|
||||
@@ -395,11 +392,11 @@ export class ImportComponent implements OnInit, OnDestroy, AfterViewInit {
|
||||
}
|
||||
}
|
||||
|
||||
private async canAccessImportExport(organizationId?: string): Promise<boolean> {
|
||||
private async canAccessImport(organizationId?: string): Promise<boolean> {
|
||||
if (!organizationId) {
|
||||
return false;
|
||||
}
|
||||
return (await this.organizationService.get(this.organizationId))?.canAccessImportExport;
|
||||
return (await this.organizationService.get(this.organizationId))?.canAccessImport;
|
||||
}
|
||||
|
||||
getFormatInstructionTitle() {
|
||||
|
||||
Reference in New Issue
Block a user