Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

feat: changed all org permission signature

=9a7849c12b4d
diff --git a/backend/src/@types/fastify.d.ts b/backend/src/@types/fastify.d.ts
index 59ca1cf558..1a28a68792 100644
--- a/backend/src/@types/fastify.d.ts
+++ b/backend/src/@types/fastify.d.ts
@@ -48,6 +48,7 @@ import { TSshCertificateAuthorityServiceFactory } from "@app/ee/services/ssh/ssh
import { TSshCertificateTemplateServiceFactory } from "@app/ee/services/ssh-certificate-template/ssh-certificate-template-service";
import { TSshHostServiceFactory } from "@app/ee/services/ssh-host/ssh-host-service";
import { TSshHostGroupServiceFactory } from "@app/ee/services/ssh-host-group/ssh-host-group-service";
+import { TSubOrgServiceFactory } from "@app/ee/services/sub-org/sub-org-service";
import { TTrustedIpServiceFactory } from "@app/ee/services/trusted-ip/trusted-ip-types";
import { TAuthMode } from "@app/server/plugins/auth/inject-identity";
import { TAdditionalPrivilegeServiceFactory } from "@app/services/additional-privilege/additional-privilege-service";
@@ -126,7 +127,6 @@ import { TUserServiceFactory } from "@app/services/user/user-service";
import { TUserEngagementServiceFactory } from "@app/services/user-engagement/user-engagement-service";
import { TWebhookServiceFactory } from "@app/services/webhook/webhook-service";
import { TWorkflowIntegrationServiceFactory } from "@app/services/workflow-integration/workflow-integration-service";
-import { TSubOrgServiceFactory } from "@app/ee/services/sub-org/sub-org-service";
declare module "@fastify/request-context" {
interface RequestContextData {
diff --git a/backend/src/db/migrations/20251018061215_sub-org.ts b/backend/src/db/migrations/20251018061215_sub-org.ts
index 3824bf68c6..0b2f72abf2 100644
--- a/backend/src/db/migrations/20251018061215_sub-org.ts
+++ b/backend/src/db/migrations/20251018061215_sub-org.ts
@@ -1,4 +1,5 @@
import { Knex } from "knex";
+
import { TableName } from "../schemas";
export async function up(knex: Knex): Promise<void> {
diff --git a/backend/src/ee/services/audit-log-stream/audit-log-stream-service.ts b/backend/src/ee/services/audit-log-stream/audit-log-stream-service.ts
index 5dd0fd4ba0..b3cd34ac91 100644
--- a/backend/src/ee/services/audit-log-stream/audit-log-stream-service.ts
+++ b/backend/src/ee/services/audit-log-stream/audit-log-stream-service.ts
@@ -1,7 +1,7 @@
import { ForbiddenError } from "@casl/ability";
import { AxiosError } from "axios";
-import { TAuditLogs } from "@app/db/schemas";
+import { OrganizationActionScope, TAuditLogs } from "@app/db/schemas";
import {
decryptLogStream,
decryptLogStreamCredentials,
@@ -45,13 +45,14 @@ export const auditLogStreamServiceFactory = ({
});
}
- const { permission } = await permissionService.getOrgPermission(
- actor.type,
- actor.id,
- actor.orgId,
- actor.authMethod,
- actor.orgId
- );
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
+ actor: actor.type,
+ actorId: actor.id,
+ orgId: actor.orgId,
+ actorAuthMethod: actor.authMethod,
+ actorOrgId: actor.orgId
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Create, OrgPermissionSubjects.Settings);
@@ -94,13 +95,14 @@ export const auditLogStreamServiceFactory = ({
const logStream = await auditLogStreamDAL.findById(logStreamId);
if (!logStream) throw new NotFoundError({ message: `Audit Log Stream with ID '${logStreamId}' not found` });
- const { permission } = await permissionService.getOrgPermission(
- actor.type,
- actor.id,
- actor.orgId,
- actor.authMethod,
- logStream.orgId
- );
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
+ actor: actor.type,
+ actorId: actor.id,
+ orgId: actor.orgId,
+ actorAuthMethod: actor.authMethod,
+ actorOrgId: actor.orgId
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Edit, OrgPermissionSubjects.Settings);
@@ -160,13 +162,14 @@ export const auditLogStreamServiceFactory = ({
const logStream = await auditLogStreamDAL.findById(logStreamId);
if (!logStream) throw new NotFoundError({ message: `Audit Log Stream with ID '${logStreamId}' not found` });
- const { permission } = await permissionService.getOrgPermission(
- actor.type,
- actor.id,
- actor.orgId,
- actor.authMethod,
- logStream.orgId
- );
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
+ actor: actor.type,
+ actorId: actor.id,
+ orgId: actor.orgId,
+ actorAuthMethod: actor.authMethod,
+ actorOrgId: actor.orgId
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Delete, OrgPermissionSubjects.Settings);
@@ -185,14 +188,14 @@ export const auditLogStreamServiceFactory = ({
const logStream = await auditLogStreamDAL.findById(logStreamId);
if (!logStream) throw new NotFoundError({ message: `Audit log stream with ID '${logStreamId}' not found` });
-
- const { permission } = await permissionService.getOrgPermission(
- actor.type,
- actor.id,
- logStream.orgId,
- actor.authMethod,
- actor.orgId
- );
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
+ actor: actor.type,
+ actorId: actor.id,
+ orgId: actor.orgId,
+ actorAuthMethod: actor.authMethod,
+ actorOrgId: actor.orgId
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Settings);
@@ -206,13 +209,14 @@ export const auditLogStreamServiceFactory = ({
};
const list = async (actor: OrgServiceActor) => {
- const { permission } = await permissionService.getOrgPermission(
- actor.type,
- actor.id,
- actor.orgId,
- actor.authMethod,
- actor.orgId
- );
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
+ actor: actor.type,
+ actorId: actor.id,
+ orgId: actor.orgId,
+ actorAuthMethod: actor.authMethod,
+ actorOrgId: actor.orgId
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Settings);
diff --git a/backend/src/ee/services/audit-log/audit-log-service.ts b/backend/src/ee/services/audit-log/audit-log-service.ts
index ece5edaf9f..eab7792f85 100644
--- a/backend/src/ee/services/audit-log/audit-log-service.ts
+++ b/backend/src/ee/services/audit-log/audit-log-service.ts
@@ -1,7 +1,7 @@
import { ForbiddenError } from "@casl/ability";
import { requestContext } from "@fastify/request-context";
-import { ActionProjectType } from "@app/db/schemas";
+import { ActionProjectType, OrganizationActionScope } from "@app/db/schemas";
import { getConfig } from "@app/lib/config/env";
import { BadRequestError } from "@app/lib/errors";
import { ActorType } from "@app/services/auth/auth-type";
@@ -47,13 +47,14 @@ export const auditLogServiceFactory = ({
);
} else {
// Organization-wide logs
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- actorOrgId,
+ orgId: actorOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(
OrgPermissionAuditLogsActions.Read,
diff --git a/backend/src/ee/services/dynamic-secret/dynamic-secret-service.ts b/backend/src/ee/services/dynamic-secret/dynamic-secret-service.ts
index 659e07bca3..974f5dd358 100644
--- a/backend/src/ee/services/dynamic-secret/dynamic-secret-service.ts
+++ b/backend/src/ee/services/dynamic-secret/dynamic-secret-service.ts
@@ -1,6 +1,6 @@
import { ForbiddenError, subject } from "@casl/ability";
-import { ActionProjectType } from "@app/db/schemas";
+import { ActionProjectType, OrganizationActionScope } from "@app/db/schemas";
import { TLicenseServiceFactory } from "@app/ee/services/license/license-service";
import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service-types";
import {
@@ -134,13 +134,14 @@ export const dynamicSecretServiceFactory = ({
isGatewayV1 = false;
}
- const { permission: orgPermission } = await permissionService.getOrgPermission(
+ const { permission: orgPermission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- gateway?.orgId ?? gatewayv2?.orgId,
+ orgId: actorOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(orgPermission).throwUnlessCan(
OrgPermissionGatewayActions.AttachGateways,
@@ -297,13 +298,14 @@ export const dynamicSecretServiceFactory = ({
isGatewayV1 = false;
}
- const { permission: orgPermission } = await permissionService.getOrgPermission(
+ const { permission: orgPermission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- actorOrgId,
+ orgId: actorOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(orgPermission).throwUnlessCan(
OrgPermissionGatewayActions.AttachGateways,
diff --git a/backend/src/ee/services/external-kms/external-kms-service.ts b/backend/src/ee/services/external-kms/external-kms-service.ts
index d515c59733..9614f32980 100644
--- a/backend/src/ee/services/external-kms/external-kms-service.ts
+++ b/backend/src/ee/services/external-kms/external-kms-service.ts
@@ -3,6 +3,7 @@ import { STSServiceException } from "@aws-sdk/client-sts";
import { ForbiddenError } from "@casl/ability";
import slugify from "@sindresorhus/slugify";
+import { OrganizationActionScope } from "@app/db/schemas";
import { BadRequestError, InternalServerError, NotFoundError } from "@app/lib/errors";
import { alphaNumericNanoId } from "@app/lib/nanoid";
import { TKmsKeyDALFactory } from "@app/services/kms/kms-key-dal";
@@ -51,13 +52,14 @@ export const externalKmsServiceFactory = ({
actorOrgId,
actorAuthMethod
}: TCreateExternalKmsDTO) => {
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- actorOrgId,
+ orgId: actorOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Create, OrgPermissionSubjects.Kms);
const plan = await licenseService.getPlan(actorOrgId);
@@ -154,13 +156,14 @@ export const externalKmsServiceFactory = ({
actorAuthMethod
}: TUpdateExternalKmsDTO) => {
const kmsDoc = await kmsDAL.findById(kmsId);
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- kmsDoc.orgId,
+ orgId: kmsDoc.orgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Edit, OrgPermissionSubjects.Kms);
const plan = await licenseService.getPlan(kmsDoc.orgId);
@@ -257,13 +260,14 @@ export const externalKmsServiceFactory = ({
const deleteById = async ({ actor, id: kmsId, actorId, actorOrgId, actorAuthMethod }: TDeleteExternalKmsDTO) => {
const kmsDoc = await kmsDAL.findById(kmsId);
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- kmsDoc.orgId,
+ orgId: kmsDoc.orgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Delete, OrgPermissionSubjects.Kms);
const externalKmsDoc = await externalKmsDAL.findOne({ kmsKeyId: kmsDoc.id });
@@ -278,13 +282,14 @@ export const externalKmsServiceFactory = ({
};
const list = async ({ actor, actorId, actorOrgId, actorAuthMethod }: TListExternalKmsDTO) => {
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- actorOrgId,
+ orgId: actorOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Kms);
const externalKmsDocs = await externalKmsDAL.find({ orgId: actorOrgId });
@@ -294,13 +299,14 @@ export const externalKmsServiceFactory = ({
const findById = async ({ actor, actorId, actorOrgId, actorAuthMethod, id: kmsId }: TGetExternalKmsByIdDTO) => {
const kmsDoc = await kmsDAL.findById(kmsId);
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- kmsDoc.orgId,
+ orgId: kmsDoc.orgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Kms);
@@ -342,13 +348,14 @@ export const externalKmsServiceFactory = ({
name: kmsName
}: TGetExternalKmsBySlugDTO) => {
const kmsDoc = await kmsDAL.findOne({ name: kmsName, orgId: actorOrgId });
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- kmsDoc.orgId,
+ orgId: kmsDoc.orgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Kms);
const externalKmsDoc = await externalKmsDAL.findOne({ kmsKeyId: kmsDoc.id });
diff --git a/backend/src/ee/services/gateway-v2/gateway-v2-service.ts b/backend/src/ee/services/gateway-v2/gateway-v2-service.ts
index a2d3237900..fd4954a00d 100644
--- a/backend/src/ee/services/gateway-v2/gateway-v2-service.ts
+++ b/backend/src/ee/services/gateway-v2/gateway-v2-service.ts
@@ -3,7 +3,7 @@ import net from "node:net";
import { ForbiddenError } from "@casl/ability";
import * as x509 from "@peculiar/x509";
-import { OrgMembershipRole, TRelays } from "@app/db/schemas";
+import { OrganizationActionScope, OrgMembershipRole, TRelays } from "@app/db/schemas";
import { PgSqlLock } from "@app/keystore/keystore";
import { crypto } from "@app/lib/crypto";
import { DatabaseErrorCode } from "@app/lib/error-codes";
@@ -73,13 +73,14 @@ export const gatewayV2ServiceFactory = ({
});
}
- const { permission } = await permissionService.getOrgPermission(
- ActorType.IDENTITY,
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
+ actor: ActorType.IDENTITY,
actorId,
orgId,
actorAuthMethod,
- orgId
- );
+ actorOrgId: orgId
+ });
ForbiddenError.from(permission).throwUnlessCan(
OrgPermissionGatewayActions.CreateGateways,
@@ -258,13 +259,14 @@ export const gatewayV2ServiceFactory = ({
};
const listGateways = async ({ orgPermission }: { orgPermission: OrgServiceActor }) => {
- const { permission } = await permissionService.getOrgPermission(
- orgPermission.type,
- orgPermission.id,
- orgPermission.orgId,
- orgPermission.authMethod,
- orgPermission.orgId
- );
+ const { permission } = await permissionService.getOrgPermission({
+ actor: orgPermission.type,
+ actorId: orgPermission.id,
+ orgId: orgPermission.orgId,
+ actorAuthMethod: orgPermission.authMethod,
+ actorOrgId: orgPermission.orgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(
OrgPermissionGatewayActions.ListGateways,
@@ -815,13 +817,14 @@ export const gatewayV2ServiceFactory = ({
throw new NotFoundError({ message: `Gateway ${id} not found` });
}
- const { permission } = await permissionService.getOrgPermission(
- orgPermission.type,
- orgPermission.id,
- gateway.orgId,
- orgPermission.authMethod,
- orgPermission.orgId
- );
+ const { permission } = await permissionService.getOrgPermission({
+ actor: orgPermission.type,
+ actorId: orgPermission.id,
+ orgId: gateway.orgId,
+ actorAuthMethod: orgPermission.authMethod,
+ actorOrgId: orgPermission.orgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(
OrgPermissionGatewayActions.DeleteGateways,
@@ -845,13 +848,14 @@ export const gatewayV2ServiceFactory = ({
};
const getPamSessionKey = async ({ orgPermission }: { orgPermission: OrgServiceActor }) => {
- const { permission } = await permissionService.getOrgPermission(
- orgPermission.type,
- orgPermission.id,
- orgPermission.orgId,
- orgPermission.authMethod,
- orgPermission.orgId
- );
+ const { permission } = await permissionService.getOrgPermission({
+ actor: orgPermission.type,
+ actorId: orgPermission.id,
+ orgId: orgPermission.orgId,
+ actorAuthMethod: orgPermission.authMethod,
+ actorOrgId: orgPermission.orgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(
OrgPermissionGatewayActions.CreateGateways,
diff --git a/backend/src/ee/services/gateway/gateway-service.ts b/backend/src/ee/services/gateway/gateway-service.ts
index 5c8ad80bfc..261640cc92 100644
--- a/backend/src/ee/services/gateway/gateway-service.ts
+++ b/backend/src/ee/services/gateway/gateway-service.ts
@@ -2,6 +2,7 @@ import { ForbiddenError } from "@casl/ability";
import * as x509 from "@peculiar/x509";
import { z } from "zod";
+import { OrganizationActionScope } from "@app/db/schemas";
import { KeyStorePrefixes, PgSqlLock, TKeyStoreFactory } from "@app/keystore/keystore";
import { getConfig } from "@app/lib/config/env";
import { crypto } from "@app/lib/crypto/cryptography";
@@ -68,13 +69,14 @@ export const gatewayServiceFactory = ({
"Gateway handshake failed due to organization plan restrictions. Please upgrade your instance to Infisical's Enterprise plan."
});
}
- const { permission } = await permissionService.getOrgPermission(
- ActorType.IDENTITY,
+ const { permission } = await permissionService.getOrgPermission({
+ actor: ActorType.IDENTITY,
actorId,
orgId,
actorAuthMethod,
- orgId
- );
+ actorOrgId: orgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(
OrgPermissionGatewayActions.CreateGateways,
OrgPermissionSubjects.Gateway
@@ -480,13 +482,14 @@ export const gatewayServiceFactory = ({
};
const listGateways = async ({ orgPermission }: TListGatewaysDTO) => {
- const { permission } = await permissionService.getOrgPermission(
- orgPermission.type,
- orgPermission.id,
- orgPermission.orgId,
- orgPermission.authMethod,
- orgPermission.orgId
- );
+ const { permission } = await permissionService.getOrgPermission({
+ actor: orgPermission.type,
+ actorId: orgPermission.id,
+ orgId: orgPermission.orgId,
+ actorAuthMethod: orgPermission.authMethod,
+ actorOrgId: orgPermission.orgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(
OrgPermissionGatewayActions.ListGateways,
OrgPermissionSubjects.Gateway
@@ -501,13 +504,14 @@ export const gatewayServiceFactory = ({
};
const getGatewayById = async ({ orgPermission, id }: TGetGatewayByIdDTO) => {
- const { permission } = await permissionService.getOrgPermission(
- orgPermission.type,
- orgPermission.id,
- orgPermission.orgId,
- orgPermission.authMethod,
- orgPermission.orgId
- );
+ const { permission } = await permissionService.getOrgPermission({
+ actor: orgPermission.type,
+ actorId: orgPermission.id,
+ orgId: orgPermission.orgId,
+ actorAuthMethod: orgPermission.authMethod,
+ actorOrgId: orgPermission.orgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(
OrgPermissionGatewayActions.ListGateways,
OrgPermissionSubjects.Gateway
@@ -521,13 +525,14 @@ export const gatewayServiceFactory = ({
};
const updateGatewayById = async ({ orgPermission, id, name }: TUpdateGatewayByIdDTO) => {
- const { permission } = await permissionService.getOrgPermission(
- orgPermission.type,
- orgPermission.id,
- orgPermission.orgId,
- orgPermission.authMethod,
- orgPermission.orgId
- );
+ const { permission } = await permissionService.getOrgPermission({
+ actor: orgPermission.type,
+ actorId: orgPermission.id,
+ orgId: orgPermission.orgId,
+ actorAuthMethod: orgPermission.authMethod,
+ actorOrgId: orgPermission.orgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(
OrgPermissionGatewayActions.EditGateways,
OrgPermissionSubjects.Gateway
@@ -542,13 +547,14 @@ export const gatewayServiceFactory = ({
};
const deleteGatewayById = async ({ orgPermission, id }: TGetGatewayByIdDTO) => {
- const { permission } = await permissionService.getOrgPermission(
- orgPermission.type,
- orgPermission.id,
- orgPermission.orgId,
- orgPermission.authMethod,
- orgPermission.orgId
- );
+ const { permission } = await permissionService.getOrgPermission({
+ actor: orgPermission.type,
+ actorId: orgPermission.id,
+ orgId: orgPermission.orgId,
+ actorAuthMethod: orgPermission.authMethod,
+ actorOrgId: orgPermission.orgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(
OrgPermissionGatewayActions.DeleteGateways,
OrgPermissionSubjects.Gateway
diff --git a/backend/src/ee/services/github-org-sync/github-org-sync-service.ts b/backend/src/ee/services/github-org-sync/github-org-sync-service.ts
index b2bcb4ef3d..d2713f269b 100644
--- a/backend/src/ee/services/github-org-sync/github-org-sync-service.ts
+++ b/backend/src/ee/services/github-org-sync/github-org-sync-service.ts
@@ -6,7 +6,7 @@ import { paginateGraphql } from "@octokit/plugin-paginate-graphql";
import { Octokit as OctokitRest } from "@octokit/rest";
import RE2 from "re2";
-import { AccessScope, OrgMembershipRole } from "@app/db/schemas";
+import { AccessScope, OrganizationActionScope, OrgMembershipRole } from "@app/db/schemas";
import { BadRequestError, NotFoundError } from "@app/lib/errors";
import { groupBy } from "@app/lib/fn";
import { logger } from "@app/lib/logger";
@@ -104,13 +104,14 @@ export const githubOrgSyncServiceFactory = ({
githubOrgAccessToken,
isActive
}: TCreateGithubOrgSyncDTO) => {
- const { permission } = await permissionService.getOrgPermission(
- orgPermission.type,
- orgPermission.id,
- orgPermission.orgId,
- orgPermission.authMethod,
- orgPermission.orgId
- );
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.ParentOrganization,
+ actor: orgPermission.type,
+ actorId: orgPermission.id,
+ orgId: orgPermission.orgId,
+ actorAuthMethod: orgPermission.authMethod,
+ actorOrgId: orgPermission.orgId
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Create, OrgPermissionSubjects.GithubOrgSync);
const plan = await licenseService.getPlan(orgPermission.orgId);
@@ -162,13 +163,14 @@ export const githubOrgSyncServiceFactory = ({
githubOrgAccessToken,
isActive
}: TUpdateGithubOrgSyncDTO) => {
- const { permission } = await permissionService.getOrgPermission(
- orgPermission.type,
- orgPermission.id,
- orgPermission.orgId,
- orgPermission.authMethod,
- orgPermission.orgId
- );
+ const { permission } = await permissionService.getOrgPermission({
+ actor: orgPermission.type,
+ scope: OrganizationActionScope.ParentOrganization,
+ actorId: orgPermission.id,
+ orgId: orgPermission.orgId,
+ actorAuthMethod: orgPermission.authMethod,
+ actorOrgId: orgPermission.orgId
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Edit, OrgPermissionSubjects.GithubOrgSync);
const plan = await licenseService.getPlan(orgPermission.orgId);
@@ -226,13 +228,14 @@ export const githubOrgSyncServiceFactory = ({
};
const deleteGithubOrgSync = async ({ orgPermission }: TDeleteGithubOrgSyncDTO) => {
- const { permission } = await permissionService.getOrgPermission(
- orgPermission.type,
- orgPermission.id,
- orgPermission.orgId,
- orgPermission.authMethod,
- orgPermission.orgId
- );
+ const { permission } = await permissionService.getOrgPermission({
+ actor: orgPermission.type,
+ actorId: orgPermission.id,
+ orgId: orgPermission.orgId,
+ actorAuthMethod: orgPermission.authMethod,
+ actorOrgId: orgPermission.orgId,
+ scope: OrganizationActionScope.ParentOrganization
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Delete, OrgPermissionSubjects.GithubOrgSync);
@@ -256,13 +259,14 @@ export const githubOrgSyncServiceFactory = ({
};
const getGithubOrgSync = async ({ orgPermission }: TDeleteGithubOrgSyncDTO) => {
- const { permission } = await permissionService.getOrgPermission(
- orgPermission.type,
- orgPermission.id,
- orgPermission.orgId,
- orgPermission.authMethod,
- orgPermission.orgId
- );
+ const { permission } = await permissionService.getOrgPermission({
+ actorId: orgPermission.id,
+ actor: orgPermission.type,
+ orgId: orgPermission.orgId,
+ actorAuthMethod: orgPermission.authMethod,
+ actorOrgId: orgPermission.orgId,
+ scope: OrganizationActionScope.ParentOrganization
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.GithubOrgSync);
@@ -422,13 +426,14 @@ export const githubOrgSyncServiceFactory = ({
};
const validateGithubToken = async ({ orgPermission, githubOrgAccessToken }: TValidateGithubTokenDTO) => {
- const { permission } = await permissionService.getOrgPermission(
- orgPermission.type,
- orgPermission.id,
- orgPermission.orgId,
- orgPermission.authMethod,
- orgPermission.orgId
- );
+ const { permission } = await permissionService.getOrgPermission({
+ actorId: orgPermission.id,
+ actor: orgPermission.type,
+ orgId: orgPermission.orgId,
+ actorAuthMethod: orgPermission.authMethod,
+ actorOrgId: orgPermission.orgId,
+ scope: OrganizationActionScope.ParentOrganization
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.GithubOrgSync);
@@ -509,13 +514,14 @@ export const githubOrgSyncServiceFactory = ({
};
const syncAllTeams = async ({ orgPermission }: TSyncAllTeamsDTO): Promise<TSyncResult> => {
- const { permission } = await permissionService.getOrgPermission(
- orgPermission.type,
- orgPermission.id,
- orgPermission.orgId,
- orgPermission.authMethod,
- orgPermission.orgId
- );
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.ParentOrganization,
+ actor: orgPermission.type,
+ orgId: orgPermission.orgId,
+ actorId: orgPermission.id,
+ actorAuthMethod: orgPermission.authMethod,
+ actorOrgId: orgPermission.orgId
+ });
ForbiddenError.from(permission).throwUnlessCan(
OrgPermissionActions.Edit,
diff --git a/backend/src/ee/services/group/group-service.ts b/backend/src/ee/services/group/group-service.ts
index 075488488b..0ffd77f0d4 100644
--- a/backend/src/ee/services/group/group-service.ts
+++ b/backend/src/ee/services/group/group-service.ts
@@ -1,7 +1,7 @@
import { ForbiddenError } from "@casl/ability";
import slugify from "@sindresorhus/slugify";
-import { AccessScope, OrgMembershipRole, TRoles } from "@app/db/schemas";
+import { AccessScope, OrganizationActionScope, OrgMembershipRole, TRoles } from "@app/db/schemas";
import { TOidcConfigDALFactory } from "@app/ee/services/oidc/oidc-config-dal";
import { BadRequestError, NotFoundError, PermissionBoundaryError, UnauthorizedError } from "@app/lib/errors";
import { alphaNumericNanoId } from "@app/lib/nanoid";
@@ -73,13 +73,14 @@ export const groupServiceFactory = ({
const createGroup = async ({ name, slug, role, actor, actorId, actorAuthMethod, actorOrgId }: TCreateGroupDTO) => {
if (!actorOrgId) throw new UnauthorizedError({ message: "No organization ID provided in request" });
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- actorOrgId,
+ orgId: actorOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionGroupActions.Create, OrgPermissionSubjects.Groups);
const plan = await licenseService.getPlan(actorOrgId);
@@ -167,13 +168,14 @@ export const groupServiceFactory = ({
}: TUpdateGroupDTO) => {
if (!actorOrgId) throw new UnauthorizedError({ message: "No organization ID provided in request" });
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- actorOrgId,
+ orgId: actorOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionGroupActions.Edit, OrgPermissionSubjects.Groups);
@@ -270,13 +272,14 @@ export const groupServiceFactory = ({
const deleteGroup = async ({ id, actor, actorId, actorAuthMethod, actorOrgId }: TDeleteGroupDTO) => {
if (!actorOrgId) throw new UnauthorizedError({ message: "No organization ID provided in request" });
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- actorOrgId,
+ orgId: actorOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionGroupActions.Delete, OrgPermissionSubjects.Groups);
const plan = await licenseService.getPlan(actorOrgId);
@@ -297,17 +300,18 @@ export const groupServiceFactory = ({
const getGroupById = async ({ id, actor, actorId, actorAuthMethod, actorOrgId }: TGetGroupByIdDTO) => {
if (!actorOrgId) throw new UnauthorizedError({ message: "No organization ID provided in request" });
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- actorOrgId,
+ orgId: actorOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionGroupActions.Read, OrgPermissionSubjects.Groups);
const group = await groupDAL.findById(id);
- if (!group) {
+ if (!group || group.orgId !== actorOrgId) {
throw new NotFoundError({
message: `Cannot find group with ID ${id}`
});
@@ -330,13 +334,14 @@ export const groupServiceFactory = ({
}: TListGroupUsersDTO) => {
if (!actorOrgId) throw new UnauthorizedError({ message: "No organization ID provided in request" });
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- actorOrgId,
+ orgId: actorOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionGroupActions.Read, OrgPermissionSubjects.Groups);
const group = await groupDAL.findOne({
@@ -365,13 +370,14 @@ export const groupServiceFactory = ({
const addUserToGroup = async ({ id, username, actor, actorId, actorAuthMethod, actorOrgId }: TAddUserToGroupDTO) => {
if (!actorOrgId) throw new UnauthorizedError({ message: "No organization ID provided in request" });
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- actorOrgId,
+ orgId: actorOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionGroupActions.Edit, OrgPermissionSubjects.Groups);
// check if group with slug exists
@@ -451,13 +457,14 @@ export const groupServiceFactory = ({
}: TRemoveUserFromGroupDTO) => {
if (!actorOrgId) throw new UnauthorizedError({ message: "No organization ID provided in request" });
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
actor,
actorId,
actorOrgId,
actorAuthMethod,
- actorOrgId
- );
+ actorOrgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionGroupActions.Edit, OrgPermissionSubjects.Groups);
// check if group with slug exists
diff --git a/backend/src/ee/services/identity-auth-template/identity-auth-template-service.ts b/backend/src/ee/services/identity-auth-template/identity-auth-template-service.ts
index ef071742d1..10aa3b190f 100644
--- a/backend/src/ee/services/identity-auth-template/identity-auth-template-service.ts
+++ b/backend/src/ee/services/identity-auth-template/identity-auth-template-service.ts
@@ -1,5 +1,6 @@
import { ForbiddenError } from "@casl/ability";
+import { OrganizationActionScope } from "@app/db/schemas";
import { EventType, TAuditLogServiceFactory } from "@app/ee/services/audit-log/audit-log-types";
import { TLicenseServiceFactory } from "@app/ee/services/license/license-service";
import {
@@ -68,13 +69,14 @@ export const identityAuthTemplateServiceFactory = ({
templateFields: Record<string, unknown>;
} & Omit<TOrgPermission, "orgId">) => {
await $checkPlan(actorOrgId);
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- actorOrgId,
+ orgId: actorOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(
OrgPermissionMachineIdentityAuthTemplateActions.CreateTemplates,
OrgPermissionSubjects.MachineIdentityAuthTemplate
@@ -113,13 +115,14 @@ export const identityAuthTemplateServiceFactory = ({
throw new NotFoundError({ message: "Template not found" });
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- template.orgId,
+ orgId: template.orgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(
OrgPermissionMachineIdentityAuthTemplateActions.EditTemplates,
OrgPermissionSubjects.MachineIdentityAuthTemplate
@@ -227,13 +230,14 @@ export const identityAuthTemplateServiceFactory = ({
throw new NotFoundError({ message: "Template not found" });
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- template.orgId,
+ orgId: template.orgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(
OrgPermissionMachineIdentityAuthTemplateActions.DeleteTemplates,
OrgPermissionSubjects.MachineIdentityAuthTemplate
@@ -282,13 +286,14 @@ export const identityAuthTemplateServiceFactory = ({
throw new NotFoundError({ message: "Template not found" });
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- template.orgId,
+ orgId: template.orgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(
OrgPermissionMachineIdentityAuthTemplateActions.ListTemplates,
OrgPermissionSubjects.MachineIdentityAuthTemplate
@@ -316,13 +321,14 @@ export const identityAuthTemplateServiceFactory = ({
actorOrgId
}: TListIdentityAuthTemplatesDTO) => {
await $checkPlan(actorOrgId);
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- actorOrgId,
+ orgId: actorOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(
OrgPermissionMachineIdentityAuthTemplateActions.ListTemplates,
OrgPermissionSubjects.MachineIdentityAuthTemplate
@@ -352,13 +358,14 @@ export const identityAuthTemplateServiceFactory = ({
actorOrgId
}: TGetTemplatesByAuthMethodDTO) => {
await $checkPlan(actorOrgId);
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- actorOrgId,
+ orgId: actorOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(
OrgPermissionMachineIdentityAuthTemplateActions.AttachTemplates,
OrgPermissionSubjects.MachineIdentityAuthTemplate
@@ -385,13 +392,14 @@ export const identityAuthTemplateServiceFactory = ({
actorOrgId
}: TFindTemplateUsagesDTO) => {
await $checkPlan(actorOrgId);
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- actorOrgId,
+ orgId: actorOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(
OrgPermissionMachineIdentityAuthTemplateActions.ListTemplates,
OrgPermissionSubjects.MachineIdentityAuthTemplate
@@ -415,13 +423,14 @@ export const identityAuthTemplateServiceFactory = ({
actorOrgId
}: TUnlinkTemplateUsageDTO) => {
await $checkPlan(actorOrgId);
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- actorOrgId,
+ orgId: actorOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(
OrgPermissionMachineIdentityAuthTemplateActions.UnlinkTemplates,
OrgPermissionSubjects.MachineIdentityAuthTemplate
diff --git a/backend/src/ee/services/kmip/kmip-operation-service.ts b/backend/src/ee/services/kmip/kmip-operation-service.ts
index 27f59a99f9..b3eace6bc5 100644
--- a/backend/src/ee/services/kmip/kmip-operation-service.ts
+++ b/backend/src/ee/services/kmip/kmip-operation-service.ts
@@ -1,5 +1,6 @@
import { ForbiddenError } from "@casl/ability";
+import { OrganizationActionScope } from "@app/db/schemas";
import { BadRequestError, ForbiddenRequestError, NotFoundError } from "@app/lib/errors";
import { TKmsKeyDALFactory } from "@app/services/kms/kms-key-dal";
import { TKmsServiceFactory } from "@app/services/kms/kms-service";
@@ -46,13 +47,14 @@ export const kmipOperationServiceFactory = ({
actorAuthMethod,
actorOrgId
}: TKmipCreateDTO) => {
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- actorOrgId,
+ orgId: actorOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionKmipActions.Proxy, OrgPermissionSubjects.Kmip);
@@ -78,13 +80,14 @@ export const kmipOperationServiceFactory = ({
};
const destroy = async ({ projectId, id, clientId, actor, actorId, actorOrgId, actorAuthMethod }: TKmipDestroyDTO) => {
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- actorOrgId,
+ orgId: actorOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionKmipActions.Proxy, OrgPermissionSubjects.Kmip);
@@ -131,13 +134,14 @@ export const kmipOperationServiceFactory = ({
};
const get = async ({ projectId, id, clientId, actor, actorId, actorAuthMethod, actorOrgId }: TKmipGetDTO) => {
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- actorOrgId,
+ orgId: actorOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionKmipActions.Proxy, OrgPermissionSubjects.Kmip);
@@ -189,13 +193,14 @@ export const kmipOperationServiceFactory = ({
};
const activate = async ({ projectId, id, clientId, actor, actorId, actorAuthMethod, actorOrgId }: TKmipGetDTO) => {
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- actorOrgId,
+ orgId: actorOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionKmipActions.Proxy, OrgPermissionSubjects.Kmip);
@@ -226,13 +231,14 @@ export const kmipOperationServiceFactory = ({
};
const revoke = async ({ projectId, id, clientId, actor, actorId, actorAuthMethod, actorOrgId }: TKmipRevokeDTO) => {
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- actorOrgId,
+ orgId: actorOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionKmipActions.Proxy, OrgPermissionSubjects.Kmip);
@@ -287,13 +293,14 @@ export const kmipOperationServiceFactory = ({
actorAuthMethod,
actorOrgId
}: TKmipGetAttributesDTO) => {
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- actorOrgId,
+ orgId: actorOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionKmipActions.Proxy, OrgPermissionSubjects.Kmip);
@@ -339,13 +346,14 @@ export const kmipOperationServiceFactory = ({
};
const locate = async ({ projectId, clientId, actor, actorId, actorAuthMethod, actorOrgId }: TKmipLocateDTO) => {
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- actorOrgId,
+ orgId: actorOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionKmipActions.Proxy, OrgPermissionSubjects.Kmip);
@@ -377,13 +385,14 @@ export const kmipOperationServiceFactory = ({
actorOrgId,
kmipMetadata
}: TKmipRegisterDTO) => {
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- actorOrgId,
+ orgId: actorOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionKmipActions.Proxy, OrgPermissionSubjects.Kmip);
diff --git a/backend/src/ee/services/kmip/kmip-service.ts b/backend/src/ee/services/kmip/kmip-service.ts
index 8daa5a37a0..482eb41be7 100644
--- a/backend/src/ee/services/kmip/kmip-service.ts
+++ b/backend/src/ee/services/kmip/kmip-service.ts
@@ -1,7 +1,7 @@
import { ForbiddenError } from "@casl/ability";
import * as x509 from "@peculiar/x509";
-import { ActionProjectType } from "@app/db/schemas";
+import { ActionProjectType, OrganizationActionScope } from "@app/db/schemas";
import { crypto } from "@app/lib/crypto/cryptography";
import { BadRequestError, InternalServerError, NotFoundError } from "@app/lib/errors";
import { isValidIp } from "@app/lib/ip";
@@ -401,13 +401,14 @@ export const kmipServiceFactory = ({
};
const setupOrgKmip = async ({ caKeyAlgorithm, actorOrgId, actor, actorId, actorAuthMethod }: TSetupOrgKmipDTO) => {
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- actorOrgId,
+ orgId: actorOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionKmipActions.Setup, OrgPermissionSubjects.Kmip);
const kmipConfig = await kmipOrgConfigDAL.findOne({
@@ -566,7 +567,14 @@ export const kmipServiceFactory = ({
};
const getOrgKmip = async ({ actorOrgId, actor, actorId, actorAuthMethod }: TGetOrgKmipDTO) => {
- await permissionService.getOrgPermission(actor, actorId, actorOrgId, actorAuthMethod, actorOrgId);
+ await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
+ actor,
+ actorId,
+ orgId: actorOrgId,
+ actorAuthMethod,
+ actorOrgId
+ });
const kmipConfig = await kmipOrgConfigDAL.findOne({
orgId: actorOrgId
@@ -759,13 +767,14 @@ export const kmipServiceFactory = ({
keyAlgorithm,
hostnamesOrIps
}: TRegisterServerDTO) => {
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- actorOrgId,
+ orgId: actorOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionKmipActions.Proxy, OrgPermissionSubjects.Kmip);
diff --git a/backend/src/ee/services/ldap-config/ldap-config-service.ts b/backend/src/ee/services/ldap-config/ldap-config-service.ts
index 43ca5ab3d1..86bfcc6873 100644
--- a/backend/src/ee/services/ldap-config/ldap-config-service.ts
+++ b/backend/src/ee/services/ldap-config/ldap-config-service.ts
@@ -1,7 +1,14 @@
import { ForbiddenError } from "@casl/ability";
import { Knex } from "knex";
-import { AccessScope, OrgMembershipStatus, TableName, TLdapConfigsUpdate, TUsers } from "@app/db/schemas";
+import {
+ AccessScope,
+ OrganizationActionScope,
+ OrgMembershipStatus,
+ TableName,
+ TLdapConfigsUpdate,
+ TUsers
+} from "@app/db/schemas";
import { TGroupDALFactory } from "@app/ee/services/group/group-dal";
import { addUsersToGroupByUserIds, removeUsersFromGroupByUserIds } from "@app/ee/services/group/group-fns";
import { TUserGroupMembershipDALFactory } from "@app/ee/services/group/user-group-membership-dal";
@@ -119,7 +126,14 @@ export const ldapConfigServiceFactory = ({
groupSearchFilter,
caCert
}: TCreateLdapCfgDTO) => {
- const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorAuthMethod, actorOrgId);
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.ParentOrganization,
+ actor,
+ actorId,
+ orgId: actorOrgId,
+ actorAuthMethod,
+ actorOrgId
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Create, OrgPermissionSubjects.Ldap);
const plan = await licenseService.getPlan(orgId);
@@ -238,7 +252,14 @@ export const ldapConfigServiceFactory = ({
groupSearchFilter,
caCert
}: TUpdateLdapCfgDTO) => {
- const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorAuthMethod, actorOrgId);
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.ParentOrganization,
+ actor,
+ actorId,
+ orgId: actorOrgId,
+ actorAuthMethod,
+ actorOrgId
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Edit, OrgPermissionSubjects.Ldap);
const plan = await licenseService.getPlan(orgId);
@@ -316,7 +337,14 @@ export const ldapConfigServiceFactory = ({
actorAuthMethod,
actorOrgId
}: TGetLdapCfgDTO) => {
- const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorAuthMethod, actorOrgId);
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.ParentOrganization,
+ actor,
+ actorId,
+ orgId: actorOrgId,
+ actorAuthMethod,
+ actorOrgId
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Ldap);
return getLdapCfg({
orgId
@@ -649,7 +677,14 @@ export const ldapConfigServiceFactory = ({
actorAuthMethod,
actorOrgId
}: TGetLdapGroupMapsDTO) => {
- const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorAuthMethod, actorOrgId);
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.ParentOrganization,
+ actor,
+ actorId,
+ orgId: actorOrgId,
+ actorAuthMethod,
+ actorOrgId
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Ldap);
const ldapConfig = await ldapConfigDAL.findOne({
@@ -678,7 +713,14 @@ export const ldapConfigServiceFactory = ({
actorAuthMethod,
actorOrgId
}: TCreateLdapGroupMapDTO) => {
- const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorAuthMethod, actorOrgId);
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.ParentOrganization,
+ actor,
+ actorId,
+ orgId: actorOrgId,
+ actorAuthMethod,
+ actorOrgId
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Create, OrgPermissionSubjects.Ldap);
const plan = await licenseService.getPlan(orgId);
@@ -732,7 +774,14 @@ export const ldapConfigServiceFactory = ({
actorAuthMethod,
actorOrgId
}: TDeleteLdapGroupMapDTO) => {
- const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorAuthMethod, actorOrgId);
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.ParentOrganization,
+ actor,
+ actorId,
+ orgId: actorOrgId,
+ actorAuthMethod,
+ actorOrgId
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Delete, OrgPermissionSubjects.Ldap);
const plan = await licenseService.getPlan(orgId);
@@ -771,7 +820,14 @@ export const ldapConfigServiceFactory = ({
caCert,
url
}: TTestLdapConnectionDTO) => {
- const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorAuthMethod, actorOrgId);
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.ParentOrganization,
+ actor,
+ actorId,
+ orgId: actorOrgId,
+ actorAuthMethod,
+ actorOrgId
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Create, OrgPermissionSubjects.Ldap);
const plan = await licenseService.getPlan(orgId);
diff --git a/backend/src/ee/services/license/license-service.ts b/backend/src/ee/services/license/license-service.ts
index fba9d0ccab..2d539dbf0f 100644
--- a/backend/src/ee/services/license/license-service.ts
+++ b/backend/src/ee/services/license/license-service.ts
@@ -9,6 +9,7 @@ import { AxiosError } from "axios";
import { CronJob } from "cron";
import { Knex } from "knex";
+import { OrganizationActionScope } from "@app/db/schemas";
import { TKeyStoreFactory } from "@app/keystore/keystore";
import { getConfig } from "@app/lib/config/env";
import { verifyOfflineLicense } from "@app/lib/crypto";
@@ -319,7 +320,14 @@ export const licenseServiceFactory = ({
actorAuthMethod,
billingCycle
}: TOrgPlansTableDTO) => {
- const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorAuthMethod, actorOrgId);
+ const { permission } = await permissionService.getOrgPermission({
+ actorId,
+ actor,
+ orgId,
+ actorOrgId,
+ actorAuthMethod,
+ scope: OrganizationActionScope.ParentOrganization
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionBillingActions.Read, OrgPermissionSubjects.Billing);
const { data } = await licenseServerCloudApi.request.get(
`/api/license-server/v1/cloud-products?billing-cycle=${billingCycle}`
@@ -336,7 +344,14 @@ export const licenseServiceFactory = ({
projectId,
refreshCache
}: TOrgPlanDTO) => {
- await permissionService.getOrgPermission(actor, actorId, orgId, actorAuthMethod, actorOrgId);
+ await permissionService.getOrgPermission({
+ actorId,
+ actor,
+ orgId,
+ actorOrgId,
+ actorAuthMethod,
+ scope: OrganizationActionScope.ParentOrganization
+ });
if (refreshCache) {
await refreshPlan(orgId);
}
@@ -352,7 +367,14 @@ export const licenseServiceFactory = ({
actorAuthMethod,
success_url
}: TStartOrgTrialDTO) => {
- const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorAuthMethod, actorOrgId);
+ const { permission } = await permissionService.getOrgPermission({
+ actorId,
+ actor,
+ orgId,
+ actorOrgId,
+ actorAuthMethod,
+ scope: OrganizationActionScope.ParentOrganization
+ });
ForbiddenError.from(permission).throwUnlessCan(
OrgPermissionBillingActions.ManageBilling,
OrgPermissionSubjects.Billing
@@ -384,7 +406,14 @@ export const licenseServiceFactory = ({
actorAuthMethod,
actorOrgId
}: TCreateOrgPortalSession) => {
- const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorAuthMethod, actorOrgId);
+ const { permission } = await permissionService.getOrgPermission({
+ actorId,
+ actor,
+ orgId,
+ actorOrgId,
+ actorAuthMethod,
+ scope: OrganizationActionScope.ParentOrganization
+ });
ForbiddenError.from(permission).throwUnlessCan(
OrgPermissionBillingActions.ManageBilling,
OrgPermissionSubjects.Billing
@@ -433,7 +462,14 @@ export const licenseServiceFactory = ({
};
const getOrgBillingInfo = async ({ orgId, actor, actorId, actorAuthMethod, actorOrgId }: TGetOrgBillInfoDTO) => {
- const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorAuthMethod, actorOrgId);
+ const { permission } = await permissionService.getOrgPermission({
+ actorId,
+ actor,
+ orgId,
+ actorOrgId,
+ actorAuthMethod,
+ scope: OrganizationActionScope.ParentOrganization
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionBillingActions.Read, OrgPermissionSubjects.Billing);
const organization = await orgDAL.findOrgById(orgId);
@@ -516,7 +552,14 @@ export const licenseServiceFactory = ({
// returns org current plan feature table
const getOrgPlanTable = async ({ orgId, actor, actorId, actorAuthMethod, actorOrgId }: TGetOrgBillInfoDTO) => {
- const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorAuthMethod, actorOrgId);
+ const { permission } = await permissionService.getOrgPermission({
+ actorId,
+ actor,
+ orgId,
+ actorOrgId,
+ actorAuthMethod,
+ scope: OrganizationActionScope.ParentOrganization
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionBillingActions.Read, OrgPermissionSubjects.Billing);
const organization = await orgDAL.findOrgById(orgId);
@@ -553,7 +596,14 @@ export const licenseServiceFactory = ({
};
const getOrgBillingDetails = async ({ orgId, actor, actorId, actorAuthMethod, actorOrgId }: TGetOrgBillInfoDTO) => {
- const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorAuthMethod, actorOrgId);
+ const { permission } = await permissionService.getOrgPermission({
+ actorId,
+ actor,
+ orgId,
+ actorOrgId,
+ actorAuthMethod,
+ scope: OrganizationActionScope.ParentOrganization
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionBillingActions.Read, OrgPermissionSubjects.Billing);
const organization = await orgDAL.findOrgById(orgId);
@@ -578,7 +628,14 @@ export const licenseServiceFactory = ({
name,
email
}: TUpdateOrgBillingDetailsDTO) => {
- const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorAuthMethod, actorOrgId);
+ const { permission } = await permissionService.getOrgPermission({
+ actorId,
+ actor,
+ orgId,
+ actorOrgId,
+ actorAuthMethod,
+ scope: OrganizationActionScope.ParentOrganization
+ });
ForbiddenError.from(permission).throwUnlessCan(
OrgPermissionBillingActions.ManageBilling,
OrgPermissionSubjects.Billing
@@ -601,7 +658,14 @@ export const licenseServiceFactory = ({
};
const getOrgPmtMethods = async ({ orgId, actor, actorId, actorAuthMethod, actorOrgId }: TOrgPmtMethodsDTO) => {
- const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorAuthMethod, actorOrgId);
+ const { permission } = await permissionService.getOrgPermission({
+ actorId,
+ actor,
+ orgId,
+ actorOrgId,
+ actorAuthMethod,
+ scope: OrganizationActionScope.ParentOrganization
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionBillingActions.Read, OrgPermissionSubjects.Billing);
const organization = await orgDAL.findOrgById(orgId);
@@ -628,7 +692,14 @@ export const licenseServiceFactory = ({
success_url,
cancel_url
}: TAddOrgPmtMethodDTO) => {
- const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorAuthMethod, actorOrgId);
+ const { permission } = await permissionService.getOrgPermission({
+ actorId,
+ actor,
+ orgId,
+ actorOrgId,
+ actorAuthMethod,
+ scope: OrganizationActionScope.ParentOrganization
+ });
ForbiddenError.from(permission).throwUnlessCan(
OrgPermissionBillingActions.ManageBilling,
OrgPermissionSubjects.Billing
@@ -660,7 +731,14 @@ export const licenseServiceFactory = ({
orgId,
pmtMethodId
}: TDelOrgPmtMethodDTO) => {
- const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorAuthMethod, actorOrgId);
+ const { permission } = await permissionService.getOrgPermission({
+ actorId,
+ actor,
+ orgId,
+ actorOrgId,
+ actorAuthMethod,
+ scope: OrganizationActionScope.ParentOrganization
+ });
ForbiddenError.from(permission).throwUnlessCan(
OrgPermissionBillingActions.ManageBilling,
OrgPermissionSubjects.Billing
@@ -692,7 +770,14 @@ export const licenseServiceFactory = ({
};
const getOrgTaxIds = async ({ orgId, actor, actorId, actorAuthMethod, actorOrgId }: TGetOrgTaxIdDTO) => {
- const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorAuthMethod, actorOrgId);
+ const { permission } = await permissionService.getOrgPermission({
+ actorId,
+ actor,
+ orgId,
+ actorOrgId,
+ actorAuthMethod,
+ scope: OrganizationActionScope.ParentOrganization
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionBillingActions.Read, OrgPermissionSubjects.Billing);
const organization = await orgDAL.findOrgById(orgId);
@@ -710,7 +795,14 @@ export const licenseServiceFactory = ({
};
const addOrgTaxId = async ({ actorId, actor, actorAuthMethod, actorOrgId, orgId, type, value }: TAddOrgTaxIdDTO) => {
- const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorAuthMethod, actorOrgId);
+ const { permission } = await permissionService.getOrgPermission({
+ actorId,
+ actor,
+ orgId,
+ actorOrgId,
+ actorAuthMethod,
+ scope: OrganizationActionScope.ParentOrganization
+ });
ForbiddenError.from(permission).throwUnlessCan(
OrgPermissionBillingActions.ManageBilling,
OrgPermissionSubjects.Billing
@@ -734,7 +826,14 @@ export const licenseServiceFactory = ({
};
const delOrgTaxId = async ({ orgId, actor, actorId, actorAuthMethod, actorOrgId, taxId }: TDelOrgTaxIdDTO) => {
- const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorAuthMethod, actorOrgId);
+ const { permission } = await permissionService.getOrgPermission({
+ actorId,
+ actor,
+ orgId,
+ actorOrgId,
+ actorAuthMethod,
+ scope: OrganizationActionScope.ParentOrganization
+ });
ForbiddenError.from(permission).throwUnlessCan(
OrgPermissionBillingActions.ManageBilling,
OrgPermissionSubjects.Billing
@@ -754,7 +853,14 @@ export const licenseServiceFactory = ({
};
const getOrgTaxInvoices = async ({ actorId, actor, actorOrgId, actorAuthMethod, orgId }: TOrgInvoiceDTO) => {
- const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorAuthMethod, actorOrgId);
+ const { permission } = await permissionService.getOrgPermission({
+ actorId,
+ actor,
+ orgId,
+ actorOrgId,
+ actorAuthMethod,
+ scope: OrganizationActionScope.ParentOrganization
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionBillingActions.Read, OrgPermissionSubjects.Billing);
const organization = await orgDAL.findOrgById(orgId);
@@ -771,7 +877,14 @@ export const licenseServiceFactory = ({
};
const getOrgLicenses = async ({ orgId, actor, actorId, actorAuthMethod, actorOrgId }: TOrgLicensesDTO) => {
- const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorAuthMethod, actorOrgId);
+ const { permission } = await permissionService.getOrgPermission({
+ actorId,
+ actor,
+ orgId,
+ actorOrgId,
+ actorAuthMethod,
+ scope: OrganizationActionScope.ParentOrganization
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionBillingActions.Read, OrgPermissionSubjects.Billing);
const organization = await orgDAL.findOrgById(orgId);
diff --git a/backend/src/ee/services/oidc/oidc-config-service.ts b/backend/src/ee/services/oidc/oidc-config-service.ts
index c2672a94e2..e80ec7cf5b 100644
--- a/backend/src/ee/services/oidc/oidc-config-service.ts
+++ b/backend/src/ee/services/oidc/oidc-config-service.ts
@@ -2,7 +2,7 @@
import { ForbiddenError } from "@casl/ability";
import { Issuer, Issuer as OpenIdIssuer, Strategy as OpenIdStrategy, TokenSet } from "openid-client";
-import { AccessScope, OrgMembershipStatus, TableName, TUsers } from "@app/db/schemas";
+import { AccessScope, OrganizationActionScope, OrgMembershipStatus, TableName, TUsers } from "@app/db/schemas";
import { TOidcConfigsUpdate } from "@app/db/schemas/oidc-configs";
import { EventType, TAuditLogServiceFactory } from "@app/ee/services/audit-log/audit-log-types";
import { TGroupDALFactory } from "@app/ee/services/group/group-dal";
@@ -118,13 +118,14 @@ export const oidcConfigServiceFactory = ({
}
if (dto.type === "external") {
- const { permission } = await permissionService.getOrgPermission(
- dto.actor,
- dto.actorId,
- dto.organizationId,
- dto.actorAuthMethod,
- dto.actorOrgId
- );
+ const { permission } = await permissionService.getOrgPermission({
+ actorId: dto.actorId,
+ actor: dto.actor,
+ orgId: dto.organizationId,
+ actorOrgId: dto.actorOrgId,
+ actorAuthMethod: dto.actorAuthMethod,
+ scope: OrganizationActionScope.ParentOrganization
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Sso);
}
@@ -508,13 +509,14 @@ export const oidcConfigServiceFactory = ({
"Failed to update OIDC SSO configuration due to plan restriction. Upgrade plan to update SSO configuration."
});
- const { permission } = await permissionService.getOrgPermission(
- actor,
+ const { permission } = await permissionService.getOrgPermission({
actorId,
- org.id,
+ actor,
+ orgId: org.id,
+ actorOrgId,
actorAuthMethod,
- actorOrgId
- );
+ scope: OrganizationActionScope.ParentOrganization
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Edit, OrgPermissionSubjects.Sso);
if (org.googleSsoAuthEnforced && isActive) {
@@ -602,13 +604,14 @@ export const oidcConfigServiceFactory = ({
"Failed to create OIDC SSO configuration due to plan restriction. Upgrade plan to update SSO configuration."
});
- const { permission } = await permissionService.getOrgPermission(
- actor,
+ const { permission } = await permissionService.getOrgPermission({
actorId,
- org.id,
+ actor,
+ orgId: org.id,
+ actorOrgId,
actorAuthMethod,
- actorOrgId
- );
+ scope: OrganizationActionScope.ParentOrganization
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Create, OrgPermissionSubjects.Sso);
if (org.googleSsoAuthEnforced && isActive) {
@@ -764,7 +767,14 @@ export const oidcConfigServiceFactory = ({
};
const isOidcManageGroupMembershipsEnabled = async (orgId: string, actor: OrgServiceActor) => {
- await permissionService.getOrgPermission(ActorType.USER, actor.id, orgId, actor.authMethod, actor.orgId);
+ await permissionService.getOrgPermission({
+ actor: ActorType.USER,
+ actorId: actor.id,
+ orgId,
+ actorAuthMethod: actor.authMethod,
+ actorOrgId: actor.orgId,
+ scope: OrganizationActionScope.ParentOrganization
+ });
const oidcConfig = await oidcConfigDAL.findOne({
orgId,
diff --git a/backend/src/ee/services/pam-account/pam-account-service.ts b/backend/src/ee/services/pam-account/pam-account-service.ts
index e9ea76e8cb..b8dad991ac 100644
--- a/backend/src/ee/services/pam-account/pam-account-service.ts
+++ b/backend/src/ee/services/pam-account/pam-account-service.ts
@@ -1,6 +1,6 @@
import { ForbiddenError, subject } from "@casl/ability";
-import { ActionProjectType, TPamAccounts, TPamResources } from "@app/db/schemas";
+import { ActionProjectType, OrganizationActionScope, TPamAccounts, TPamResources } from "@app/db/schemas";
import { PAM_RESOURCE_FACTORY_MAP } from "@app/ee/services/pam-resource/pam-resource-factory";
import { decryptResource, decryptResourceConnectionDetails } from "@app/ee/services/pam-resource/pam-resource-fns";
import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service-types";
@@ -459,13 +459,14 @@ export const pamAccountServiceFactory = ({
const project = await projectDAL.findById(session.projectId);
if (!project) throw new NotFoundError({ message: `Project with ID '${session.projectId}' not found` });
- const { permission } = await permissionService.getOrgPermission(
- actor.type,
- actor.id,
- project.orgId,
- actor.authMethod,
- actor.orgId
- );
+ const { permission } = await permissionService.getOrgPermission({
+ actor: actor.type,
+ actorId: actor.id,
+ orgId: project.orgId,
+ actorAuthMethod: actor.authMethod,
+ actorOrgId: actor.orgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(
OrgPermissionGatewayActions.CreateGateways,
diff --git a/backend/src/ee/services/pam-session/pam-session-service.ts b/backend/src/ee/services/pam-session/pam-session-service.ts
index 7133833066..26ff7daa6b 100644
--- a/backend/src/ee/services/pam-session/pam-session-service.ts
+++ b/backend/src/ee/services/pam-session/pam-session-service.ts
@@ -1,6 +1,6 @@
import { ForbiddenError } from "@casl/ability";
-import { ActionProjectType } from "@app/db/schemas";
+import { ActionProjectType, OrganizationActionScope } from "@app/db/schemas";
import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service-types";
import { BadRequestError, ForbiddenRequestError, NotFoundError } from "@app/lib/errors";
import { OrgServiceActor } from "@app/lib/types";
@@ -102,13 +102,14 @@ export const pamSessionServiceFactory = ({
const project = await projectDAL.findById(session.projectId);
if (!project) throw new NotFoundError({ message: `Project with ID '${session.projectId}' not found` });
- const { permission } = await permissionService.getOrgPermission(
- actor.type,
- actor.id,
- project.orgId,
- actor.authMethod,
- actor.orgId
- );
+ const { permission } = await permissionService.getOrgPermission({
+ actor: actor.type,
+ actorId: actor.id,
+ orgId: project.orgId,
+ actorAuthMethod: actor.authMethod,
+ actorOrgId: actor.orgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(
OrgPermissionGatewayActions.CreateGateways,
@@ -142,13 +143,14 @@ export const pamSessionServiceFactory = ({
const project = await projectDAL.findById(session.projectId);
if (!project) throw new NotFoundError({ message: `Project with ID '${session.projectId}' not found` });
- const { permission } = await permissionService.getOrgPermission(
- actor.type,
- actor.id,
- project.orgId,
- actor.authMethod,
- actor.orgId
- );
+ const { permission } = await permissionService.getOrgPermission({
+ actor: actor.type,
+ actorId: actor.id,
+ orgId: project.orgId,
+ actorAuthMethod: actor.authMethod,
+ actorOrgId: actor.orgId,
+ scope: OrganizationActionScope.Any
+ });
if (actor.type === ActorType.IDENTITY) {
ForbiddenError.from(permission).throwUnlessCan(
diff --git a/backend/src/ee/services/project-template/project-template-service.ts b/backend/src/ee/services/project-template/project-template-service.ts
index f3fe07aa81..5a9f04d8d3 100644
--- a/backend/src/ee/services/project-template/project-template-service.ts
+++ b/backend/src/ee/services/project-template/project-template-service.ts
@@ -1,7 +1,7 @@
import { ForbiddenError } from "@casl/ability";
import { packRules } from "@casl/ability/extra";
-import { ProjectType, TProjectTemplates } from "@app/db/schemas";
+import { OrganizationActionScope, ProjectType, TProjectTemplates } from "@app/db/schemas";
import { TLicenseServiceFactory } from "@app/ee/services/license/license-service";
import { OrgPermissionActions, OrgPermissionSubjects } from "@app/ee/services/permission/org-permission";
import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service-types";
@@ -59,13 +59,14 @@ export const projectTemplateServiceFactory = ({
message: "Failed to access project templates due to plan restriction. Upgrade plan to access project templates."
});
- const { permission } = await permissionService.getOrgPermission(
- actor.type,
- actor.id,
- actor.orgId,
- actor.authMethod,
- actor.orgId
- );
+ const { permission } = await permissionService.getOrgPermission({
+ actor: actor.type,
+ actorId: actor.id,
+ orgId: actor.orgId,
+ actorAuthMethod: actor.authMethod,
+ actorOrgId: actor.orgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.ProjectTemplates);
@@ -97,13 +98,14 @@ export const projectTemplateServiceFactory = ({
if (!projectTemplate) throw new NotFoundError({ message: `Could not find project template with Name "${name}"` });
- const { permission } = await permissionService.getOrgPermission(
- actor.type,
- actor.id,
- projectTemplate.orgId,
- actor.authMethod,
- actor.orgId
- );
+ const { permission } = await permissionService.getOrgPermission({
+ actor: actor.type,
+ actorId: actor.id,
+ orgId: projectTemplate.orgId,
+ actorAuthMethod: actor.authMethod,
+ actorOrgId: actor.orgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.ProjectTemplates);
@@ -125,13 +127,14 @@ export const projectTemplateServiceFactory = ({
if (!projectTemplate) throw new NotFoundError({ message: `Could not find project template with ID ${id}` });
- const { permission } = await permissionService.getOrgPermission(
- actor.type,
- actor.id,
- projectTemplate.orgId,
- actor.authMethod,
- actor.orgId
- );
+ const { permission } = await permissionService.getOrgPermission({
+ actor: actor.type,
+ actorId: actor.id,
+ orgId: projectTemplate.orgId,
+ actorAuthMethod: actor.authMethod,
+ actorOrgId: actor.orgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.ProjectTemplates);
@@ -152,13 +155,14 @@ export const projectTemplateServiceFactory = ({
message: "Failed to create project template due to plan restriction. Upgrade plan to access project templates."
});
- const { permission } = await permissionService.getOrgPermission(
- actor.type,
- actor.id,
- actor.orgId,
- actor.authMethod,
- actor.orgId
- );
+ const { permission } = await permissionService.getOrgPermission({
+ actor: actor.type,
+ actorId: actor.id,
+ orgId: actor.orgId,
+ actorAuthMethod: actor.authMethod,
+ actorOrgId: actor.orgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Create, OrgPermissionSubjects.ProjectTemplates);
@@ -213,13 +217,14 @@ export const projectTemplateServiceFactory = ({
if (!projectTemplate) throw new NotFoundError({ message: `Could not find project template with ID ${id}` });
- const { permission } = await permissionService.getOrgPermission(
- actor.type,
- actor.id,
- projectTemplate.orgId,
- actor.authMethod,
- actor.orgId
- );
+ const { permission } = await permissionService.getOrgPermission({
+ actor: actor.type,
+ actorId: actor.id,
+ orgId: projectTemplate.orgId,
+ actorAuthMethod: actor.authMethod,
+ actorOrgId: actor.orgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Edit, OrgPermissionSubjects.ProjectTemplates);
if (projectTemplate.type !== ProjectType.SecretManager && environments)
@@ -272,13 +277,14 @@ export const projectTemplateServiceFactory = ({
if (!projectTemplate) throw new NotFoundError({ message: `Could not find project template with ID ${id}` });
- const { permission } = await permissionService.getOrgPermission(
- actor.type,
- actor.id,
- projectTemplate.orgId,
- actor.authMethod,
- actor.orgId
- );
+ const { permission } = await permissionService.getOrgPermission({
+ actor: actor.type,
+ actorId: actor.id,
+ orgId: projectTemplate.orgId,
+ actorAuthMethod: actor.authMethod,
+ actorOrgId: actor.orgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Delete, OrgPermissionSubjects.ProjectTemplates);
diff --git a/backend/src/ee/services/relay/relay-service.ts b/backend/src/ee/services/relay/relay-service.ts
index d791e99195..b2eb932ed2 100644
--- a/backend/src/ee/services/relay/relay-service.ts
+++ b/backend/src/ee/services/relay/relay-service.ts
@@ -3,7 +3,7 @@ import { isIP } from "node:net";
import { ForbiddenError } from "@casl/ability";
import * as x509 from "@peculiar/x509";
-import { OrgMembershipRole, TRelays } from "@app/db/schemas";
+import { OrganizationActionScope, OrgMembershipRole, TRelays } from "@app/db/schemas";
import { PgSqlLock } from "@app/keystore/keystore";
import { crypto } from "@app/lib/crypto";
import { BadRequestError, ForbiddenRequestError, NotFoundError } from "@app/lib/errors";
@@ -126,8 +126,8 @@ export const relayServiceFactory = ({
// generate instance relay CA
const instanceRelayCaSerialNumber = createSerialNumber();
- const instanceRelayCaIssuedAt = new Date();
const instanceRelayCaExpiration = new Date(new Date().setFullYear(2045));
+ const instanceRelayCaIssuedAt = new Date();
const instanceRelayCaKeys = await crypto.nativeCrypto.subtle.generateKey(alg, true, ["sign", "verify"]);
const instanceRelayCaSkObj = crypto.nativeCrypto.KeyObject.from(instanceRelayCaKeys.privateKey);
const instanceRelayCaCert = await x509.X509CertificateGenerator.create({
@@ -972,13 +972,14 @@ export const relayServiceFactory = ({
});
}
- const { permission } = await permissionService.getOrgPermission(
- ActorType.IDENTITY,
- identityId,
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
+ actor: ActorType.IDENTITY,
+ actorId: identityId,
orgId,
- actorAuthMethod!,
- orgId
- );
+ actorAuthMethod: actorAuthMethod!,
+ actorOrgId: orgId
+ });
ForbiddenError.from(permission).throwUnlessCan(
OrgPermissionRelayActions.CreateRelays,
@@ -1102,13 +1103,14 @@ export const relayServiceFactory = ({
});
}
- const { permission } = await permissionService.getOrgPermission(
- ActorType.IDENTITY,
- identityId,
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
+ actor: ActorType.IDENTITY,
+ actorId: identityId,
orgId,
- actorAuthMethod!,
- orgId
- );
+ actorAuthMethod: actorAuthMethod!,
+ actorOrgId: orgId
+ });
ForbiddenError.from(permission).throwUnlessCan(
OrgPermissionRelayActions.CreateRelays,
OrgPermissionSubjects.Relay
@@ -1155,13 +1157,14 @@ export const relayServiceFactory = ({
actorAuthMethod: ActorAuthMethod;
actorOrgId: string;
}) => {
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- actorOrgId,
- actorAuthMethod,
+ orgId: actorOrgId,
+ actorAuthMethod: actorAuthMethod!,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionRelayActions.ListRelays, OrgPermissionSubjects.Relay);
@@ -1189,13 +1192,14 @@ export const relayServiceFactory = ({
actorAuthMethod: ActorAuthMethod;
actorOrgId: string;
}) => {
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- actorOrgId,
+ orgId: actorOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionRelayActions.DeleteRelays, OrgPermissionSubjects.Relay);
diff --git a/backend/src/ee/services/saml-config/saml-config-service.ts b/backend/src/ee/services/saml-config/saml-config-service.ts
index ab84ebd398..abe8c3d2e5 100644
--- a/backend/src/ee/services/saml-config/saml-config-service.ts
+++ b/backend/src/ee/services/saml-config/saml-config-service.ts
@@ -5,6 +5,7 @@ import RE2 from "re2";
import {
AccessScope,
+ OrganizationActionScope,
OrgMembershipRole,
OrgMembershipStatus,
TableName,
@@ -251,7 +252,14 @@ export const samlConfigServiceFactory = ({
authProvider,
enableGroupSync
}) => {
- const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorAuthMethod, actorOrgId);
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.ParentOrganization,
+ actor,
+ actorId,
+ orgId,
+ actorAuthMethod,
+ actorOrgId
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Create, OrgPermissionSubjects.Sso);
const plan = await licenseService.getPlan(orgId);
@@ -317,7 +325,14 @@ export const samlConfigServiceFactory = ({
authProvider,
enableGroupSync
}) => {
- const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorAuthMethod, actorOrgId);
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.ParentOrganization,
+ actor,
+ actorId,
+ orgId,
+ actorAuthMethod,
+ actorOrgId
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Edit, OrgPermissionSubjects.Sso);
const plan = await licenseService.getPlan(orgId);
if (!plan.samlSSO)
@@ -424,13 +439,14 @@ export const samlConfigServiceFactory = ({
// when dto is type id means it's internally used
if (dto.type === "org") {
- const { permission } = await permissionService.getOrgPermission(
- dto.actor,
- dto.actorId,
- samlConfig.orgId,
- dto.actorAuthMethod,
- dto.actorOrgId
- );
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.ParentOrganization,
+ actor: dto.actor,
+ actorId: dto.actorId,
+ orgId: samlConfig.orgId,
+ actorAuthMethod: dto.actorAuthMethod,
+ actorOrgId: dto.actorOrgId
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Sso);
}
const { decryptor } = await kmsService.createCipherPairWithDataKey({
diff --git a/backend/src/ee/services/scim/scim-service.ts b/backend/src/ee/services/scim/scim-service.ts
index a08cd5dbfc..e3a6d5e7ea 100644
--- a/backend/src/ee/services/scim/scim-service.ts
+++ b/backend/src/ee/services/scim/scim-service.ts
@@ -4,6 +4,7 @@ import { scimPatch } from "scim-patch";
import {
AccessScope,
+ OrganizationActionScope,
OrgMembershipRole,
OrgMembershipStatus,
TableName,
@@ -125,7 +126,14 @@ export const scimServiceFactory = ({
description,
ttlDays
}) => {
- const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorAuthMethod, actorOrgId);
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.ParentOrganization,
+ actor,
+ actorId,
+ orgId: actorOrgId,
+ actorAuthMethod,
+ actorOrgId
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Create, OrgPermissionSubjects.Scim);
const plan = await licenseService.getPlan(orgId);
@@ -160,7 +168,14 @@ export const scimServiceFactory = ({
actorAuthMethod,
orgId
}) => {
- const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorAuthMethod, actorOrgId);
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.ParentOrganization,
+ actor,
+ actorId,
+ orgId: actorOrgId,
+ actorAuthMethod,
+ actorOrgId
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Scim);
const plan = await licenseService.getPlan(orgId);
@@ -183,13 +198,14 @@ export const scimServiceFactory = ({
let scimToken = await scimDAL.findById(scimTokenId);
if (!scimToken) throw new NotFoundError({ message: `SCIM token with ID '${scimTokenId}' not found` });
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.ParentOrganization,
actor,
actorId,
- scimToken.orgId,
+ orgId: scimToken.orgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Delete, OrgPermissionSubjects.Scim);
const plan = await licenseService.getPlan(scimToken.orgId);
diff --git a/backend/src/ee/services/secret-scanning/secret-scanning-service.ts b/backend/src/ee/services/secret-scanning/secret-scanning-service.ts
index 85a3cd5f2d..a5fbe37a78 100644
--- a/backend/src/ee/services/secret-scanning/secret-scanning-service.ts
+++ b/backend/src/ee/services/secret-scanning/secret-scanning-service.ts
@@ -2,6 +2,7 @@ import { ForbiddenError } from "@casl/ability";
import { WebhookEventMap } from "@octokit/webhooks-types";
import { ProbotOctokit } from "probot";
+import { OrganizationActionScope } from "@app/db/schemas";
import { OrgPermissionActions, OrgPermissionSubjects } from "@app/ee/services/permission/org-permission";
import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service-types";
import { getConfig } from "@app/lib/config/env";
@@ -49,7 +50,14 @@ export const secretScanningServiceFactory = ({
}: TInstallAppSessionDTO) => {
const appCfg = getConfig();
- const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorAuthMethod, actorOrgId);
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
+ actor,
+ actorId,
+ orgId,
+ actorAuthMethod,
+ actorOrgId
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Create, OrgPermissionSubjects.SecretScanning);
const sessionId = crypto.randomBytes(16).toString("hex");
@@ -68,13 +76,14 @@ export const secretScanningServiceFactory = ({
const session = await gitAppInstallSessionDAL.findOne({ sessionId });
if (!session) throw new NotFoundError({ message: "Session was not found" });
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- session.orgId,
+ orgId: session.orgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Create, OrgPermissionSubjects.SecretScanning);
const installatedApp = await gitAppOrgDAL.transaction(async (tx) => {
await gitAppInstallSessionDAL.deleteById(session.id, tx);
@@ -117,7 +126,14 @@ export const secretScanningServiceFactory = ({
actorAuthMethod,
actorOrgId
}: TGetOrgInstallStatusDTO) => {
- const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorAuthMethod, actorOrgId);
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
+ actor,
+ actorId,
+ orgId,
+ actorAuthMethod,
+ actorOrgId
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.SecretScanning);
const appInstallation = await gitAppOrgDAL.findOne({ orgId });
@@ -125,7 +141,14 @@ export const secretScanningServiceFactory = ({
};
const getRisksByOrg = async ({ actor, orgId, actorId, actorAuthMethod, actorOrgId, filter }: TGetOrgRisksDTO) => {
- const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorAuthMethod, actorOrgId);
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
+ actor,
+ actorId,
+ orgId,
+ actorAuthMethod,
+ actorOrgId
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.SecretScanning);
const results = await secretScanningDAL.findByOrgId(orgId, filter);
@@ -134,7 +157,14 @@ export const secretScanningServiceFactory = ({
};
const getAllRisksByOrg = async ({ actor, orgId, actorId, actorAuthMethod, actorOrgId }: TGetAllOrgRisksDTO) => {
- const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorAuthMethod, actorOrgId);
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
+ actor,
+ actorId,
+ orgId,
+ actorAuthMethod,
+ actorOrgId
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.SecretScanning);
const risks = await secretScanningDAL.find({ orgId }, { sort: [["createdAt", "desc"]] });
@@ -150,7 +180,14 @@ export const secretScanningServiceFactory = ({
riskId,
status
}: TUpdateRiskStatusDTO) => {
- const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorAuthMethod, actorOrgId);
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
+ actor,
+ actorId,
+ orgId,
+ actorAuthMethod,
+ actorOrgId
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Edit, OrgPermissionSubjects.SecretScanning);
const isRiskResolved = Boolean(
diff --git a/backend/src/lib/types/index.ts b/backend/src/lib/types/index.ts
index 1a2262bc18..ff6013b7f2 100644
--- a/backend/src/lib/types/index.ts
+++ b/backend/src/lib/types/index.ts
@@ -81,6 +81,13 @@ export type OrgServiceActor = {
parentOrgId: string;
};
+export type ProjectServiceActor = {
+ type: ActorType;
+ id: string;
+ authMethod: ActorAuthMethod;
+ orgId: string;
+};
+
export enum QueueWorkerProfile {
All = "all",
Standard = "standard",
diff --git a/backend/src/server/routes/index.ts b/backend/src/server/routes/index.ts
index 4a73a650cf..bcf508835e 100644
--- a/backend/src/server/routes/index.ts
+++ b/backend/src/server/routes/index.ts
@@ -131,6 +131,7 @@ import { sshHostLoginUserDALFactory } from "@app/ee/services/ssh-host/ssh-login-
import { sshHostGroupDALFactory } from "@app/ee/services/ssh-host-group/ssh-host-group-dal";
import { sshHostGroupMembershipDALFactory } from "@app/ee/services/ssh-host-group/ssh-host-group-membership-dal";
import { sshHostGroupServiceFactory } from "@app/ee/services/ssh-host-group/ssh-host-group-service";
+import { subOrgServiceFactory } from "@app/ee/services/sub-org/sub-org-service";
import { trustedIpDALFactory } from "@app/ee/services/trusted-ip/trusted-ip-dal";
import { trustedIpServiceFactory } from "@app/ee/services/trusted-ip/trusted-ip-service";
import { keyValueStoreDALFactory } from "@app/keystore/key-value-store-dal";
@@ -564,7 +565,7 @@ export const registerRoutes = async (
projectDAL
});
- const tokenService = tokenServiceFactory({ tokenDAL: authTokenDAL, userDAL, membershipUserDAL });
+ const tokenService = tokenServiceFactory({ tokenDAL: authTokenDAL, userDAL, membershipUserDAL, orgDAL });
const membershipUserService = membershipUserServiceFactory({
licenseService,
@@ -904,6 +905,15 @@ export const registerRoutes = async (
userGroupMembershipDAL,
additionalPrivilegeDAL
});
+
+ const subOrgService = subOrgServiceFactory({
+ licenseService,
+ membershipDAL,
+ membershipRoleDAL,
+ orgDAL,
+ permissionService
+ });
+
const signupService = authSignupServiceFactory({
tokenService,
smtpService,
@@ -1601,7 +1611,8 @@ export const registerRoutes = async (
identityAccessTokenDAL,
accessTokenQueue,
identityDAL,
- membershipIdentityDAL
+ membershipIdentityDAL,
+ orgDAL
});
const identityTokenAuthService = identityTokenAuthServiceFactory({
@@ -2248,6 +2259,7 @@ export const registerRoutes = async (
groupProject: groupProjectService,
permission: permissionService,
org: orgService,
+ subOrganization: subOrgService,
oidc: oidcService,
apiKey: apiKeyService,
authToken: tokenService,
diff --git a/backend/src/services/app-connection/app-connection-service.ts b/backend/src/services/app-connection/app-connection-service.ts
index 5e26ebdaf9..d599568b34 100644
--- a/backend/src/services/app-connection/app-connection-service.ts
+++ b/backend/src/services/app-connection/app-connection-service.ts
@@ -1,6 +1,6 @@
import { ForbiddenError, subject } from "@casl/ability";
-import { ActionProjectType, TAppConnections } from "@app/db/schemas";
+import { ActionProjectType, OrganizationActionScope, TAppConnections } from "@app/db/schemas";
import { ValidateOCIConnectionCredentialsSchema } from "@app/ee/services/app-connections/oci";
import { ociConnectionService } from "@app/ee/services/app-connections/oci/oci-connection-service";
import { ValidateOracleDBConnectionCredentialsSchema } from "@app/ee/services/app-connections/oracledb";
@@ -215,13 +215,14 @@ export const appConnectionServiceFactory = ({
)
);
} else {
- const { permission } = await permissionService.getOrgPermission(
- actor.type,
- actor.id,
- actor.orgId,
- actor.authMethod,
- actor.orgId
- );
+ const { permission } = await permissionService.getOrgPermission({
+ actorId: actor.id,
+ actor: actor.type,
+ orgId: actor.orgId,
+ actorOrgId: actor.orgId,
+ actorAuthMethod: actor.authMethod,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(
OrgPermissionAppConnectionActions.Read,
@@ -268,13 +269,14 @@ export const appConnectionServiceFactory = ({
subject(ProjectPermissionSub.AppConnections, { connectionId })
);
} else {
- const { permission } = await permissionService.getOrgPermission(
- actor.type,
- actor.id,
- appConnection.orgId,
- actor.authMethod,
- actor.orgId
- );
+ const { permission } = await permissionService.getOrgPermission({
+ actorId: actor.id,
+ actor: actor.type,
+ orgId: appConnection.orgId,
+ actorOrgId: actor.orgId,
+ actorAuthMethod: actor.authMethod,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(
OrgPermissionAppConnectionActions.Read,
@@ -318,13 +320,14 @@ export const appConnectionServiceFactory = ({
subject(ProjectPermissionSub.AppConnections, { connectionId: appConnection.id })
);
} else {
- const { permission } = await permissionService.getOrgPermission(
- actor.type,
- actor.id,
- appConnection.orgId,
- actor.authMethod,
- actor.orgId
- );
+ const { permission } = await permissionService.getOrgPermission({
+ actorId: actor.id,
+ actor: actor.type,
+ orgId: appConnection.orgId,
+ actorOrgId: actor.orgId,
+ actorAuthMethod: actor.authMethod,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(
OrgPermissionAppConnectionActions.Read,
@@ -342,13 +345,14 @@ export const appConnectionServiceFactory = ({
{ method, app, credentials, gatewayId, projectId, ...params }: TCreateAppConnectionDTO,
actor: OrgServiceActor
) => {
- const { permission: orgPermission } = await permissionService.getOrgPermission(
- actor.type,
- actor.id,
- actor.orgId,
- actor.authMethod,
- actor.orgId
- );
+ const { permission: orgPermission } = await permissionService.getOrgPermission({
+ actorId: actor.id,
+ actor: actor.type,
+ orgId: actor.orgId,
+ actorOrgId: actor.orgId,
+ actorAuthMethod: actor.authMethod,
+ scope: OrganizationActionScope.Any
+ });
if (projectId) {
const project = await projectDAL.findProjectById(projectId);
@@ -477,13 +481,14 @@ export const appConnectionServiceFactory = ({
"Failed to update app connection due to plan restriction. Upgrade plan to access enterprise app connections."
);
- const { permission: orgPermission } = await permissionService.getOrgPermission(
- actor.type,
- actor.id,
- appConnection.orgId,
- actor.authMethod,
- actor.orgId
- );
+ const { permission: orgPermission } = await permissionService.getOrgPermission({
+ actorId: actor.id,
+ actor: actor.type,
+ orgId: appConnection.orgId,
+ actorOrgId: actor.orgId,
+ actorAuthMethod: actor.authMethod,
+ scope: OrganizationActionScope.Any
+ });
if (appConnection.projectId) {
const { permission } = await permissionService.getProjectPermission({
@@ -635,13 +640,14 @@ export const appConnectionServiceFactory = ({
subject(ProjectPermissionSub.AppConnections, { connectionId })
);
} else {
- const { permission } = await permissionService.getOrgPermission(
- actor.type,
- actor.id,
- appConnection.orgId,
- actor.authMethod,
- actor.orgId
- );
+ const { permission } = await permissionService.getOrgPermission({
+ actorId: actor.id,
+ actor: actor.type,
+ orgId: appConnection.orgId,
+ actorOrgId: actor.orgId,
+ actorAuthMethod: actor.authMethod,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(
OrgPermissionAppConnectionActions.Delete,
@@ -704,13 +710,14 @@ export const appConnectionServiceFactory = ({
subject(ProjectPermissionSub.AppConnections, { connectionId })
);
} else {
- const { permission: orgPermission } = await permissionService.getOrgPermission(
- actor.type,
- actor.id,
- appConnection.orgId,
- actor.authMethod,
- actor.orgId
- );
+ const { permission: orgPermission } = await permissionService.getOrgPermission({
+ actorId: actor.id,
+ actor: actor.type,
+ orgId: appConnection.orgId,
+ actorOrgId: actor.orgId,
+ actorAuthMethod: actor.authMethod,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(orgPermission).throwUnlessCan(
OrgPermissionAppConnectionActions.Connect,
@@ -747,13 +754,14 @@ export const appConnectionServiceFactory = ({
};
const listAvailableAppConnectionsForUser = async (app: AppConnection, actor: OrgServiceActor, projectId?: string) => {
- const { permission: orgPermission } = await permissionService.getOrgPermission(
- actor.type,
- actor.id,
- actor.orgId,
- actor.authMethod,
- actor.orgId
- );
+ const { permission: orgPermission } = await permissionService.getOrgPermission({
+ actorId: actor.id,
+ actor: actor.type,
+ orgId: actor.orgId,
+ actorOrgId: actor.orgId,
+ actorAuthMethod: actor.authMethod,
+ scope: OrganizationActionScope.Any
+ });
let availableProjectConnections: TAppConnections[] = [];
@@ -805,13 +813,14 @@ export const appConnectionServiceFactory = ({
if (!appConnection) throw new NotFoundError({ message: `Could not find App Connection with ID ${connectionId}` });
- const { permission } = await permissionService.getOrgPermission(
- actor.type,
- actor.id,
- appConnection.orgId,
- actor.authMethod,
- actor.orgId
- );
+ const { permission } = await permissionService.getOrgPermission({
+ actorId: actor.id,
+ actor: actor.type,
+ orgId: appConnection.orgId,
+ actorOrgId: actor.orgId,
+ actorAuthMethod: actor.authMethod,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(
OrgPermissionAppConnectionActions.Read,
diff --git a/backend/src/services/auth-token/auth-token-service.ts b/backend/src/services/auth-token/auth-token-service.ts
index b30e3beaf3..6d0dfcd4c4 100644
--- a/backend/src/services/auth-token/auth-token-service.ts
+++ b/backend/src/services/auth-token/auth-token-service.ts
@@ -7,10 +7,10 @@ import { BadRequestError, ForbiddenRequestError, NotFoundError, UnauthorizedErro
import { AuthModeJwtTokenPayload, AuthModeRefreshJwtTokenPayload, AuthTokenType } from "../auth/auth-type";
import { TMembershipUserDALFactory } from "../membership-user/membership-user-dal";
+import { TOrgDALFactory } from "../org/org-dal";
import { TUserDALFactory } from "../user/user-dal";
import { TTokenDALFactory } from "./auth-token-dal";
import { TCreateTokenForUserDTO, TIssueAuthTokenDTO, TokenType, TValidateTokenForUserDTO } from "./auth-token-types";
-import { TOrgDALFactory } from "../org/org-dal";
type TAuthTokenServiceFactoryDep = {
tokenDAL: TTokenDALFactory;
diff --git a/backend/src/services/external-group-org-role-mapping/external-group-org-role-mapping-service.ts b/backend/src/services/external-group-org-role-mapping/external-group-org-role-mapping-service.ts
index a072544ca7..e51d25ce37 100644
--- a/backend/src/services/external-group-org-role-mapping/external-group-org-role-mapping-service.ts
+++ b/backend/src/services/external-group-org-role-mapping/external-group-org-role-mapping-service.ts
@@ -1,5 +1,6 @@
import { ForbiddenError } from "@casl/ability";
+import { OrganizationActionScope } from "@app/db/schemas";
import { TLicenseServiceFactory } from "@app/ee/services/license/license-service";
import { OrgPermissionActions, OrgPermissionSubjects } from "@app/ee/services/permission/org-permission";
import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service-types";
@@ -26,13 +27,14 @@ export const externalGroupOrgRoleMappingServiceFactory = ({
roleDAL
}: TExternalGroupOrgRoleMappingServiceFactoryDep) => {
const listExternalGroupOrgRoleMappings = async (actor: OrgServiceActor) => {
- const { permission } = await permissionService.getOrgPermission(
- actor.type,
- actor.id,
- actor.orgId,
- actor.authMethod,
- actor.orgId
- );
+ const { permission } = await permissionService.getOrgPermission({
+ actor: actor.type,
+ actorId: actor.id,
+ orgId: actor.orgId,
+ actorAuthMethod: actor.authMethod,
+ actorOrgId: actor.orgId,
+ scope: OrganizationActionScope.ParentOrganization
+ });
// TODO: will need to change if we add support for ldap, oidc, etc.
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Scim);
@@ -48,13 +50,14 @@ export const externalGroupOrgRoleMappingServiceFactory = ({
dto: TSyncExternalGroupOrgMembershipRoleMappingsDTO,
actor: OrgServiceActor
) => {
- const { permission } = await permissionService.getOrgPermission(
- actor.type,
- actor.id,
- actor.orgId,
- actor.authMethod,
- actor.orgId
- );
+ const { permission } = await permissionService.getOrgPermission({
+ actor: actor.type,
+ actorId: actor.id,
+ orgId: actor.orgId,
+ actorAuthMethod: actor.authMethod,
+ actorOrgId: actor.orgId,
+ scope: OrganizationActionScope.ParentOrganization
+ });
// TODO: will need to change if we add support for ldap, oidc, etc.
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Edit, OrgPermissionSubjects.Scim);
diff --git a/backend/src/services/external-migration/external-migration-service.ts b/backend/src/services/external-migration/external-migration-service.ts
index 4192ffcd54..3cc128768e 100644
--- a/backend/src/services/external-migration/external-migration-service.ts
+++ b/backend/src/services/external-migration/external-migration-service.ts
@@ -1,4 +1,4 @@
-import { OrgMembershipRole } from "@app/db/schemas";
+import { OrganizationActionScope, OrgMembershipRole } from "@app/db/schemas";
import {
AuditLogInfo,
EventType,
@@ -89,13 +89,14 @@ export const externalMigrationServiceFactory = ({
throw new BadRequestError({ message: "EnvKey migration is not supported when running in FIPS mode." });
}
- const { hasRole } = await permissionService.getOrgPermission(
- actor,
+ const { hasRole } = await permissionService.getOrgPermission({
actorId,
+ actor,
+ orgId: actorOrgId,
actorOrgId,
actorAuthMethod,
- actorOrgId
- );
+ scope: OrganizationActionScope.Any
+ });
if (!hasRole(OrgMembershipRole.Admin)) {
throw new ForbiddenRequestError({ message: "Only admins can import data" });
}
@@ -136,13 +137,14 @@ export const externalMigrationServiceFactory = ({
actorOrgId,
actorAuthMethod
}: TImportVaultDataDTO) => {
- const { hasRole } = await permissionService.getOrgPermission(
- actor,
+ const { hasRole } = await permissionService.getOrgPermission({
actorId,
+ actor,
+ orgId: actorOrgId,
actorOrgId,
actorAuthMethod,
- actorOrgId
- );
+ scope: OrganizationActionScope.Any
+ });
if (!hasRole(OrgMembershipRole.Admin)) {
throw new ForbiddenRequestError({ message: "Only admins can import data" });
@@ -192,13 +194,14 @@ export const externalMigrationServiceFactory = ({
actorAuthMethod,
provider
}: THasCustomVaultMigrationDTO) => {
- const { hasRole } = await permissionService.getOrgPermission(
- actor,
+ const { hasRole } = await permissionService.getOrgPermission({
actorId,
+ actor,
+ orgId: actorOrgId,
actorOrgId,
actorAuthMethod,
- actorOrgId
- );
+ scope: OrganizationActionScope.Any
+ });
if (!hasRole(OrgMembershipRole.Admin)) {
throw new ForbiddenRequestError({ message: "Only admins can check custom migration status" });
@@ -247,13 +250,14 @@ export const externalMigrationServiceFactory = ({
};
const createVaultExternalMigration = async ({ namespace, connectionId, actor }: TCreateVaultExternalMigrationDTO) => {
- const { hasRole } = await permissionService.getOrgPermission(
- actor.type,
- actor.id,
- actor.orgId,
- actor.authMethod,
- actor.orgId
- );
+ const { hasRole } = await permissionService.getOrgPermission({
+ actorId: actor.id,
+ actor: actor.type,
+ orgId: actor.orgId,
+ actorOrgId: actor.orgId,
+ actorAuthMethod: actor.authMethod,
+ scope: OrganizationActionScope.Any
+ });
if (!hasRole(OrgMembershipRole.Admin)) {
throw new ForbiddenRequestError({ message: "Only admins can configure vault external migration" });
@@ -298,13 +302,14 @@ export const externalMigrationServiceFactory = ({
connectionId,
actor
}: TUpdateVaultExternalMigrationDTO) => {
- const { hasRole } = await permissionService.getOrgPermission(
- actor.type,
- actor.id,
- actor.orgId,
- actor.authMethod,
- actor.orgId
- );
+ const { hasRole } = await permissionService.getOrgPermission({
+ actorId: actor.id,
+ actor: actor.type,
+ orgId: actor.orgId,
+ actorOrgId: actor.orgId,
+ actorAuthMethod: actor.authMethod,
+ scope: OrganizationActionScope.Any
+ });
if (!hasRole(OrgMembershipRole.Admin)) {
throw new ForbiddenRequestError({ message: "Only admins can update vault external migration" });
@@ -332,13 +337,14 @@ export const externalMigrationServiceFactory = ({
};
const getVaultExternalMigrationConfigs = async ({ actor }: { actor: OrgServiceActor }) => {
- const { hasRole } = await permissionService.getOrgPermission(
- actor.type,
- actor.id,
- actor.orgId,
- actor.authMethod,
- actor.orgId
- );
+ const { hasRole } = await permissionService.getOrgPermission({
+ actorId: actor.id,
+ actor: actor.type,
+ orgId: actor.orgId,
+ actorOrgId: actor.orgId,
+ actorAuthMethod: actor.authMethod,
+ scope: OrganizationActionScope.Any
+ });
if (!hasRole(OrgMembershipRole.Admin)) {
throw new ForbiddenRequestError({ message: "Only admins can view vault external migration configs" });
@@ -352,13 +358,14 @@ export const externalMigrationServiceFactory = ({
};
const getVaultNamespaces = async ({ actor }: { actor: OrgServiceActor }) => {
- const { hasRole } = await permissionService.getOrgPermission(
- actor.type,
- actor.id,
- actor.orgId,
- actor.authMethod,
- actor.orgId
- );
+ const { hasRole } = await permissionService.getOrgPermission({
+ actorId: actor.id,
+ actor: actor.type,
+ orgId: actor.orgId,
+ actorOrgId: actor.orgId,
+ actorAuthMethod: actor.authMethod,
+ scope: OrganizationActionScope.Any
+ });
if (!hasRole(OrgMembershipRole.Admin)) {
throw new ForbiddenRequestError({ message: "Only admins can view vault namespaces" });
@@ -380,13 +387,14 @@ export const externalMigrationServiceFactory = ({
};
const getVaultPolicies = async ({ actor, namespace }: { actor: OrgServiceActor; namespace: string }) => {
- const { hasRole } = await permissionService.getOrgPermission(
- actor.type,
- actor.id,
- actor.orgId,
- actor.authMethod,
- actor.orgId
- );
+ const { hasRole } = await permissionService.getOrgPermission({
+ actorId: actor.id,
+ actor: actor.type,
+ orgId: actor.orgId,
+ actorOrgId: actor.orgId,
+ actorAuthMethod: actor.authMethod,
+ scope: OrganizationActionScope.Any
+ });
if (!hasRole(OrgMembershipRole.Admin)) {
throw new ForbiddenRequestError({ message: "Only admins can view vault policies" });
@@ -422,13 +430,14 @@ export const externalMigrationServiceFactory = ({
};
const getVaultMounts = async ({ actor, namespace }: { actor: OrgServiceActor; namespace: string }) => {
- const { hasRole } = await permissionService.getOrgPermission(
- actor.type,
- actor.id,
- actor.orgId,
- actor.authMethod,
- actor.orgId
- );
+ const { hasRole } = await permissionService.getOrgPermission({
+ actorId: actor.id,
+ actor: actor.type,
+ orgId: actor.orgId,
+ actorOrgId: actor.orgId,
+ actorAuthMethod: actor.authMethod,
+ scope: OrganizationActionScope.Any
+ });
if (!hasRole(OrgMembershipRole.Admin)) {
throw new ForbiddenRequestError({ message: "Only admins can view vault mounts" });
@@ -472,13 +481,14 @@ export const externalMigrationServiceFactory = ({
namespace: string;
mountPath: string;
}) => {
- const { hasRole } = await permissionService.getOrgPermission(
- actor.type,
- actor.id,
- actor.orgId,
- actor.authMethod,
- actor.orgId
- );
+ const { hasRole } = await permissionService.getOrgPermission({
+ actorId: actor.id,
+ actor: actor.type,
+ orgId: actor.orgId,
+ actorOrgId: actor.orgId,
+ actorAuthMethod: actor.authMethod,
+ scope: OrganizationActionScope.Any
+ });
if (!hasRole(OrgMembershipRole.Admin)) {
throw new ForbiddenRequestError({ message: "Only admins can view vault secret paths" });
@@ -531,13 +541,14 @@ export const externalMigrationServiceFactory = ({
vaultSecretPath: string;
auditLogInfo: AuditLogInfo;
}) => {
- const { hasRole } = await permissionService.getOrgPermission(
- actor.type,
- actor.id,
- actor.orgId,
- actor.authMethod,
- actor.orgId
- );
+ const { hasRole } = await permissionService.getOrgPermission({
+ actorId: actor.id,
+ actor: actor.type,
+ orgId: actor.orgId,
+ actorOrgId: actor.orgId,
+ actorAuthMethod: actor.authMethod,
+ scope: OrganizationActionScope.Any
+ });
if (!hasRole(OrgMembershipRole.Admin)) {
throw new ForbiddenRequestError({ message: "Only admins can import vault secrets" });
@@ -617,13 +628,14 @@ export const externalMigrationServiceFactory = ({
};
const deleteVaultExternalMigration = async ({ id, actor }: TDeleteVaultExternalMigrationDTO) => {
- const { hasRole } = await permissionService.getOrgPermission(
- actor.type,
- actor.id,
- actor.orgId,
- actor.authMethod,
- actor.orgId
- );
+ const { hasRole } = await permissionService.getOrgPermission({
+ actorId: actor.id,
+ actor: actor.type,
+ orgId: actor.orgId,
+ actorOrgId: actor.orgId,
+ actorAuthMethod: actor.authMethod,
+ scope: OrganizationActionScope.Any
+ });
if (!hasRole(OrgMembershipRole.Admin)) {
throw new ForbiddenRequestError({ message: "Only admins can delete vault external migration configs" });
@@ -653,13 +665,14 @@ export const externalMigrationServiceFactory = ({
namespace: string;
authType?: string;
}) => {
- const { hasRole } = await permissionService.getOrgPermission(
- actor.type,
- actor.id,
- actor.orgId,
- actor.authMethod,
- actor.orgId
- );
+ const { hasRole } = await permissionService.getOrgPermission({
+ actorId: actor.id,
+ actor: actor.type,
+ orgId: actor.orgId,
+ actorOrgId: actor.orgId,
+ actorAuthMethod: actor.authMethod,
+ scope: OrganizationActionScope.Any
+ });
if (!hasRole(OrgMembershipRole.Admin)) {
throw new ForbiddenRequestError({ message: "Only admins can view vault auth mounts" });
@@ -704,13 +717,14 @@ export const externalMigrationServiceFactory = ({
namespace: string;
mountPath: string;
}) => {
- const { hasRole } = await permissionService.getOrgPermission(
- actor.type,
- actor.id,
- actor.orgId,
- actor.authMethod,
- actor.orgId
- );
+ const { hasRole } = await permissionService.getOrgPermission({
+ actorId: actor.id,
+ actor: actor.type,
+ orgId: actor.orgId,
+ actorOrgId: actor.orgId,
+ actorAuthMethod: actor.authMethod,
+ scope: OrganizationActionScope.Any
+ });
if (!hasRole(OrgMembershipRole.Admin)) {
throw new ForbiddenRequestError({ message: "Only admins can view vault Kubernetes auth roles" });
diff --git a/backend/src/services/identity-access-token/identity-access-token-service.ts b/backend/src/services/identity-access-token/identity-access-token-service.ts
index 0bca289036..f565ebf659 100644
--- a/backend/src/services/identity-access-token/identity-access-token-service.ts
+++ b/backend/src/services/identity-access-token/identity-access-token-service.ts
@@ -8,9 +8,9 @@ import { TAccessTokenQueueServiceFactory } from "../access-token-queue/access-to
import { AuthTokenType } from "../auth/auth-type";
import { TIdentityDALFactory } from "../identity/identity-dal";
import { TMembershipIdentityDALFactory } from "../membership-identity/membership-identity-dal";
+import { TOrgDALFactory } from "../org/org-dal";
import { TIdentityAccessTokenDALFactory } from "./identity-access-token-dal";
import { TIdentityAccessTokenJwtPayload, TRenewAccessTokenDTO } from "./identity-access-token-types";
-import { TOrgDALFactory } from "../org/org-dal";
type TIdentityAccessTokenServiceFactoryDep = {
identityAccessTokenDAL: TIdentityAccessTokenDALFactory;
diff --git a/backend/src/services/identity-alicloud-auth/identity-alicloud-auth-service.ts b/backend/src/services/identity-alicloud-auth/identity-alicloud-auth-service.ts
index 43584a1afb..274703c60f 100644
--- a/backend/src/services/identity-alicloud-auth/identity-alicloud-auth-service.ts
+++ b/backend/src/services/identity-alicloud-auth/identity-alicloud-auth-service.ts
@@ -2,7 +2,7 @@
import { ForbiddenError } from "@casl/ability";
import { AxiosError } from "axios";
-import { AccessScope, IdentityAuthMethod } from "@app/db/schemas";
+import { AccessScope, IdentityAuthMethod, OrganizationActionScope } from "@app/db/schemas";
import { TLicenseServiceFactory } from "@app/ee/services/license/license-service";
import { OrgPermissionIdentityActions, OrgPermissionSubjects } from "@app/ee/services/permission/org-permission";
import {
@@ -173,13 +173,14 @@ export const identityAliCloudAuthServiceFactory = ({
throw new BadRequestError({ message: "Access token TTL cannot be greater than max TTL" });
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityMembershipOrg.scopeOrgId,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Create, OrgPermissionSubjects.Identity);
const plan = await licenseService.getPlan(identityMembershipOrg.scopeOrgId);
@@ -255,13 +256,14 @@ export const identityAliCloudAuthServiceFactory = ({
throw new BadRequestError({ message: "Access token TTL cannot be greater than max TTL" });
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityMembershipOrg.scopeOrgId,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Edit, OrgPermissionSubjects.Identity);
const plan = await licenseService.getPlan(identityMembershipOrg.scopeOrgId);
@@ -313,13 +315,14 @@ export const identityAliCloudAuthServiceFactory = ({
const alicloudIdentityAuth = await identityAliCloudAuthDAL.findOne({ identityId });
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityMembershipOrg.scopeOrgId,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Read, OrgPermissionSubjects.Identity);
return { ...alicloudIdentityAuth, orgId: identityMembershipOrg.scopeOrgId };
};
@@ -344,22 +347,24 @@ export const identityAliCloudAuthServiceFactory = ({
message: "The identity does not have Alibaba Cloud auth"
});
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityMembershipOrg.scopeOrgId,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Edit, OrgPermissionSubjects.Identity);
- const { permission: rolePermission } = await permissionService.getOrgPermission(
- ActorType.IDENTITY,
- identityMembershipOrg.identity.id,
- identityMembershipOrg.scopeOrgId,
+ const { permission: rolePermission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
+ actor: ActorType.IDENTITY,
+ actorId: identityMembershipOrg.identity.id,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
const { shouldUseNewPrivilegeSystem } = await orgDAL.findById(identityMembershipOrg.scopeOrgId);
const permissionBoundary = validatePrivilegeChangeOperation(
diff --git a/backend/src/services/identity-aws-auth/identity-aws-auth-service.ts b/backend/src/services/identity-aws-auth/identity-aws-auth-service.ts
index 8793c3a007..74912635e2 100644
--- a/backend/src/services/identity-aws-auth/identity-aws-auth-service.ts
+++ b/backend/src/services/identity-aws-auth/identity-aws-auth-service.ts
@@ -3,7 +3,7 @@ import { ForbiddenError } from "@casl/ability";
import axios from "axios";
import RE2 from "re2";
-import { AccessScope, IdentityAuthMethod } from "@app/db/schemas";
+import { AccessScope, IdentityAuthMethod, OrganizationActionScope } from "@app/db/schemas";
import { TLicenseServiceFactory } from "@app/ee/services/license/license-service";
import { OrgPermissionIdentityActions, OrgPermissionSubjects } from "@app/ee/services/permission/org-permission";
import {
@@ -251,13 +251,14 @@ export const identityAwsAuthServiceFactory = ({
throw new BadRequestError({ message: "Access token TTL cannot be greater than max TTL" });
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
actor,
actorId,
- identityMembershipOrg.scopeOrgId,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
- actorOrgId
- );
+ actorOrgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Create, OrgPermissionSubjects.Identity);
const plan = await licenseService.getPlan(identityMembershipOrg.scopeOrgId);
@@ -336,13 +337,14 @@ export const identityAwsAuthServiceFactory = ({
throw new BadRequestError({ message: "Access token TTL cannot be greater than max TTL" });
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityMembershipOrg.scopeOrgId,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Edit, OrgPermissionSubjects.Identity);
const plan = await licenseService.getPlan(identityMembershipOrg.scopeOrgId);
@@ -396,13 +398,14 @@ export const identityAwsAuthServiceFactory = ({
const awsIdentityAuth = await identityAwsAuthDAL.findOne({ identityId });
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityMembershipOrg.scopeOrgId,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Read, OrgPermissionSubjects.Identity);
return { ...awsIdentityAuth, orgId: identityMembershipOrg.scopeOrgId };
};
@@ -427,22 +430,24 @@ export const identityAwsAuthServiceFactory = ({
message: "The identity does not have aws auth"
});
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityMembershipOrg.scopeOrgId,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Edit, OrgPermissionSubjects.Identity);
- const { permission: rolePermission } = await permissionService.getOrgPermission(
- ActorType.IDENTITY,
- identityMembershipOrg.identity.id,
- identityMembershipOrg.scopeOrgId,
+ const { permission: rolePermission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
+ actor: ActorType.IDENTITY,
+ actorId: identityMembershipOrg.identity.id,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
const { shouldUseNewPrivilegeSystem } = await orgDAL.findById(identityMembershipOrg.scopeOrgId);
const permissionBoundary = validatePrivilegeChangeOperation(
diff --git a/backend/src/services/identity-azure-auth/identity-azure-auth-service.ts b/backend/src/services/identity-azure-auth/identity-azure-auth-service.ts
index b3250ed56e..98e7b14a4e 100644
--- a/backend/src/services/identity-azure-auth/identity-azure-auth-service.ts
+++ b/backend/src/services/identity-azure-auth/identity-azure-auth-service.ts
@@ -1,6 +1,6 @@
import { ForbiddenError } from "@casl/ability";
-import { AccessScope, IdentityAuthMethod } from "@app/db/schemas";
+import { AccessScope, IdentityAuthMethod, OrganizationActionScope } from "@app/db/schemas";
import { TLicenseServiceFactory } from "@app/ee/services/license/license-service";
import { OrgPermissionIdentityActions, OrgPermissionSubjects } from "@app/ee/services/permission/org-permission";
import {
@@ -163,13 +163,14 @@ export const identityAzureAuthServiceFactory = ({
throw new BadRequestError({ message: "Access token TTL cannot be greater than max TTL" });
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityMembershipOrg.scopeOrgId,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Create, OrgPermissionSubjects.Identity);
const plan = await licenseService.getPlan(identityMembershipOrg.scopeOrgId);
@@ -247,13 +248,14 @@ export const identityAzureAuthServiceFactory = ({
throw new BadRequestError({ message: "Access token TTL cannot be greater than max TTL" });
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityMembershipOrg.scopeOrgId,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Edit, OrgPermissionSubjects.Identity);
const plan = await licenseService.getPlan(identityMembershipOrg.scopeOrgId);
@@ -309,13 +311,14 @@ export const identityAzureAuthServiceFactory = ({
const identityAzureAuth = await identityAzureAuthDAL.findOne({ identityId });
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityMembershipOrg.scopeOrgId,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Read, OrgPermissionSubjects.Identity);
return { ...identityAzureAuth, orgId: identityMembershipOrg.scopeOrgId };
@@ -341,22 +344,24 @@ export const identityAzureAuthServiceFactory = ({
message: "The identity does not have azure auth"
});
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityMembershipOrg.scopeOrgId,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Edit, OrgPermissionSubjects.Identity);
- const { permission: rolePermission } = await permissionService.getOrgPermission(
- ActorType.IDENTITY,
- identityMembershipOrg.identity.id,
- identityMembershipOrg.scopeOrgId,
+ const { permission: rolePermission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
+ actor: ActorType.IDENTITY,
+ actorId: identityMembershipOrg.identity.id,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
const { shouldUseNewPrivilegeSystem } = await orgDAL.findById(identityMembershipOrg.scopeOrgId);
const permissionBoundary = validatePrivilegeChangeOperation(
shouldUseNewPrivilegeSystem,
diff --git a/backend/src/services/identity-gcp-auth/identity-gcp-auth-service.ts b/backend/src/services/identity-gcp-auth/identity-gcp-auth-service.ts
index fe7b9b6d70..05a2c94f86 100644
--- a/backend/src/services/identity-gcp-auth/identity-gcp-auth-service.ts
+++ b/backend/src/services/identity-gcp-auth/identity-gcp-auth-service.ts
@@ -1,6 +1,6 @@
import { ForbiddenError } from "@casl/ability";
-import { AccessScope, IdentityAuthMethod } from "@app/db/schemas";
+import { AccessScope, IdentityAuthMethod, OrganizationActionScope } from "@app/db/schemas";
import { TLicenseServiceFactory } from "@app/ee/services/license/license-service";
import { OrgPermissionIdentityActions, OrgPermissionSubjects } from "@app/ee/services/permission/org-permission";
import {
@@ -204,13 +204,14 @@ export const identityGcpAuthServiceFactory = ({
throw new BadRequestError({ message: "Access token TTL cannot be greater than max TTL" });
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityMembershipOrg.scopeOrgId,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Create, OrgPermissionSubjects.Identity);
const plan = await licenseService.getPlan(identityMembershipOrg.scopeOrgId);
@@ -290,13 +291,14 @@ export const identityGcpAuthServiceFactory = ({
throw new BadRequestError({ message: "Access token TTL cannot be greater than max TTL" });
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityMembershipOrg.scopeOrgId,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Edit, OrgPermissionSubjects.Identity);
const plan = await licenseService.getPlan(identityMembershipOrg.scopeOrgId);
@@ -354,13 +356,14 @@ export const identityGcpAuthServiceFactory = ({
const identityGcpAuth = await identityGcpAuthDAL.findOne({ identityId });
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityMembershipOrg.scopeOrgId,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Read, OrgPermissionSubjects.Identity);
return { ...identityGcpAuth, orgId: identityMembershipOrg.scopeOrgId };
@@ -387,22 +390,24 @@ export const identityGcpAuthServiceFactory = ({
message: "The identity does not have gcp auth"
});
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityMembershipOrg.scopeOrgId,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Edit, OrgPermissionSubjects.Identity);
- const { permission: rolePermission } = await permissionService.getOrgPermission(
- ActorType.IDENTITY,
- identityMembershipOrg.identity.id,
- identityMembershipOrg.scopeOrgId,
+ const { permission: rolePermission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
+ actor: ActorType.IDENTITY,
+ actorId: identityMembershipOrg.identity.id,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
const { shouldUseNewPrivilegeSystem } = await orgDAL.findById(identityMembershipOrg.scopeOrgId);
const permissionBoundary = validatePrivilegeChangeOperation(
shouldUseNewPrivilegeSystem,
diff --git a/backend/src/services/identity-jwt-auth/identity-jwt-auth-service.ts b/backend/src/services/identity-jwt-auth/identity-jwt-auth-service.ts
index a99c8ad78d..b506552865 100644
--- a/backend/src/services/identity-jwt-auth/identity-jwt-auth-service.ts
+++ b/backend/src/services/identity-jwt-auth/identity-jwt-auth-service.ts
@@ -3,7 +3,7 @@ import https from "https";
import jwt from "jsonwebtoken";
import { JwksClient } from "jwks-rsa";
-import { AccessScope, IdentityAuthMethod, TIdentityJwtAuthsUpdate } from "@app/db/schemas";
+import { AccessScope, IdentityAuthMethod, OrganizationActionScope, TIdentityJwtAuthsUpdate } from "@app/db/schemas";
import { TLicenseServiceFactory } from "@app/ee/services/license/license-service";
import { OrgPermissionIdentityActions, OrgPermissionSubjects } from "@app/ee/services/permission/org-permission";
import {
@@ -294,13 +294,14 @@ export const identityJwtAuthServiceFactory = ({
throw new BadRequestError({ message: "Access token TTL cannot be greater than max TTL" });
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityMembershipOrg.scopeOrgId,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Create, OrgPermissionSubjects.Identity);
@@ -403,13 +404,14 @@ export const identityJwtAuthServiceFactory = ({
throw new BadRequestError({ message: "Access token TTL cannot be greater than max TTL" });
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityMembershipOrg.scopeOrgId,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Edit, OrgPermissionSubjects.Identity);
@@ -498,13 +500,14 @@ export const identityJwtAuthServiceFactory = ({
});
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityMembershipOrg.scopeOrgId,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Read, OrgPermissionSubjects.Identity);
@@ -546,23 +549,25 @@ export const identityJwtAuthServiceFactory = ({
});
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityMembershipOrg.scopeOrgId,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Edit, OrgPermissionSubjects.Identity);
- const { permission: rolePermission } = await permissionService.getOrgPermission(
- ActorType.IDENTITY,
- identityMembershipOrg.identity.id,
- identityMembershipOrg.scopeOrgId,
+ const { permission: rolePermission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
+ actor: ActorType.IDENTITY,
+ actorId: identityMembershipOrg.identity.id,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
const { shouldUseNewPrivilegeSystem } = await orgDAL.findById(identityMembershipOrg.scopeOrgId);
const permissionBoundary = validatePrivilegeChangeOperation(
diff --git a/backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-service.ts b/backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-service.ts
index 952b1e31de..d2eefcda12 100644
--- a/backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-service.ts
+++ b/backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-service.ts
@@ -3,7 +3,12 @@ import axios, { AxiosError } from "axios";
import https from "https";
import RE2 from "re2";
-import { AccessScope, IdentityAuthMethod, TIdentityKubernetesAuthsUpdate } from "@app/db/schemas";
+import {
+ AccessScope,
+ IdentityAuthMethod,
+ OrganizationActionScope,
+ TIdentityKubernetesAuthsUpdate
+} from "@app/db/schemas";
import { TGatewayDALFactory } from "@app/ee/services/gateway/gateway-dal";
import { TGatewayServiceFactory } from "@app/ee/services/gateway/gateway-service";
import { TGatewayV2DALFactory } from "@app/ee/services/gateway-v2/gateway-v2-dal";
@@ -519,13 +524,14 @@ export const identityKubernetesAuthServiceFactory = ({
throw new BadRequestError({ message: "Access token TTL cannot be greater than max TTL" });
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityMembershipOrg.scopeOrgId,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Create, OrgPermissionSubjects.Identity);
const plan = await licenseService.getPlan(identityMembershipOrg.scopeOrgId);
@@ -560,13 +566,14 @@ export const identityKubernetesAuthServiceFactory = ({
isGatewayV1 = false;
}
- const { permission: orgPermission } = await permissionService.getOrgPermission(
+ const { permission: orgPermission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityMembershipOrg.scopeOrgId,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(orgPermission).throwUnlessCan(
OrgPermissionGatewayActions.AttachGateways,
OrgPermissionSubjects.Gateway
@@ -650,13 +657,14 @@ export const identityKubernetesAuthServiceFactory = ({
throw new BadRequestError({ message: "Access token TTL cannot be greater than max TTL" });
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityMembershipOrg.scopeOrgId,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Edit, OrgPermissionSubjects.Identity);
const plan = await licenseService.getPlan(identityMembershipOrg.scopeOrgId);
@@ -692,13 +700,14 @@ export const identityKubernetesAuthServiceFactory = ({
isGatewayV1 = false;
}
- const { permission: orgPermission } = await permissionService.getOrgPermission(
+ const { permission: orgPermission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityMembershipOrg.scopeOrgId,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(orgPermission).throwUnlessCan(
OrgPermissionGatewayActions.AttachGateways,
OrgPermissionSubjects.Gateway
@@ -791,13 +800,14 @@ export const identityKubernetesAuthServiceFactory = ({
});
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityMembershipOrg.scopeOrgId,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Read, OrgPermissionSubjects.Identity);
const { decryptor } = await kmsService.createCipherPairWithDataKey({
@@ -847,22 +857,24 @@ export const identityKubernetesAuthServiceFactory = ({
message: "The identity does not have kubernetes auth"
});
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityMembershipOrg.scopeOrgId,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Edit, OrgPermissionSubjects.Identity);
- const { permission: rolePermission } = await permissionService.getOrgPermission(
- ActorType.IDENTITY,
- identityMembershipOrg.identity.id,
- identityMembershipOrg.scopeOrgId,
+ const { permission: rolePermission } = await permissionService.getOrgPermission({
+ actor: ActorType.IDENTITY,
+ actorId: identityMembershipOrg.identity.id,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
- actorOrgId
- );
+ actorOrgId,
+ scope: OrganizationActionScope.Any
+ });
const { shouldUseNewPrivilegeSystem } = await orgDAL.findById(identityMembershipOrg.scopeOrgId);
const permissionBoundary = validatePrivilegeChangeOperation(
shouldUseNewPrivilegeSystem,
diff --git a/backend/src/services/identity-ldap-auth/identity-ldap-auth-service.ts b/backend/src/services/identity-ldap-auth/identity-ldap-auth-service.ts
index 1a8ea3ed6f..f925ff245b 100644
--- a/backend/src/services/identity-ldap-auth/identity-ldap-auth-service.ts
+++ b/backend/src/services/identity-ldap-auth/identity-ldap-auth-service.ts
@@ -2,7 +2,7 @@
import { ForbiddenError } from "@casl/ability";
import slugify from "@sindresorhus/slugify";
-import { AccessScope, IdentityAuthMethod } from "@app/db/schemas";
+import { AccessScope, IdentityAuthMethod, OrganizationActionScope } from "@app/db/schemas";
import { TIdentityAuthTemplateDALFactory } from "@app/ee/services/identity-auth-template";
import { testLDAPConfig } from "@app/ee/services/ldap-config/ldap-fns";
import { TLicenseServiceFactory } from "@app/ee/services/license/license-service";
@@ -265,13 +265,14 @@ export const identityLdapAuthServiceFactory = ({
throw new BadRequestError({ message: "Access token TTL cannot be greater than max TTL" });
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityMembershipOrg.scopeOrgId,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Create, OrgPermissionSubjects.Identity);
if (templateId) {
@@ -441,13 +442,14 @@ export const identityLdapAuthServiceFactory = ({
throw new BadRequestError({ message: "Access token TTL cannot be greater than max TTL" });
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityMembershipOrg.scopeOrgId,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Edit, OrgPermissionSubjects.Identity);
if (templateId) {
@@ -597,13 +599,14 @@ export const identityLdapAuthServiceFactory = ({
const ldapIdentityAuth = await identityLdapAuthDAL.findOne({ identityId });
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityMembershipOrg.scopeOrgId,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
const { decryptor } = await kmsService.createCipherPairWithDataKey({
type: KmsDataKey.Organization,
@@ -640,22 +643,24 @@ export const identityLdapAuthServiceFactory = ({
message: "The identity does not have LDAP Auth attached"
});
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityMembershipOrg.scopeOrgId,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Edit, OrgPermissionSubjects.Identity);
- const { permission: rolePermission } = await permissionService.getOrgPermission(
- ActorType.IDENTITY,
- identityMembershipOrg.identity.id,
- identityMembershipOrg.scopeOrgId,
+ const { permission: rolePermission } = await permissionService.getOrgPermission({
+ actor: ActorType.IDENTITY,
+ actorId: identityMembershipOrg.identity.id,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
- actorOrgId
- );
+ actorOrgId,
+ scope: OrganizationActionScope.Any
+ });
const { shouldUseNewPrivilegeSystem } = await orgDAL.findById(identityMembershipOrg.scopeOrgId);
const permissionBoundary = validatePrivilegeChangeOperation(
@@ -785,13 +790,14 @@ export const identityLdapAuthServiceFactory = ({
});
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityMembershipOrg.scopeOrgId,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Edit, OrgPermissionSubjects.Identity);
const deleted = await keyStore.deleteItems({
diff --git a/backend/src/services/identity-oci-auth/identity-oci-auth-service.ts b/backend/src/services/identity-oci-auth/identity-oci-auth-service.ts
index bfac3d1589..b8991477df 100644
--- a/backend/src/services/identity-oci-auth/identity-oci-auth-service.ts
+++ b/backend/src/services/identity-oci-auth/identity-oci-auth-service.ts
@@ -3,7 +3,7 @@ import { ForbiddenError } from "@casl/ability";
import { AxiosError } from "axios";
import RE2 from "re2";
-import { AccessScope, IdentityAuthMethod } from "@app/db/schemas";
+import { AccessScope, IdentityAuthMethod, OrganizationActionScope } from "@app/db/schemas";
import { TLicenseServiceFactory } from "@app/ee/services/license/license-service";
import { OrgPermissionIdentityActions, OrgPermissionSubjects } from "@app/ee/services/permission/org-permission";
import {
@@ -179,13 +179,14 @@ export const identityOciAuthServiceFactory = ({
throw new BadRequestError({ message: "Access token TTL cannot be greater than max TTL" });
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityMembershipOrg.scopeOrgId,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Create, OrgPermissionSubjects.Identity);
const plan = await licenseService.getPlan(identityMembershipOrg.scopeOrgId);
@@ -262,13 +263,14 @@ export const identityOciAuthServiceFactory = ({
throw new BadRequestError({ message: "Access token TTL cannot be greater than max TTL" });
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityMembershipOrg.scopeOrgId,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Edit, OrgPermissionSubjects.Identity);
const plan = await licenseService.getPlan(identityMembershipOrg.scopeOrgId);
@@ -321,13 +323,14 @@ export const identityOciAuthServiceFactory = ({
const ociIdentityAuth = await identityOciAuthDAL.findOne({ identityId });
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityMembershipOrg.scopeOrgId,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Read, OrgPermissionSubjects.Identity);
return { ...ociIdentityAuth, orgId: identityMembershipOrg.scopeOrgId };
};
@@ -352,22 +355,24 @@ export const identityOciAuthServiceFactory = ({
message: "The identity does not have OCI auth"
});
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityMembershipOrg.scopeOrgId,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Edit, OrgPermissionSubjects.Identity);
- const { permission: rolePermission } = await permissionService.getOrgPermission(
- ActorType.IDENTITY,
- identityMembershipOrg.identity.id,
- identityMembershipOrg.scopeOrgId,
+ const { permission: rolePermission } = await permissionService.getOrgPermission({
+ actor: ActorType.IDENTITY,
+ actorId: identityMembershipOrg.identity.id,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
- actorOrgId
- );
+ actorOrgId,
+ scope: OrganizationActionScope.Any
+ });
const { shouldUseNewPrivilegeSystem } = await orgDAL.findById(actorOrgId);
const permissionBoundary = validatePrivilegeChangeOperation(
diff --git a/backend/src/services/identity-oidc-auth/identity-oidc-auth-service.ts b/backend/src/services/identity-oidc-auth/identity-oidc-auth-service.ts
index 1218d8e1cd..9372c940c7 100644
--- a/backend/src/services/identity-oidc-auth/identity-oidc-auth-service.ts
+++ b/backend/src/services/identity-oidc-auth/identity-oidc-auth-service.ts
@@ -4,7 +4,7 @@ import https from "https";
import jwt from "jsonwebtoken";
import { JwksClient } from "jwks-rsa";
-import { AccessScope, IdentityAuthMethod, TIdentityOidcAuthsUpdate } from "@app/db/schemas";
+import { AccessScope, IdentityAuthMethod, OrganizationActionScope, TIdentityOidcAuthsUpdate } from "@app/db/schemas";
import { TLicenseServiceFactory } from "@app/ee/services/license/license-service";
import { OrgPermissionIdentityActions, OrgPermissionSubjects } from "@app/ee/services/permission/org-permission";
import {
@@ -269,13 +269,14 @@ export const identityOidcAuthServiceFactory = ({
throw new BadRequestError({ message: "Access token TTL cannot be greater than max TTL" });
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityMembershipOrg.scopeOrgId,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Create, OrgPermissionSubjects.Identity);
@@ -367,13 +368,14 @@ export const identityOidcAuthServiceFactory = ({
throw new BadRequestError({ message: "Access token TTL cannot be greater than max TTL" });
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityMembershipOrg.scopeOrgId,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Edit, OrgPermissionSubjects.Identity);
@@ -447,13 +449,14 @@ export const identityOidcAuthServiceFactory = ({
});
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityMembershipOrg.scopeOrgId,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Read, OrgPermissionSubjects.Identity);
const identityOidcAuth = await identityOidcAuthDAL.findOne({ identityId });
@@ -488,23 +491,25 @@ export const identityOidcAuthServiceFactory = ({
});
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityMembershipOrg.scopeOrgId,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Edit, OrgPermissionSubjects.Identity);
- const { permission: rolePermission } = await permissionService.getOrgPermission(
- ActorType.IDENTITY,
- identityMembershipOrg.identity.id,
- identityMembershipOrg.scopeOrgId,
+ const { permission: rolePermission } = await permissionService.getOrgPermission({
+ actor: ActorType.IDENTITY,
+ actorId: identityMembershipOrg.identity.id,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
- actorOrgId
- );
+ actorOrgId,
+ scope: OrganizationActionScope.Any
+ });
const { shouldUseNewPrivilegeSystem } = await orgDAL.findById(identityMembershipOrg.scopeOrgId);
const permissionBoundary = validatePrivilegeChangeOperation(
diff --git a/backend/src/services/identity-tls-cert-auth/identity-tls-cert-auth-service.ts b/backend/src/services/identity-tls-cert-auth/identity-tls-cert-auth-service.ts
index 625b9b328c..9d59ababf9 100644
--- a/backend/src/services/identity-tls-cert-auth/identity-tls-cert-auth-service.ts
+++ b/backend/src/services/identity-tls-cert-auth/identity-tls-cert-auth-service.ts
@@ -1,6 +1,6 @@
import { ForbiddenError } from "@casl/ability";
-import { AccessScope, IdentityAuthMethod } from "@app/db/schemas";
+import { AccessScope, IdentityAuthMethod, OrganizationActionScope } from "@app/db/schemas";
import { TLicenseServiceFactory } from "@app/ee/services/license/license-service";
import { OrgPermissionIdentityActions, OrgPermissionSubjects } from "@app/ee/services/permission/org-permission";
import {
@@ -200,13 +200,14 @@ export const identityTlsCertAuthServiceFactory = ({
throw new BadRequestError({ message: "Access token TTL cannot be greater than max TTL" });
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityMembershipOrg.scopeOrgId,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Create, OrgPermissionSubjects.Identity);
const plan = await licenseService.getPlan(identityMembershipOrg.scopeOrgId);
@@ -288,13 +289,14 @@ export const identityTlsCertAuthServiceFactory = ({
throw new BadRequestError({ message: "Access token TTL cannot be greater than max TTL" });
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityMembershipOrg.scopeOrgId,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Edit, OrgPermissionSubjects.Identity);
const plan = await licenseService.getPlan(identityMembershipOrg.scopeOrgId);
@@ -359,13 +361,14 @@ export const identityTlsCertAuthServiceFactory = ({
const identityAuth = await identityTlsCertAuthDAL.findOne({ identityId });
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityMembershipOrg.scopeOrgId,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Read, OrgPermissionSubjects.Identity);
const { decryptor } = await kmsService.createCipherPairWithDataKey({
type: KmsDataKey.Organization,
@@ -399,23 +402,24 @@ export const identityTlsCertAuthServiceFactory = ({
message: "The identity does not have TLS Certificate auth"
});
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityMembershipOrg.scopeOrgId,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Edit, OrgPermissionSubjects.Identity);
- const { permission: rolePermission, memberships } = await permissionService.getOrgPermission(
- ActorType.IDENTITY,
- identityMembershipOrg.identity.id,
- identityMembershipOrg.scopeOrgId,
+ const { permission: rolePermission, memberships } = await permissionService.getOrgPermission({
+ actor: ActorType.IDENTITY,
+ actorId: identityMembershipOrg.identity.id,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
- actorOrgId
- );
-
+ actorOrgId,
+ scope: OrganizationActionScope.Any
+ });
const shouldUseNewPrivilegeSystem = Boolean(memberships?.[0]?.shouldUseNewPrivilegeSystem);
const permissionBoundary = validatePrivilegeChangeOperation(
shouldUseNewPrivilegeSystem,
diff --git a/backend/src/services/identity-token-auth/identity-token-auth-service.ts b/backend/src/services/identity-token-auth/identity-token-auth-service.ts
index 2ae05cb972..87ae18fd54 100644
--- a/backend/src/services/identity-token-auth/identity-token-auth-service.ts
+++ b/backend/src/services/identity-token-auth/identity-token-auth-service.ts
@@ -1,6 +1,6 @@
import { ForbiddenError } from "@casl/ability";
-import { AccessScope, IdentityAuthMethod, TableName } from "@app/db/schemas";
+import { AccessScope, IdentityAuthMethod, OrganizationActionScope, TableName } from "@app/db/schemas";
import { TLicenseServiceFactory } from "@app/ee/services/license/license-service";
import { OrgPermissionIdentityActions, OrgPermissionSubjects } from "@app/ee/services/permission/org-permission";
import {
@@ -90,13 +90,14 @@ export const identityTokenAuthServiceFactory = ({
throw new BadRequestError({ message: "Access token TTL cannot be greater than max TTL" });
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityMembershipOrg.scopeOrgId,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Create, OrgPermissionSubjects.Identity);
const plan = await licenseService.getPlan(identityMembershipOrg.scopeOrgId);
@@ -172,13 +173,14 @@ export const identityTokenAuthServiceFactory = ({
throw new BadRequestError({ message: "Access token TTL cannot be greater than max TTL" });
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityMembershipOrg.scopeOrgId,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Edit, OrgPermissionSubjects.Identity);
const plan = await licenseService.getPlan(identityMembershipOrg.scopeOrgId);
@@ -232,13 +234,14 @@ export const identityTokenAuthServiceFactory = ({
const identityTokenAuth = await identityTokenAuthDAL.findOne({ identityId });
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityMembershipOrg.scopeOrgId,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Read, OrgPermissionSubjects.Identity);
return { ...identityTokenAuth, orgId: identityMembershipOrg.scopeOrgId };
@@ -268,22 +271,24 @@ export const identityTokenAuthServiceFactory = ({
message: "The identity does not have Token Auth"
});
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityMembershipOrg.scopeOrgId,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Edit, OrgPermissionSubjects.Identity);
- const { permission: rolePermission } = await permissionService.getOrgPermission(
- ActorType.IDENTITY,
- identityMembershipOrg.identity.id,
- identityMembershipOrg.scopeOrgId,
+ const { permission: rolePermission } = await permissionService.getOrgPermission({
+ actor: ActorType.IDENTITY,
+ actorId: identityMembershipOrg.identity.id,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
- actorOrgId
- );
+ actorOrgId,
+ scope: OrganizationActionScope.Any
+ });
const { shouldUseNewPrivilegeSystem } = await orgDAL.findById(identityMembershipOrg.scopeOrgId);
const permissionBoundary = validatePrivilegeChangeOperation(
@@ -341,22 +346,26 @@ export const identityTokenAuthServiceFactory = ({
message: "The identity does not have Token Auth"
});
}
- const { permission } = await permissionService.getOrgPermission(
+
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityMembershipOrg.scopeOrgId,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
+
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Edit, OrgPermissionSubjects.Identity);
- const { permission: rolePermission } = await permissionService.getOrgPermission(
- ActorType.IDENTITY,
- identityMembershipOrg.identity.id,
- identityMembershipOrg.scopeOrgId,
+ const { permission: rolePermission } = await permissionService.getOrgPermission({
+ actor: ActorType.IDENTITY,
+ actorId: identityMembershipOrg.identity.id,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
- actorOrgId
- );
+ actorOrgId,
+ scope: OrganizationActionScope.Any
+ });
const { shouldUseNewPrivilegeSystem } = await orgDAL.findById(identityMembershipOrg.scopeOrgId);
const permissionBoundary = validatePrivilegeChangeOperation(
@@ -449,13 +458,14 @@ export const identityTokenAuthServiceFactory = ({
message: "The identity does not have Token Auth"
});
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityMembershipOrg.scopeOrgId,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Read, OrgPermissionSubjects.Identity);
const tokens = await identityAccessTokenDAL.find(
@@ -501,22 +511,24 @@ export const identityTokenAuthServiceFactory = ({
message: "The identity does not have Token Auth"
});
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityMembershipOrg.scopeOrgId,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Edit, OrgPermissionSubjects.Identity);
- const { permission: rolePermission } = await permissionService.getOrgPermission(
- ActorType.IDENTITY,
- identityMembershipOrg.identity.id,
- identityMembershipOrg.scopeOrgId,
+ const { permission: rolePermission } = await permissionService.getOrgPermission({
+ actor: ActorType.IDENTITY,
+ actorId: identityMembershipOrg.identity.id,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
- actorOrgId
- );
+ actorOrgId,
+ scope: OrganizationActionScope.Any
+ });
const { shouldUseNewPrivilegeSystem } = await orgDAL.findById(identityMembershipOrg.scopeOrgId);
const permissionBoundary = validatePrivilegeChangeOperation(
shouldUseNewPrivilegeSystem,
@@ -580,13 +592,14 @@ export const identityTokenAuthServiceFactory = ({
throw new NotFoundError({ message: `Failed to find identity with ID ${identityAccessToken.identityId}` });
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityOrgMembership.scopeOrgId,
+ orgId: identityOrgMembership.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Edit, OrgPermissionSubjects.Identity);
const [revokedToken] = await identityAccessTokenDAL.update(
diff --git a/backend/src/services/identity-ua/identity-ua-service.ts b/backend/src/services/identity-ua/identity-ua-service.ts
index 563a3f897d..f63c8a6e50 100644
--- a/backend/src/services/identity-ua/identity-ua-service.ts
+++ b/backend/src/services/identity-ua/identity-ua-service.ts
@@ -1,6 +1,6 @@
import { ForbiddenError } from "@casl/ability";
-import { AccessScope, IdentityAuthMethod } from "@app/db/schemas";
+import { AccessScope, IdentityAuthMethod, OrganizationActionScope } from "@app/db/schemas";
import { TLicenseServiceFactory } from "@app/ee/services/license/license-service";
import { OrgPermissionIdentityActions, OrgPermissionSubjects } from "@app/ee/services/permission/org-permission";
import {
@@ -320,13 +320,15 @@ export const identityUaServiceFactory = ({
throw new BadRequestError({ message: "Access token TTL cannot be greater than max TTL" });
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityMembershipOrg.scopeOrgId,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
+
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Create, OrgPermissionSubjects.Identity);
const plan = await licenseService.getPlan(identityMembershipOrg.scopeOrgId);
@@ -430,13 +432,14 @@ export const identityUaServiceFactory = ({
throw new BadRequestError({ message: "Access token TTL cannot be greater than max TTL" });
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityMembershipOrg.scopeOrgId,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Edit, OrgPermissionSubjects.Identity);
const plan = await licenseService.getPlan(identityMembershipOrg.scopeOrgId);
@@ -513,13 +516,14 @@ export const identityUaServiceFactory = ({
});
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityMembershipOrg.scopeOrgId,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Read, OrgPermissionSubjects.Identity);
return { ...uaIdentityAuth, orgId: identityMembershipOrg.scopeOrgId };
};
@@ -545,22 +549,24 @@ export const identityUaServiceFactory = ({
message: "The identity does not have universal auth"
});
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityMembershipOrg.scopeOrgId,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Edit, OrgPermissionSubjects.Identity);
- const { permission: rolePermission } = await permissionService.getOrgPermission(
- ActorType.IDENTITY,
- identityMembershipOrg.identity.id,
- identityMembershipOrg.scopeOrgId,
+ const { permission: rolePermission } = await permissionService.getOrgPermission({
+ actor: ActorType.IDENTITY,
+ actorId: identityMembershipOrg.identity.id,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
- actorOrgId
- );
+ actorOrgId,
+ scope: OrganizationActionScope.Any
+ });
const { shouldUseNewPrivilegeSystem } = await orgDAL.findById(identityMembershipOrg.scopeOrgId);
const permissionBoundary = validatePrivilegeChangeOperation(
shouldUseNewPrivilegeSystem,
@@ -612,22 +618,24 @@ export const identityUaServiceFactory = ({
});
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityMembershipOrg.scopeOrgId,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Create, OrgPermissionSubjects.Identity);
- const { permission: rolePermission } = await permissionService.getOrgPermission(
- ActorType.IDENTITY,
- identityMembershipOrg.identity.id,
- identityMembershipOrg.scopeOrgId,
+ const { permission: rolePermission } = await permissionService.getOrgPermission({
+ actor: ActorType.IDENTITY,
+ actorId: identityMembershipOrg.identity.id,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
- actorOrgId
- );
+ actorOrgId,
+ scope: OrganizationActionScope.Any
+ });
const { shouldUseNewPrivilegeSystem } = await orgDAL.findById(identityMembershipOrg.scopeOrgId);
const permissionBoundary = validatePrivilegeChangeOperation(
shouldUseNewPrivilegeSystem,
@@ -692,23 +700,24 @@ export const identityUaServiceFactory = ({
message: "The identity does not have universal auth"
});
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityMembershipOrg.scopeOrgId,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Read, OrgPermissionSubjects.Identity);
- const { permission: rolePermission } = await permissionService.getOrgPermission(
- ActorType.IDENTITY,
- identityMembershipOrg.identity.id,
- identityMembershipOrg.scopeOrgId,
+ const { permission: rolePermission } = await permissionService.getOrgPermission({
+ actor: ActorType.IDENTITY,
+ actorId: identityMembershipOrg.identity.id,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
- actorOrgId
- );
-
+ actorOrgId,
+ scope: OrganizationActionScope.Any
+ });
const { shouldUseNewPrivilegeSystem } = await orgDAL.findById(identityMembershipOrg.scopeOrgId);
const permissionBoundary = validatePrivilegeChangeOperation(
shouldUseNewPrivilegeSystem,
@@ -768,22 +777,24 @@ export const identityUaServiceFactory = ({
const clientSecret = await identityUaClientSecretDAL.findOne({ id: clientSecretId, identityUAId: identityUa.id });
if (!clientSecret) throw new NotFoundError({ message: `Failed to find identity with ID ${identityId}` });
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityMembershipOrg.scopeOrgId,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Read, OrgPermissionSubjects.Identity);
- const { permission: rolePermission } = await permissionService.getOrgPermission(
- ActorType.IDENTITY,
- identityMembershipOrg.identity.id,
- identityMembershipOrg.scopeOrgId,
+ const { permission: rolePermission } = await permissionService.getOrgPermission({
+ actor: ActorType.IDENTITY,
+ actorId: identityMembershipOrg.identity.id,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
- actorOrgId
- );
+ actorOrgId,
+ scope: OrganizationActionScope.Any
+ });
const { shouldUseNewPrivilegeSystem } = await orgDAL.findById(identityMembershipOrg.scopeOrgId);
const permissionBoundary = validatePrivilegeChangeOperation(
shouldUseNewPrivilegeSystem,
@@ -835,22 +846,24 @@ export const identityUaServiceFactory = ({
const clientSecret = await identityUaClientSecretDAL.findOne({ id: clientSecretId, identityUAId: identityUa.id });
if (!clientSecret) throw new NotFoundError({ message: `Failed to find identity with ID ${identityId}` });
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityMembershipOrg.scopeOrgId,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Delete, OrgPermissionSubjects.Identity);
- const { permission: rolePermission } = await permissionService.getOrgPermission(
- ActorType.IDENTITY,
- identityMembershipOrg.identity.id,
- identityMembershipOrg.scopeOrgId,
+ const { permission: rolePermission } = await permissionService.getOrgPermission({
+ actor: ActorType.IDENTITY,
+ actorId: identityMembershipOrg.identity.id,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
- actorOrgId
- );
+ actorOrgId,
+ scope: OrganizationActionScope.Any
+ });
const { shouldUseNewPrivilegeSystem } = await orgDAL.findById(identityMembershipOrg.scopeOrgId);
const permissionBoundary = validatePrivilegeChangeOperation(
@@ -901,13 +914,14 @@ export const identityUaServiceFactory = ({
});
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityMembershipOrg.scopeOrgId,
+ orgId: identityMembershipOrg.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Edit, OrgPermissionSubjects.Identity);
const deleted = await keyStore.deleteItems({
diff --git a/backend/src/services/identity/identity-service.ts b/backend/src/services/identity/identity-service.ts
index 721844070c..e83f2f3698 100644
--- a/backend/src/services/identity/identity-service.ts
+++ b/backend/src/services/identity/identity-service.ts
@@ -1,6 +1,6 @@
import { ForbiddenError } from "@casl/ability";
-import { AccessScope, OrgMembershipRole, TableName, TRoles } from "@app/db/schemas";
+import { AccessScope, OrganizationActionScope, OrgMembershipRole, TableName, TRoles } from "@app/db/schemas";
import { TLicenseServiceFactory } from "@app/ee/services/license/license-service";
import { OrgPermissionIdentityActions, OrgPermissionSubjects } from "@app/ee/services/permission/org-permission";
import {
@@ -67,7 +67,14 @@ export const identityServiceFactory = ({
actorOrgId,
metadata
}: TCreateIdentityDTO) => {
- const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorAuthMethod, actorOrgId);
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
+ actor,
+ actorId,
+ orgId,
+ actorAuthMethod,
+ actorOrgId
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Create, OrgPermissionSubjects.Identity);
const [rolePermissionDetails] = await permissionService.getOrgPermissionByRoles([role], orgId);
@@ -104,7 +111,7 @@ export const identityServiceFactory = ({
}
const identity = await identityDAL.transaction(async (tx) => {
- const newIdentity = await identityDAL.create({ name, hasDeleteProtection }, tx);
+ const newIdentity = await identityDAL.create({ name, hasDeleteProtection, orgId }, tx);
const membership = await membershipIdentityDAL.create(
{
scope: AccessScope.Organization,
@@ -172,13 +179,14 @@ export const identityServiceFactory = ({
});
if (!identityOrgMembership) throw new NotFoundError({ message: `Failed to find identity with id ${id}` });
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityOrgMembership.scopeOrgId,
+ orgId: identityOrgMembership.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Edit, OrgPermissionSubjects.Identity);
let customRole: TRoles | undefined;
@@ -264,13 +272,14 @@ export const identityServiceFactory = ({
const identity = doc[0];
if (!identity) throw new NotFoundError({ message: `Failed to find identity with id ${id}` });
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identity.orgId,
+ orgId: identity.orgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Read, OrgPermissionSubjects.Identity);
// TODO(namespace): check this in identity service
@@ -314,13 +323,14 @@ export const identityServiceFactory = ({
});
if (!identityOrgMembership) throw new NotFoundError({ message: `Failed to find identity with id ${id}` });
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityOrgMembership.scopeOrgId,
+ orgId: identityOrgMembership.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Delete, OrgPermissionSubjects.Identity);
@@ -346,7 +356,14 @@ export const identityServiceFactory = ({
orderDirection,
search
}: TListOrgIdentitiesByOrgIdDTO) => {
- const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorAuthMethod, actorOrgId);
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
+ actor,
+ actorId,
+ orgId: actorOrgId,
+ actorAuthMethod,
+ actorOrgId
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Read, OrgPermissionSubjects.Identity);
const identityMemberships = await identityOrgMembershipDAL.find({
@@ -379,7 +396,14 @@ export const identityServiceFactory = ({
orderDirection,
searchFilter = {}
}: TSearchOrgIdentitiesByOrgIdDTO) => {
- const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorAuthMethod, actorOrgId);
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
+ actor,
+ actorId,
+ orgId: actorOrgId,
+ actorAuthMethod,
+ actorOrgId
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Read, OrgPermissionSubjects.Identity);
const { totalCount, docs } = await identityOrgMembershipDAL.searchIdentities({
@@ -408,13 +432,14 @@ export const identityServiceFactory = ({
});
if (!identityOrgMembership) throw new NotFoundError({ message: `Failed to find identity with id ${identityId}` });
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- identityOrgMembership.scopeOrgId,
+ orgId: identityOrgMembership.scopeOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Read, OrgPermissionSubjects.Identity);
const identityMemberships = await identityProjectDAL.findByIdentityId(identityId);
diff --git a/backend/src/services/membership-group/org/org-membership-group-factory.ts b/backend/src/services/membership-group/org/org-membership-group-factory.ts
index 1e87ee3ca1..d69db9c082 100644
--- a/backend/src/services/membership-group/org/org-membership-group-factory.ts
+++ b/backend/src/services/membership-group/org/org-membership-group-factory.ts
@@ -1,6 +1,6 @@
import { ForbiddenError } from "@casl/ability";
-import { AccessScope, OrgMembershipRole } from "@app/db/schemas";
+import { AccessScope, OrganizationActionScope, OrgMembershipRole } from "@app/db/schemas";
import { OrgPermissionGroupActions, OrgPermissionSubjects } from "@app/ee/services/permission/org-permission";
import {
constructPermissionErrorMessage,
@@ -45,13 +45,14 @@ export const newOrgMembershipGroupFactory = ({
};
const onUpdateMembershipGroupGuard: TMembershipGroupScopeFactory["onUpdateMembershipGroupGuard"] = async (dto) => {
- const { permission } = await permissionService.getOrgPermission(
- dto.permission.type,
- dto.permission.id,
- dto.permission.orgId,
- dto.permission.authMethod,
- dto.permission.orgId
- );
+ const { permission } = await permissionService.getOrgPermission({
+ actor: dto.permission.type,
+ actorId: dto.permission.id,
+ orgId: dto.permission.orgId,
+ actorAuthMethod: dto.permission.authMethod,
+ actorOrgId: dto.permission.orgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionGroupActions.Edit, OrgPermissionSubjects.Groups);
const permissionRoles = await permissionService.getOrgPermissionByRoles(
dto.data.roles.map((el) => el.role),
@@ -89,26 +90,28 @@ export const newOrgMembershipGroupFactory = ({
};
const onListMembershipGroupGuard: TMembershipGroupScopeFactory["onListMembershipGroupGuard"] = async (dto) => {
- const { permission } = await permissionService.getOrgPermission(
- dto.permission.type,
- dto.permission.id,
- dto.permission.orgId,
- dto.permission.authMethod,
- dto.permission.orgId
- );
+ const { permission } = await permissionService.getOrgPermission({
+ actor: dto.permission.type,
+ actorId: dto.permission.id,
+ orgId: dto.permission.orgId,
+ actorAuthMethod: dto.permission.authMethod,
+ actorOrgId: dto.permission.orgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionGroupActions.Read, OrgPermissionSubjects.Groups);
};
const onGetMembershipGroupByGroupIdGuard: TMembershipGroupScopeFactory["onGetMembershipGroupByGroupIdGuard"] = async (
dto
) => {
- const { permission } = await permissionService.getOrgPermission(
- dto.permission.type,
- dto.permission.id,
- dto.permission.orgId,
- dto.permission.authMethod,
- dto.permission.orgId
- );
+ const { permission } = await permissionService.getOrgPermission({
+ actor: dto.permission.type,
+ actorId: dto.permission.id,
+ orgId: dto.permission.orgId,
+ actorAuthMethod: dto.permission.authMethod,
+ actorOrgId: dto.permission.orgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionGroupActions.Read, OrgPermissionSubjects.Groups);
};
diff --git a/backend/src/services/membership-identity/org/org-membership-identity-factory.ts b/backend/src/services/membership-identity/org/org-membership-identity-factory.ts
index 06789e274a..fce31b0fe9 100644
--- a/backend/src/services/membership-identity/org/org-membership-identity-factory.ts
+++ b/backend/src/services/membership-identity/org/org-membership-identity-factory.ts
@@ -1,6 +1,6 @@
import { ForbiddenError } from "@casl/ability";
-import { AccessScope, OrgMembershipRole } from "@app/db/schemas";
+import { AccessScope, OrganizationActionScope, OrgMembershipRole } from "@app/db/schemas";
import { OrgPermissionIdentityActions, OrgPermissionSubjects } from "@app/ee/services/permission/org-permission";
import {
constructPermissionErrorMessage,
@@ -48,13 +48,15 @@ export const newOrgMembershipIdentityFactory = ({
const onUpdateMembershipIdentityGuard: TMembershipIdentityScopeFactory["onUpdateMembershipIdentityGuard"] = async (
dto
) => {
- const { permission } = await permissionService.getOrgPermission(
- dto.permission.type,
- dto.permission.id,
- dto.permission.orgId,
- dto.permission.authMethod,
- dto.permission.orgId
- );
+ const { permission } = await permissionService.getOrgPermission({
+ actor: dto.permission.type,
+ actorId: dto.permission.id,
+ orgId: dto.permission.orgId,
+ actorAuthMethod: dto.permission.authMethod,
+ actorOrgId: dto.permission.orgId,
+ scope: OrganizationActionScope.Any
+ });
+
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Edit, OrgPermissionSubjects.Identity);
const permissionRoles = await permissionService.getOrgPermissionByRoles(
dto.data.roles.map((el) => el.role),
@@ -95,25 +97,27 @@ export const newOrgMembershipIdentityFactory = ({
const onListMembershipIdentityGuard: TMembershipIdentityScopeFactory["onListMembershipIdentityGuard"] = async (
dto
) => {
- const { permission } = await permissionService.getOrgPermission(
- dto.permission.type,
- dto.permission.id,
- dto.permission.orgId,
- dto.permission.authMethod,
- dto.permission.orgId
- );
+ const { permission } = await permissionService.getOrgPermission({
+ actor: dto.permission.type,
+ actorId: dto.permission.id,
+ orgId: dto.permission.orgId,
+ actorAuthMethod: dto.permission.authMethod,
+ actorOrgId: dto.permission.orgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Read, OrgPermissionSubjects.Identity);
};
const onGetMembershipIdentityByIdentityIdGuard: TMembershipIdentityScopeFactory["onGetMembershipIdentityByIdentityIdGuard"] =
async (dto) => {
- const { permission } = await permissionService.getOrgPermission(
- dto.permission.type,
- dto.permission.id,
- dto.permission.orgId,
- dto.permission.authMethod,
- dto.permission.orgId
- );
+ const { permission } = await permissionService.getOrgPermission({
+ actor: dto.permission.type,
+ actorId: dto.permission.id,
+ orgId: dto.permission.orgId,
+ actorAuthMethod: dto.permission.authMethod,
+ actorOrgId: dto.permission.orgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Read, OrgPermissionSubjects.Identity);
};
diff --git a/backend/src/services/membership-user/org/org-membership-user-factory.ts b/backend/src/services/membership-user/org/org-membership-user-factory.ts
index 523e85baeb..5caf77c2c1 100644
--- a/backend/src/services/membership-user/org/org-membership-user-factory.ts
+++ b/backend/src/services/membership-user/org/org-membership-user-factory.ts
@@ -1,6 +1,6 @@
import { ForbiddenError } from "@casl/ability";
-import { AccessScope } from "@app/db/schemas";
+import { AccessScope, OrganizationActionScope } from "@app/db/schemas";
import { TUserGroupMembershipDALFactory } from "@app/ee/services/group/user-group-membership-dal";
import { TLicenseServiceFactory } from "@app/ee/services/license/license-service";
import { OrgPermissionActions, OrgPermissionSubjects } from "@app/ee/services/permission/org-permission";
@@ -52,13 +52,14 @@ export const newOrgMembershipUserFactory = ({
const isCustomRole: TMembershipUserScopeFactory["isCustomRole"] = (role: string) => isCustomOrgRole(role);
const onCreateMembershipUserGuard: TMembershipUserScopeFactory["onCreateMembershipUserGuard"] = async (dto) => {
- const { permission } = await permissionService.getOrgPermission(
- dto.permission.type,
- dto.permission.id,
- dto.permission.orgId,
- dto.permission.authMethod,
- dto.permission.orgId
- );
+ const { permission } = await permissionService.getOrgPermission({
+ actor: dto.permission.type,
+ actorId: dto.permission.id,
+ orgId: dto.permission.orgId,
+ actorAuthMethod: dto.permission.authMethod,
+ actorOrgId: dto.permission.orgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Create, OrgPermissionSubjects.Member);
const plan = await licenseService.getPlan(dto.permission.orgId);
@@ -134,48 +135,52 @@ export const newOrgMembershipUserFactory = ({
};
const onUpdateMembershipUserGuard: TMembershipUserScopeFactory["onUpdateMembershipUserGuard"] = async (dto) => {
- const { permission } = await permissionService.getOrgPermission(
- dto.permission.type,
- dto.permission.id,
- dto.permission.orgId,
- dto.permission.authMethod,
- dto.permission.orgId
- );
+ const { permission } = await permissionService.getOrgPermission({
+ actor: dto.permission.type,
+ actorId: dto.permission.id,
+ orgId: dto.permission.orgId,
+ actorAuthMethod: dto.permission.authMethod,
+ actorOrgId: dto.permission.orgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Edit, OrgPermissionSubjects.Member);
};
const onDeleteMembershipUserGuard: TMembershipUserScopeFactory["onDeleteMembershipUserGuard"] = async (dto) => {
- const { permission } = await permissionService.getOrgPermission(
- dto.permission.type,
- dto.permission.id,
- dto.permission.orgId,
- dto.permission.authMethod,
- dto.permission.orgId
- );
+ const { permission } = await permissionService.getOrgPermission({
+ actor: dto.permission.type,
+ actorId: dto.permission.id,
+ orgId: dto.permission.orgId,
+ actorAuthMethod: dto.permission.authMethod,
+ actorOrgId: dto.permission.orgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Delete, OrgPermissionSubjects.Member);
};
const onListMembershipUserGuard: TMembershipUserScopeFactory["onListMembershipUserGuard"] = async (dto) => {
- const { permission } = await permissionService.getOrgPermission(
- dto.permission.type,
- dto.permission.id,
- dto.permission.orgId,
- dto.permission.authMethod,
- dto.permission.orgId
- );
+ const { permission } = await permissionService.getOrgPermission({
+ actor: dto.permission.type,
+ actorId: dto.permission.id,
+ orgId: dto.permission.orgId,
+ actorAuthMethod: dto.permission.authMethod,
+ actorOrgId: dto.permission.orgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Member);
};
const onGetMembershipUserByUserIdGuard: TMembershipUserScopeFactory["onGetMembershipUserByUserIdGuard"] = async (
dto
) => {
- const { permission } = await permissionService.getOrgPermission(
- dto.permission.type,
- dto.permission.id,
- dto.permission.orgId,
- dto.permission.authMethod,
- dto.permission.orgId
- );
+ const { permission } = await permissionService.getOrgPermission({
+ actor: dto.permission.type,
+ actorId: dto.permission.id,
+ orgId: dto.permission.orgId,
+ actorAuthMethod: dto.permission.authMethod,
+ actorOrgId: dto.permission.orgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Member);
};
diff --git a/backend/src/services/microsoft-teams/microsoft-teams-service.ts b/backend/src/services/microsoft-teams/microsoft-teams-service.ts
index 23ed61402a..ff17daa755 100644
--- a/backend/src/services/microsoft-teams/microsoft-teams-service.ts
+++ b/backend/src/services/microsoft-teams/microsoft-teams-service.ts
@@ -9,6 +9,7 @@ import {
import { CronJob } from "cron";
import { FastifyReply, FastifyRequest } from "fastify";
+import { OrganizationActionScope } from "@app/db/schemas";
import { OrgPermissionActions, OrgPermissionSubjects } from "@app/ee/services/permission/org-permission";
import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service-types";
import { BadRequestError, DatabaseError, NotFoundError } from "@app/lib/errors";
@@ -208,13 +209,14 @@ export const microsoftTeamsServiceFactory = ({
});
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
actor,
actorId,
- microsoftTeamsIntegration.orgId,
+ orgId: microsoftTeamsIntegration.orgId,
actorAuthMethod,
- actorOrgId
- );
+ actorOrgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Edit, OrgPermissionSubjects.Settings);
@@ -282,13 +284,14 @@ export const microsoftTeamsServiceFactory = ({
description,
redirectUri
}: TCreateMicrosoftTeamsIntegrationDTO) => {
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
actor,
actorId,
- actorOrgId,
+ orgId: actorOrgId,
actorAuthMethod,
- actorOrgId
- );
+ actorOrgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Create, OrgPermissionSubjects.Settings);
@@ -393,13 +396,14 @@ export const microsoftTeamsServiceFactory = ({
});
};
const getClientId = async ({ actorId, actor, actorOrgId, actorAuthMethod }: TGetClientIdDTO) => {
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
actor,
actorId,
- actorOrgId,
+ orgId: actorOrgId,
actorAuthMethod,
- actorOrgId
- );
+ actorOrgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Settings);
@@ -427,13 +431,14 @@ export const microsoftTeamsServiceFactory = ({
actorOrgId,
actorAuthMethod
}: TGetMicrosoftTeamsIntegrationByOrgDTO) => {
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
actor,
actorId,
- actorOrgId,
+ orgId: actorOrgId,
actorAuthMethod,
- actorOrgId
- );
+ actorOrgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Create, OrgPermissionSubjects.Settings);
@@ -463,13 +468,14 @@ export const microsoftTeamsServiceFactory = ({
});
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
actor,
actorId,
- microsoftTeamsIntegration.orgId,
+ orgId: microsoftTeamsIntegration.orgId,
actorAuthMethod,
- actorOrgId
- );
+ actorOrgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Settings);
@@ -495,13 +501,14 @@ export const microsoftTeamsServiceFactory = ({
});
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
actor,
actorId,
- microsoftTeamsIntegration.orgId,
+ orgId: microsoftTeamsIntegration.orgId,
actorAuthMethod,
- actorOrgId
- );
+ actorOrgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Edit, OrgPermissionSubjects.Settings);
@@ -549,13 +556,14 @@ export const microsoftTeamsServiceFactory = ({
});
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
actor,
actorId,
- microsoftTeamsIntegration.orgId,
+ orgId: microsoftTeamsIntegration.orgId,
actorAuthMethod,
- actorOrgId
- );
+ actorOrgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Delete, OrgPermissionSubjects.Settings);
@@ -577,13 +585,14 @@ export const microsoftTeamsServiceFactory = ({
});
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
actor,
actorId,
- microsoftTeamsIntegration.orgId,
+ orgId: microsoftTeamsIntegration.orgId,
actorAuthMethod,
- actorOrgId
- );
+ actorOrgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Settings);
diff --git a/backend/src/services/org-admin/org-admin-service.ts b/backend/src/services/org-admin/org-admin-service.ts
index 4c080717d9..4f4a9b08c8 100644
--- a/backend/src/services/org-admin/org-admin-service.ts
+++ b/backend/src/services/org-admin/org-admin-service.ts
@@ -1,6 +1,6 @@
import { ForbiddenError } from "@casl/ability";
-import { AccessScope, ProjectMembershipRole, ProjectVersion } from "@app/db/schemas";
+import { AccessScope, OrganizationActionScope, ProjectMembershipRole, ProjectVersion } from "@app/db/schemas";
import { OrgPermissionAdminConsoleAction, OrgPermissionSubjects } from "@app/ee/services/permission/org-permission";
import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service-types";
import { BadRequestError, NotFoundError } from "@app/lib/errors";
@@ -44,13 +44,14 @@ export const orgAdminServiceFactory = ({
actorOrgId,
actorAuthMethod
}: TListOrgProjectsDTO) => {
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
actor,
actorId,
- actorOrgId,
+ orgId: actorOrgId,
actorAuthMethod,
- actorOrgId
- );
+ actorOrgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(
OrgPermissionAdminConsoleAction.AccessAllProjects,
OrgPermissionSubjects.AdminConsole
@@ -76,13 +77,14 @@ export const orgAdminServiceFactory = ({
actorAuthMethod,
projectId
}: TAccessProjectDTO) => {
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
actor,
actorId,
- actorOrgId,
+ orgId: actorOrgId,
actorAuthMethod,
- actorOrgId
- );
+ actorOrgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(
OrgPermissionAdminConsoleAction.AccessAllProjects,
OrgPermissionSubjects.AdminConsole
diff --git a/backend/src/services/org/org-dal.ts b/backend/src/services/org/org-dal.ts
index 077ddcdfb1..d7efdc4630 100644
--- a/backend/src/services/org/org-dal.ts
+++ b/backend/src/services/org/org-dal.ts
@@ -26,8 +26,8 @@ import {
} from "@app/lib/knex";
import { generateKnexQueryFromScim } from "@app/lib/knex/scim";
-import { OrgAuthMethod } from "./org-types";
import { ActorType } from "../auth/auth-type";
+import { OrgAuthMethod } from "./org-types";
export type TOrgDALFactory = ReturnType<typeof orgDALFactory>;
diff --git a/backend/src/services/org/org-service.ts b/backend/src/services/org/org-service.ts
index 5b98b44b18..b053349d32 100644
--- a/backend/src/services/org/org-service.ts
+++ b/backend/src/services/org/org-service.ts
@@ -4,6 +4,7 @@ import { Knex } from "knex";
import {
AccessScope,
+ OrganizationActionScope,
OrgMembershipRole,
OrgMembershipStatus,
TableName,
@@ -158,7 +159,14 @@ export const orgServiceFactory = ({
actorAuthMethod: ActorAuthMethod,
actorOrgId: string | undefined
) => {
- await permissionService.getOrgPermission(ActorType.USER, userId, orgId, actorAuthMethod, actorOrgId);
+ await permissionService.getOrgPermission({
+ actor: ActorType.USER,
+ actorId: userId,
+ orgId,
+ actorAuthMethod,
+ actorOrgId,
+ scope: OrganizationActionScope.Any
+ });
const appCfg = getConfig();
const org = await orgDAL.findOrgById(orgId);
if (!org) throw new NotFoundError({ message: `Organization with ID '${orgId}' not found` });
@@ -194,13 +202,14 @@ export const orgServiceFactory = ({
actorAuthMethod: ActorAuthMethod,
actorOrgId: string | undefined
) => {
- const { permission } = await permissionService.getOrgPermission(
- ActorType.USER,
- userId,
+ const { permission } = await permissionService.getOrgPermission({
+ actor: ActorType.USER,
+ actorId: userId,
orgId,
actorAuthMethod,
- actorOrgId
- );
+ actorOrgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Member);
const members = await orgDAL.findAllOrgMembers(orgId);
@@ -208,7 +217,14 @@ export const orgServiceFactory = ({
};
const getOrgGroups = async ({ actor, actorId, orgId, actorAuthMethod, actorOrgId }: TGetOrgGroupsDTO) => {
- const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorAuthMethod, actorOrgId);
+ const { permission } = await permissionService.getOrgPermission({
+ actor,
+ actorId,
+ orgId,
+ actorAuthMethod,
+ actorOrgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionGroupActions.Read, OrgPermissionSubjects.Groups);
const groups = await groupDAL.findByOrgId(orgId);
return groups;
@@ -222,7 +238,14 @@ export const orgServiceFactory = ({
orgId,
emails
}: TFindOrgMembersByEmailDTO) => {
- const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorAuthMethod, actorOrgId);
+ const { permission } = await permissionService.getOrgPermission({
+ actor,
+ actorId,
+ orgId,
+ actorAuthMethod,
+ actorOrgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Member);
const members = await orgDAL.findOrgMembersByUsername(orgId, emails);
@@ -309,13 +332,14 @@ export const orgServiceFactory = ({
actorAuthMethod,
orgId
}: TUpgradePrivilegeSystemDTO) => {
- const { hasRole } = await permissionService.getOrgPermission(
- ActorType.USER,
+ const { hasRole } = await permissionService.getOrgPermission({
+ actor: ActorType.USER,
actorId,
orgId,
actorAuthMethod,
- actorOrgId
- );
+ actorOrgId,
+ scope: OrganizationActionScope.Any
+ });
if (!hasRole(OrgMembershipRole.Admin)) {
throw new ForbiddenRequestError({
@@ -380,7 +404,14 @@ export const orgServiceFactory = ({
}
}: TUpdateOrgDTO) => {
const appCfg = getConfig();
- const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorAuthMethod, actorOrgId);
+ const { permission } = await permissionService.getOrgPermission({
+ actor,
+ actorId,
+ orgId,
+ actorAuthMethod,
+ actorOrgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Edit, OrgPermissionSubjects.Settings);
if (allowSecretSharingOutsideOrganization !== undefined) {
@@ -658,13 +689,14 @@ export const orgServiceFactory = ({
actorAuthMethod: ActorAuthMethod;
actorOrgId: string | undefined;
}) => {
- const { hasRole } = await permissionService.getOrgPermission(
- ActorType.USER,
- userId,
+ const { hasRole } = await permissionService.getOrgPermission({
+ actor: ActorType.USER,
+ actorId: userId,
orgId,
actorAuthMethod,
- actorOrgId
- );
+ actorOrgId,
+ scope: OrganizationActionScope.Any
+ });
if (!hasRole(OrgMembershipRole.Admin)) {
throw new ForbiddenRequestError({
name: "DeleteOrganizationById",
@@ -744,13 +776,14 @@ export const orgServiceFactory = ({
actorOrgId,
metadata
}: TUpdateOrgMembershipDTO) => {
- const { permission } = await permissionService.getOrgPermission(
- ActorType.USER,
- userId,
+ const { permission } = await permissionService.getOrgPermission({
+ actor: ActorType.USER,
+ actorId: userId,
orgId,
actorAuthMethod,
- actorOrgId
- );
+ actorOrgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Edit, OrgPermissionSubjects.Member);
const foundMembership = await membershipUserDAL.findOne({
@@ -831,7 +864,14 @@ export const orgServiceFactory = ({
membershipId
}: TResendOrgMemberInvitationDTO) => {
const appCfg = getConfig();
- const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorAuthMethod, actorOrgId);
+ const { permission } = await permissionService.getOrgPermission({
+ actor,
+ actorId,
+ orgId,
+ actorAuthMethod,
+ actorOrgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Create, OrgPermissionSubjects.Member);
@@ -967,7 +1007,14 @@ export const orgServiceFactory = ({
actorAuthMethod,
actorOrgId
}: TGetOrgMembershipDTO) => {
- const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorAuthMethod, actorOrgId);
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
+ actor,
+ actorId,
+ orgId,
+ actorAuthMethod,
+ actorOrgId
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Member);
const membership = await orgMembershipDAL.findOrgMembershipById(membershipId);
@@ -988,13 +1035,14 @@ export const orgServiceFactory = ({
actorAuthMethod,
actorOrgId
}: TDeleteOrgMembershipDTO) => {
- const { permission } = await permissionService.getOrgPermission(
- ActorType.USER,
- userId,
+ const { permission } = await permissionService.getOrgPermission({
+ actor: ActorType.USER,
+ actorId: userId,
orgId,
actorAuthMethod,
- actorOrgId
- );
+ actorOrgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Delete, OrgPermissionSubjects.Member);
const [deletedMembership] = await deleteOrgMembershipsFn({
@@ -1021,13 +1069,14 @@ export const orgServiceFactory = ({
actorAuthMethod,
actorOrgId
}: TDeleteOrgMembershipsDTO) => {
- const { permission } = await permissionService.getOrgPermission(
- ActorType.USER,
- userId,
+ const { permission } = await permissionService.getOrgPermission({
+ actor: ActorType.USER,
+ actorId: userId,
orgId,
actorAuthMethod,
- actorOrgId
- );
+ actorOrgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Delete, OrgPermissionSubjects.Member);
if (membershipIds.includes(userId)) {
@@ -1059,7 +1108,14 @@ export const orgServiceFactory = ({
actorAuthMethod,
actorOrgId
}: TListProjectMembershipsByOrgMembershipIdDTO) => {
- const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorAuthMethod, actorOrgId);
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
+ actor,
+ actorId,
+ orgId,
+ actorAuthMethod,
+ actorOrgId
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Member);
const membership = await orgMembershipDAL.findOrgMembershipById(orgMembershipId);
@@ -1082,13 +1138,14 @@ export const orgServiceFactory = ({
actorAuthMethod: ActorAuthMethod,
actorOrgId: string | undefined
) => {
- const { permission } = await permissionService.getOrgPermission(
- ActorType.USER,
- userId,
+ const { permission } = await permissionService.getOrgPermission({
+ actor: ActorType.USER,
+ actorId: userId,
orgId,
actorAuthMethod,
- actorOrgId
- );
+ actorOrgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.IncidentAccount);
const incidentContacts = await incidentContactDAL.findByOrgId(orgId);
return incidentContacts;
@@ -1101,13 +1158,14 @@ export const orgServiceFactory = ({
actorAuthMethod: ActorAuthMethod,
actorOrgId: string | undefined
) => {
- const { permission } = await permissionService.getOrgPermission(
- ActorType.USER,
- userId,
+ const { permission } = await permissionService.getOrgPermission({
+ actor: ActorType.USER,
+ actorId: userId,
orgId,
actorAuthMethod,
- actorOrgId
- );
+ actorOrgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Create, OrgPermissionSubjects.IncidentAccount);
const doesIncidentContactExist = await incidentContactDAL.findOne(orgId, { email });
if (doesIncidentContactExist) {
@@ -1128,13 +1186,14 @@ export const orgServiceFactory = ({
actorAuthMethod: ActorAuthMethod,
actorOrgId: string | undefined
) => {
- const { permission } = await permissionService.getOrgPermission(
- ActorType.USER,
- userId,
+ const { permission } = await permissionService.getOrgPermission({
+ actor: ActorType.USER,
+ actorId: userId,
orgId,
actorAuthMethod,
- actorOrgId
- );
+ actorOrgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Delete, OrgPermissionSubjects.IncidentAccount);
const incidentContact = await incidentContactDAL.deleteById(id, orgId);
diff --git a/backend/src/services/project/project-service.ts b/backend/src/services/project/project-service.ts
index 58b3c5395e..e17787351d 100644
--- a/backend/src/services/project/project-service.ts
+++ b/backend/src/services/project/project-service.ts
@@ -5,6 +5,7 @@ import slugify from "@sindresorhus/slugify";
import {
AccessScope,
ActionProjectType,
+ OrganizationActionScope,
ProjectMembershipRole,
ProjectType,
ProjectVersion,
@@ -245,13 +246,14 @@ export const projectServiceFactory = ({
type = ProjectType.SecretManager
}: TCreateProjectDTO) => {
const organization = await orgDAL.findOne({ id: actorOrgId });
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- organization.id,
+ orgId: organization.id,
actorAuthMethod,
actorOrgId
- );
+ });
if (
permission.cannot(OrgPermissionActions.Create, OrgPermissionSubjects.Workspace) &&
@@ -296,6 +298,7 @@ export const projectServiceFactory = ({
projectTemplate = await projectTemplateService.findProjectTemplateByName(template, {
id: actorId,
orgId: organization.id,
+ parentOrgId: organization.id,
type: actor,
authMethod: actorAuthMethod
});
@@ -513,13 +516,14 @@ export const projectServiceFactory = ({
: await projectDAL.findUserProjects(actorId, actorOrgId, type);
if (includeRoles) {
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- actorOrgId,
+ orgId: actorOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
// `includeRoles` is specifically used by organization admins when inviting new users to the organizations to avoid looping redundant api calls.
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Create, OrgPermissionSubjects.Member);
@@ -1822,13 +1826,13 @@ export const projectServiceFactory = ({
projectIds
}: TSearchProjectsDTO) => {
// check user belong to org
- await permissionService.getOrgPermission(
- permission.type,
- permission.id,
- permission.orgId,
- permission.authMethod,
- permission.orgId
- );
+ await permissionService.getOrgPermission({
+ actor: permission.type,
+ actorId: permission.id,
+ orgId: permission.orgId,
+ actorAuthMethod: permission.authMethod,
+ scope: OrganizationActionScope.Any
+ });
return projectDAL.searchProjects({
limit,
@@ -1846,13 +1850,13 @@ export const projectServiceFactory = ({
const requestProjectAccess = async ({ permission, comment, projectId }: TProjectAccessRequestDTO) => {
// check user belong to org
- await permissionService.getOrgPermission(
- permission.type,
- permission.id,
- permission.orgId,
- permission.authMethod,
- permission.orgId
- );
+ await permissionService.getOrgPermission({
+ actor: permission.type,
+ actorId: permission.id,
+ orgId: permission.orgId,
+ actorAuthMethod: permission.authMethod,
+ scope: OrganizationActionScope.Any
+ });
const projectMember = await permissionService
.getProjectPermission({
diff --git a/backend/src/services/role/org/org-role-factory.ts b/backend/src/services/role/org/org-role-factory.ts
index 50ffa5e43a..f91dabccbd 100644
--- a/backend/src/services/role/org/org-role-factory.ts
+++ b/backend/src/services/role/org/org-role-factory.ts
@@ -1,6 +1,6 @@
import { ForbiddenError } from "@casl/ability";
-import { AccessScope } from "@app/db/schemas";
+import { AccessScope, OrganizationActionScope } from "@app/db/schemas";
import {
orgAdminPermissions,
orgMemberPermissions,
@@ -34,35 +34,38 @@ export const newOrgRoleFactory = ({
const isCustomRole: TRoleScopeFactory["isCustomRole"] = (role: string) => isCustomOrgRole(role);
const onCreateRoleGuard: TRoleScopeFactory["onCreateRoleGuard"] = async (dto) => {
- const { permission } = await permissionService.getOrgPermission(
- dto.permission.type,
- dto.permission.id,
- dto.permission.orgId,
- dto.permission.authMethod,
- dto.permission.orgId
- );
+ const { permission } = await permissionService.getOrgPermission({
+ actor: dto.permission.type,
+ actorId: dto.permission.id,
+ orgId: dto.permission.orgId,
+ actorAuthMethod: dto.permission.authMethod,
+ actorOrgId: dto.permission.orgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Create, OrgPermissionSubjects.Role);
};
const onUpdateRoleGuard: TRoleScopeFactory["onUpdateRoleGuard"] = async (dto) => {
- const { permission } = await permissionService.getOrgPermission(
- dto.permission.type,
- dto.permission.id,
- dto.permission.orgId,
- dto.permission.authMethod,
- dto.permission.orgId
- );
+ const { permission } = await permissionService.getOrgPermission({
+ actor: dto.permission.type,
+ actorId: dto.permission.id,
+ orgId: dto.permission.orgId,
+ actorAuthMethod: dto.permission.authMethod,
+ actorOrgId: dto.permission.orgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Edit, OrgPermissionSubjects.Role);
};
const onDeleteRoleGuard: TRoleScopeFactory["onDeleteRoleGuard"] = async (dto) => {
- const { permission } = await permissionService.getOrgPermission(
- dto.permission.type,
- dto.permission.id,
- dto.permission.orgId,
- dto.permission.authMethod,
- dto.permission.orgId
- );
+ const { permission } = await permissionService.getOrgPermission({
+ actor: dto.permission.type,
+ actorId: dto.permission.id,
+ orgId: dto.permission.orgId,
+ actorAuthMethod: dto.permission.authMethod,
+ actorOrgId: dto.permission.orgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Delete, OrgPermissionSubjects.Role);
const externalGroupMapping = await externalGroupOrgRoleMappingDAL.findOne({
@@ -78,35 +81,38 @@ export const newOrgRoleFactory = ({
};
const onListRoleGuard: TRoleScopeFactory["onListRoleGuard"] = async (dto) => {
- const { permission } = await permissionService.getOrgPermission(
- dto.permission.type,
- dto.permission.id,
- dto.permission.orgId,
- dto.permission.authMethod,
- dto.permission.orgId
- );
+ const { permission } = await permissionService.getOrgPermission({
+ actor: dto.permission.type,
+ actorId: dto.permission.id,
+ orgId: dto.permission.orgId,
+ actorAuthMethod: dto.permission.authMethod,
+ actorOrgId: dto.permission.orgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Role);
};
const onGetRoleByIdGuard: TRoleScopeFactory["onGetRoleByIdGuard"] = async (dto) => {
- const { permission } = await permissionService.getOrgPermission(
- dto.permission.type,
- dto.permission.id,
- dto.permission.orgId,
- dto.permission.authMethod,
- dto.permission.orgId
- );
+ const { permission } = await permissionService.getOrgPermission({
+ actor: dto.permission.type,
+ actorId: dto.permission.id,
+ orgId: dto.permission.orgId,
+ actorAuthMethod: dto.permission.authMethod,
+ actorOrgId: dto.permission.orgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Role);
};
const onGetRoleBySlugGuard: TRoleScopeFactory["onGetRoleBySlugGuard"] = async (dto) => {
- const { permission } = await permissionService.getOrgPermission(
- dto.permission.type,
- dto.permission.id,
- dto.permission.orgId,
- dto.permission.authMethod,
- dto.permission.orgId
- );
+ const { permission } = await permissionService.getOrgPermission({
+ actor: dto.permission.type,
+ actorId: dto.permission.id,
+ orgId: dto.permission.orgId,
+ actorAuthMethod: dto.permission.authMethod,
+ actorOrgId: dto.permission.orgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Role);
};
diff --git a/backend/src/services/role/role-service.ts b/backend/src/services/role/role-service.ts
index 41c825b2e9..3387dc96be 100644
--- a/backend/src/services/role/role-service.ts
+++ b/backend/src/services/role/role-service.ts
@@ -1,7 +1,7 @@
import { packRules } from "@casl/ability/extra";
import { requestContext } from "@fastify/request-context";
-import { AccessScope, ActionProjectType, TableName } from "@app/db/schemas";
+import { AccessScope, ActionProjectType, OrganizationActionScope, TableName } from "@app/db/schemas";
import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service-types";
import { BadRequestError, NotFoundError } from "@app/lib/errors";
import { validateHandlebarTemplate } from "@app/lib/template/validate-handlebars";
@@ -214,13 +214,14 @@ export const roleServiceFactory = ({
const getUserPermission = async (dto: TGetUserPermissionDTO) => {
if (dto.scopeData.scope === AccessScope.Organization) {
- const { permission, memberships } = await permissionService.getOrgPermission(
- dto.permission.type,
- dto.permission.id,
- dto.permission.orgId,
- dto.permission.authMethod,
- dto.permission.orgId
- );
+ const { permission, memberships } = await permissionService.getOrgPermission({
+ actorId: dto.permission.id,
+ actor: dto.permission.type,
+ orgId: dto.permission.orgId,
+ actorOrgId: dto.permission.orgId,
+ actorAuthMethod: dto.permission.authMethod,
+ scope: OrganizationActionScope.Any
+ });
return { permissions: packRules(permission.rules), memberships, assumedPrivilegeDetails: undefined };
}
diff --git a/backend/src/services/secret-sharing/secret-sharing-service.ts b/backend/src/services/secret-sharing/secret-sharing-service.ts
index 4cbfcdc7f3..3f5df049cb 100644
--- a/backend/src/services/secret-sharing/secret-sharing-service.ts
+++ b/backend/src/services/secret-sharing/secret-sharing-service.ts
@@ -1,4 +1,4 @@
-import { TSecretSharing } from "@app/db/schemas";
+import { OrganizationActionScope, TSecretSharing } from "@app/db/schemas";
import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service-types";
import { getConfig } from "@app/lib/config/env";
import { crypto } from "@app/lib/crypto/cryptography";
@@ -81,7 +81,14 @@ export const secretSharingServiceFactory = ({
}: TCreateSharedSecretDTO) => {
const appCfg = getConfig();
- const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorAuthMethod, actorOrgId);
+ const { permission } = await permissionService.getOrgPermission({
+ actor,
+ actorId,
+ orgId,
+ actorAuthMethod,
+ actorOrgId,
+ scope: OrganizationActionScope.Any
+ });
if (!permission) throw new ForbiddenRequestError({ name: "User is not a part of the specified organization" });
$validateSharedSecretExpiry(expiresAt);
@@ -196,7 +203,14 @@ export const secretSharingServiceFactory = ({
actorAuthMethod,
actorOrgId
}: TCreateSecretRequestDTO) => {
- const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorAuthMethod, actorOrgId);
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
+ actor,
+ actorId,
+ orgId,
+ actorAuthMethod,
+ actorOrgId
+ });
if (!permission) throw new ForbiddenRequestError({ name: "User is not a part of the specified organization" });
$validateSharedSecretExpiry(expiresAt);
@@ -228,7 +242,14 @@ export const secretSharingServiceFactory = ({
throw new NotFoundError({ message: `Secret request with ID '${id}' not found` });
}
- const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorAuthMethod, actorOrgId);
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
+ actor,
+ actorId,
+ orgId,
+ actorAuthMethod,
+ actorOrgId
+ });
if (!permission) throw new ForbiddenRequestError({ name: "User is not a part of the specified organization" });
if (secretRequest.userId !== actorId || secretRequest.orgId !== orgId) {
@@ -267,13 +288,14 @@ export const secretSharingServiceFactory = ({
throw new UnauthorizedError();
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- secretRequest.orgId,
+ orgId: secretRequest.orgId,
actorAuthMethod,
actorOrgId
- );
+ });
if (!permission) throw new ForbiddenRequestError({ name: "User is not a part of the specified organization" });
}
@@ -316,13 +338,14 @@ export const secretSharingServiceFactory = ({
throw new UnauthorizedError();
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- secretRequest.orgId,
+ orgId: secretRequest.orgId,
actorAuthMethod,
actorOrgId
- );
+ });
if (!permission) throw new ForbiddenRequestError({ name: "User is not a part of the specified organization" });
const user = await userDAL.findById(actorId);
@@ -415,13 +438,14 @@ export const secretSharingServiceFactory = ({
}: TGetSharedSecretsDTO) => {
if (!actorOrgId) throw new ForbiddenRequestError();
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
actor,
actorId,
- actorOrgId,
+ orgId: actorOrgId,
actorAuthMethod,
actorOrgId
- );
+ });
if (!permission) throw new ForbiddenRequestError({ name: "User does not belong to the specified organization" });
const secrets = await secretSharingDAL.find(
@@ -563,7 +587,14 @@ export const secretSharingServiceFactory = ({
const deleteSharedSecretById = async (deleteSharedSecretInput: TDeleteSharedSecretDTO) => {
const { actor, actorId, orgId, actorAuthMethod, actorOrgId, sharedSecretId } = deleteSharedSecretInput;
- const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorAuthMethod, actorOrgId);
+ const { permission } = await permissionService.getOrgPermission({
+ scope: OrganizationActionScope.Any,
+ actor,
+ actorId,
+ orgId,
+ actorAuthMethod,
+ actorOrgId
+ });
if (!permission) throw new ForbiddenRequestError({ name: "User does not belong to the specified organization" });
const sharedSecret = isUuidV4(sharedSecretId)
diff --git a/backend/src/services/slack/slack-service.ts b/backend/src/services/slack/slack-service.ts
index c8aa8aaf62..e4110ac118 100644
--- a/backend/src/services/slack/slack-service.ts
+++ b/backend/src/services/slack/slack-service.ts
@@ -1,6 +1,7 @@
import { ForbiddenError } from "@casl/ability";
import { InstallProvider } from "@slack/oauth";
+import { OrganizationActionScope } from "@app/db/schemas";
import { OrgPermissionActions, OrgPermissionSubjects } from "@app/ee/services/permission/org-permission";
import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service-types";
import { getConfig } from "@app/lib/config/env";
@@ -230,13 +231,14 @@ export const slackServiceFactory = ({
}: TGetSlackInstallUrlDTO) => {
const appCfg = getConfig();
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
actor,
actorId,
- actorOrgId,
+ orgId: actorOrgId,
actorAuthMethod,
- actorOrgId
- );
+ actorOrgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Create, OrgPermissionSubjects.Settings);
@@ -264,13 +266,14 @@ export const slackServiceFactory = ({
});
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
actor,
actorId,
- slackIntegration.orgId,
+ orgId: slackIntegration.orgId,
actorAuthMethod,
- actorOrgId
- );
+ actorOrgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Create, OrgPermissionSubjects.Settings);
@@ -293,13 +296,14 @@ export const slackServiceFactory = ({
actorOrgId,
actorAuthMethod
}: TGetSlackIntegrationByOrgDTO) => {
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
actor,
actorId,
- actorOrgId,
+ orgId: actorOrgId,
actorAuthMethod,
- actorOrgId
- );
+ actorOrgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Create, OrgPermissionSubjects.Settings);
@@ -324,13 +328,14 @@ export const slackServiceFactory = ({
});
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
actor,
actorId,
- slackIntegration.orgId,
+ orgId: slackIntegration.orgId,
actorAuthMethod,
- actorOrgId
- );
+ actorOrgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Settings);
@@ -351,13 +356,14 @@ export const slackServiceFactory = ({
});
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
actor,
actorId,
- slackIntegration.orgId,
+ orgId: slackIntegration.orgId,
actorAuthMethod,
- actorOrgId
- );
+ actorOrgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Settings);
@@ -389,13 +395,14 @@ export const slackServiceFactory = ({
});
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
actor,
actorId,
- slackIntegration.orgId,
+ orgId: slackIntegration.orgId,
actorAuthMethod,
- actorOrgId
- );
+ actorOrgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Edit, OrgPermissionSubjects.Settings);
@@ -432,13 +439,14 @@ export const slackServiceFactory = ({
});
}
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
actor,
actorId,
- slackIntegration.orgId,
+ orgId: slackIntegration.orgId,
actorAuthMethod,
- actorOrgId
- );
+ actorOrgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Delete, OrgPermissionSubjects.Settings);
diff --git a/backend/src/services/super-admin/super-admin-service.ts b/backend/src/services/super-admin/super-admin-service.ts
index 84a53f4075..63bab2666b 100644
--- a/backend/src/services/super-admin/super-admin-service.ts
+++ b/backend/src/services/super-admin/super-admin-service.ts
@@ -592,7 +592,7 @@ export const superAdminServiceFactory = ({
});
const { identity, credentials } = await identityDAL.transaction(async (tx) => {
- const newIdentity = await identityDAL.create({ name: "Instance Admin Identity" }, tx);
+ const newIdentity = await identityDAL.create({ name: "Instance Admin Identity", orgId: organization.id }, tx);
const membership = await membershipIdentityDAL.create(
{
actorIdentityId: newIdentity.id,
diff --git a/backend/src/services/user/user-service.ts b/backend/src/services/user/user-service.ts
index b54eab8eff..56d7ee635f 100644
--- a/backend/src/services/user/user-service.ts
+++ b/backend/src/services/user/user-service.ts
@@ -1,7 +1,7 @@
import { ForbiddenError } from "@casl/ability";
import { Knex } from "knex";
-import { AccessScope } from "@app/db/schemas";
+import { AccessScope, OrganizationActionScope } from "@app/db/schemas";
import { OrgPermissionActions, OrgPermissionSubjects } from "@app/ee/services/permission/org-permission";
import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service-types";
import { crypto } from "@app/lib/crypto";
@@ -458,13 +458,14 @@ export const userServiceFactory = ({
// This makes it so the user can always read information about themselves, but no one else if they don't have the Members Read permission.
if (user.id !== actorId) {
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
actor,
actorId,
- actorOrgId,
+ orgId: actorOrgId,
actorAuthMethod,
- actorOrgId
- );
+ actorOrgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Member);
}
diff --git a/backend/src/services/workflow-integration/workflow-integration-service.ts b/backend/src/services/workflow-integration/workflow-integration-service.ts
index cb7f7a325e..8fea0e2400 100644
--- a/backend/src/services/workflow-integration/workflow-integration-service.ts
+++ b/backend/src/services/workflow-integration/workflow-integration-service.ts
@@ -1,5 +1,6 @@
import { ForbiddenError } from "@casl/ability";
+import { OrganizationActionScope } from "@app/db/schemas";
import { OrgPermissionActions, OrgPermissionSubjects } from "@app/ee/services/permission/org-permission";
import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service-types";
@@ -23,13 +24,14 @@ export const workflowIntegrationServiceFactory = ({
actorOrgId,
actorAuthMethod
}: TGetWorkflowIntegrationsByOrg) => {
- const { permission } = await permissionService.getOrgPermission(
+ const { permission } = await permissionService.getOrgPermission({
actor,
actorId,
- actorOrgId,
+ orgId: actorOrgId,
actorAuthMethod,
- actorOrgId
- );
+ actorOrgId,
+ scope: OrganizationActionScope.Any
+ });
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Read, OrgPermissionSubjects.Settings);