mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-15 09:35:37 +00:00
feat: switched to root org id pattern
This commit is contained in:
@@ -460,7 +460,7 @@ export const groupServiceFactory = ({
|
||||
const { permission } = await permissionService.getOrgPermission({
|
||||
actor,
|
||||
actorId,
|
||||
actorOrgId,
|
||||
orgId: actorOrgId,
|
||||
actorAuthMethod,
|
||||
actorOrgId,
|
||||
scope: OrganizationActionScope.Any
|
||||
|
||||
@@ -19,7 +19,7 @@ interface TPermissionDataReturn extends TMemberships {
|
||||
orgAuthEnforced?: boolean | null;
|
||||
orgGoogleSsoAuthEnforced?: boolean | null;
|
||||
shouldUseNewPrivilegeSystem?: boolean | null;
|
||||
parentOrgId?: boolean | null;
|
||||
rootOrgId?: string | null;
|
||||
bypassOrgAuthEnabled?: boolean | null;
|
||||
roles: {
|
||||
id: string;
|
||||
@@ -275,7 +275,7 @@ export const permissionDALFactory = (db: TDbClient): TPermissionDALFactory => {
|
||||
db.ref("authEnforced").withSchema(TableName.Organization).as("orgAuthEnforced"),
|
||||
db.ref("googleSsoAuthEnforced").withSchema(TableName.Organization).as("orgGoogleSsoAuthEnforced"),
|
||||
db.ref("bypassOrgAuthEnabled").withSchema(TableName.Organization).as("bypassOrgAuthEnabled"),
|
||||
db.ref("parentOrgId").withSchema(TableName.Organization).as("parentOrgId")
|
||||
db.ref("rootOrgId").withSchema(TableName.Organization).as("rootOrgId")
|
||||
);
|
||||
|
||||
const data = sqlNestRelationships({
|
||||
@@ -285,7 +285,7 @@ export const permissionDALFactory = (db: TDbClient): TPermissionDALFactory => {
|
||||
MembershipsSchema.extend({
|
||||
orgAuthEnforced: z.boolean().optional().nullable(),
|
||||
shouldUseNewPrivilegeSystem: z.boolean().optional().nullable(),
|
||||
parentOrgId: z.string().optional().nullable(),
|
||||
rootOrgId: z.string().optional().nullable(),
|
||||
orgGoogleSsoAuthEnforced: z.boolean(),
|
||||
bypassOrgAuthEnabled: z.boolean()
|
||||
}).parse(el),
|
||||
|
||||
@@ -209,8 +209,8 @@ export const permissionServiceFactory = ({
|
||||
});
|
||||
if (!permissionData?.length) throw new ForbiddenRequestError({ name: "You are not member of this organization" });
|
||||
|
||||
const parentOrgId = permissionData?.[0]?.parentOrgId;
|
||||
const isChild = Boolean(parentOrgId);
|
||||
const rootOrgId = permissionData?.[0]?.rootOrgId;
|
||||
const isChild = Boolean(rootOrgId);
|
||||
if (scope === OrganizationActionScope.ParentOrganization && isChild) {
|
||||
throw new BadRequestError({ message: `Child organization cannot do this operation` });
|
||||
} else if (scope === OrganizationActionScope.ChildOrganization && !isChild) {
|
||||
|
||||
@@ -2,7 +2,7 @@ import { z } from "zod";
|
||||
|
||||
import { ProjectMembershipRole, ProjectType, TProjectEnvironments } from "@app/db/schemas";
|
||||
import { TProjectPermissionV2Schema } from "@app/ee/services/permission/project-permission";
|
||||
import { OrgServiceActor } from "@app/lib/types";
|
||||
import { ProjectServiceActor } from "@app/lib/types";
|
||||
import { UnpackedPermissionSchema } from "@app/server/routes/sanitizedSchema/permission";
|
||||
|
||||
export type TProjectTemplateEnvironment = Pick<TProjectEnvironments, "name" | "slug" | "position">;
|
||||
@@ -31,7 +31,7 @@ export enum InfisicalProjectTemplate {
|
||||
|
||||
export type TProjectTemplateServiceFactory = {
|
||||
listProjectTemplatesByOrg: (
|
||||
actor: OrgServiceActor,
|
||||
actor: ProjectServiceActor,
|
||||
type?: ProjectType
|
||||
) => Promise<
|
||||
(
|
||||
@@ -85,7 +85,7 @@ export type TProjectTemplateServiceFactory = {
|
||||
>;
|
||||
createProjectTemplate: (
|
||||
arg: TCreateProjectTemplateDTO,
|
||||
actor: OrgServiceActor
|
||||
actor: ProjectServiceActor
|
||||
) => Promise<{
|
||||
environments: TProjectTemplateEnvironment[];
|
||||
roles: {
|
||||
@@ -109,7 +109,7 @@ export type TProjectTemplateServiceFactory = {
|
||||
updateProjectTemplateById: (
|
||||
id: string,
|
||||
{ roles, environments, ...params }: TUpdateProjectTemplateDTO,
|
||||
actor: OrgServiceActor
|
||||
actor: ProjectServiceActor
|
||||
) => Promise<{
|
||||
environments: TProjectTemplateEnvironment[];
|
||||
roles: {
|
||||
@@ -132,7 +132,7 @@ export type TProjectTemplateServiceFactory = {
|
||||
}>;
|
||||
deleteProjectTemplateById: (
|
||||
id: string,
|
||||
actor: OrgServiceActor
|
||||
actor: ProjectServiceActor
|
||||
) => Promise<{
|
||||
environments: TProjectTemplateEnvironment[];
|
||||
roles: {
|
||||
@@ -155,7 +155,7 @@ export type TProjectTemplateServiceFactory = {
|
||||
}>;
|
||||
findProjectTemplateById: (
|
||||
id: string,
|
||||
actor: OrgServiceActor
|
||||
actor: ProjectServiceActor
|
||||
) => Promise<{
|
||||
packedRoles: TProjectTemplateRole[];
|
||||
environments: TProjectTemplateEnvironment[];
|
||||
@@ -179,7 +179,7 @@ export type TProjectTemplateServiceFactory = {
|
||||
}>;
|
||||
findProjectTemplateByName: (
|
||||
name: string,
|
||||
actor: OrgServiceActor
|
||||
actor: ProjectServiceActor
|
||||
) => Promise<{
|
||||
packedRoles: TProjectTemplateRole[];
|
||||
environments: TProjectTemplateEnvironment[];
|
||||
|
||||
@@ -44,7 +44,7 @@ export const subOrgServiceFactory = ({
|
||||
OrgPermissionSubjects.ChildOrganization
|
||||
);
|
||||
|
||||
const orgLicensePlan = await licenseService.getPlan(permissionActor.parentOrgId);
|
||||
const orgLicensePlan = await licenseService.getPlan(permissionActor.rootOrgId);
|
||||
if (!orgLicensePlan.subOrganization) {
|
||||
throw new BadRequestError({
|
||||
message: "Child organization creation failed. Please upgrade your instance to Infisical's Enterprise plan."
|
||||
@@ -52,7 +52,10 @@ export const subOrgServiceFactory = ({
|
||||
}
|
||||
|
||||
const organization = await orgDAL.transaction(async (tx) => {
|
||||
const org = await orgDAL.create({ name, slug: name, parentOrgId: permissionActor.orgId }, tx);
|
||||
const org = await orgDAL.create(
|
||||
{ name, slug: name, rootOrgId: permissionActor.orgId, parentOrgId: permissionActor.orgId },
|
||||
tx
|
||||
);
|
||||
const membership = await membershipDAL.create(
|
||||
{
|
||||
scope: AccessScope.Organization,
|
||||
@@ -83,7 +86,7 @@ export const subOrgServiceFactory = ({
|
||||
actorId: permissionActor.id,
|
||||
actor: permissionActor.type,
|
||||
orgId: permissionActor.parentOrgId,
|
||||
actorOrgId: permissionActor.parentOrgId,
|
||||
actorOrgId: permissionActor.rootOrgId,
|
||||
actorAuthMethod: permissionActor.authMethod,
|
||||
scope: OrganizationActionScope.ParentOrganization
|
||||
});
|
||||
@@ -91,7 +94,7 @@ export const subOrgServiceFactory = ({
|
||||
const organizations = await orgDAL.listSubOrganizations({
|
||||
actorId: permissionActor.id,
|
||||
actorType: permissionActor.type,
|
||||
orgId: permissionActor.parentOrgId,
|
||||
orgId: permissionActor.rootOrgId,
|
||||
isAccessible: data?.isAccessible,
|
||||
limit: data?.limit,
|
||||
offset: data?.offset
|
||||
|
||||
Reference in New Issue
Block a user