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