mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-15 15:41:27 +00:00
merge main
This commit is contained in:
@@ -55,7 +55,7 @@ export const importDataIntoInfisicalFn = async ({
|
||||
actorId,
|
||||
actorOrgId,
|
||||
actorAuthMethod,
|
||||
workspaceName: project.name,
|
||||
projectName: project.name,
|
||||
createDefaultEnvs: false,
|
||||
tx
|
||||
})
|
||||
|
||||
@@ -237,8 +237,8 @@ export const projectServiceFactory = ({
|
||||
actorId,
|
||||
actorOrgId,
|
||||
actorAuthMethod,
|
||||
workspaceName,
|
||||
workspaceDescription,
|
||||
projectName: workspaceName,
|
||||
projectDescription: workspaceDescription,
|
||||
slug: projectSlug,
|
||||
kmsKeyId,
|
||||
tx: trx,
|
||||
@@ -254,7 +254,13 @@ export const projectServiceFactory = ({
|
||||
actorAuthMethod,
|
||||
actorOrgId
|
||||
);
|
||||
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Create, OrgPermissionSubjects.Workspace);
|
||||
|
||||
if (
|
||||
permission.cannot(OrgPermissionActions.Create, OrgPermissionSubjects.Workspace) &&
|
||||
permission.cannot(OrgPermissionActions.Create, OrgPermissionSubjects.Project)
|
||||
) {
|
||||
throw new ForbiddenRequestError({ message: "You don't have permission to create a project" });
|
||||
}
|
||||
|
||||
const results = await (trx || projectDAL).transaction(async (tx) => {
|
||||
await tx.raw("SELECT pg_advisory_xact_lock(?)", [PgSqlLock.CreateProject(organization.id)]);
|
||||
@@ -591,7 +597,8 @@ export const projectServiceFactory = ({
|
||||
secretSharing: update.secretSharing,
|
||||
defaultProduct: update.defaultProduct,
|
||||
showSnapshotsLegacy: update.showSnapshotsLegacy,
|
||||
secretDetectionIgnoreValues: update.secretDetectionIgnoreValues
|
||||
secretDetectionIgnoreValues: update.secretDetectionIgnoreValues,
|
||||
pitVersionLimit: update.pitVersionLimit
|
||||
});
|
||||
|
||||
return updatedProject;
|
||||
@@ -684,19 +691,21 @@ export const projectServiceFactory = ({
|
||||
actorOrgId,
|
||||
actorAuthMethod,
|
||||
auditLogsRetentionDays,
|
||||
workspaceSlug
|
||||
filter
|
||||
}: TUpdateAuditLogsRetentionDTO) => {
|
||||
const project = await projectDAL.findProjectBySlug(workspaceSlug, actorOrgId);
|
||||
const project = await projectDAL.findProjectByFilter(filter);
|
||||
const projectId = project.id;
|
||||
|
||||
if (!project) {
|
||||
throw new NotFoundError({
|
||||
message: `Project with slug '${workspaceSlug}' not found`
|
||||
message: `Project not found`
|
||||
});
|
||||
}
|
||||
|
||||
const { hasRole } = await permissionService.getProjectPermission({
|
||||
actor,
|
||||
actorId,
|
||||
projectId: project.id,
|
||||
projectId,
|
||||
actorAuthMethod,
|
||||
actorOrgId,
|
||||
actionProjectType: ActionProjectType.Any
|
||||
|
||||
@@ -42,12 +42,13 @@ export type TCreateProjectDTO = {
|
||||
actorAuthMethod: ActorAuthMethod;
|
||||
actorId: string;
|
||||
actorOrgId?: string;
|
||||
workspaceName: string;
|
||||
workspaceDescription?: string;
|
||||
projectName: string;
|
||||
projectDescription?: string;
|
||||
slug?: string;
|
||||
kmsKeyId?: string;
|
||||
createDefaultEnvs?: boolean;
|
||||
template?: string;
|
||||
pitVersionLimit?: number;
|
||||
tx?: Knex;
|
||||
type?: ProjectType;
|
||||
};
|
||||
@@ -78,7 +79,7 @@ export type TUpdateProjectVersionLimitDTO = {
|
||||
|
||||
export type TUpdateAuditLogsRetentionDTO = {
|
||||
auditLogsRetentionDays: number;
|
||||
workspaceSlug: string;
|
||||
filter: Filter;
|
||||
} & Omit<TProjectPermission, "projectId">;
|
||||
|
||||
export type TUpdateProjectNameDTO = {
|
||||
@@ -90,6 +91,7 @@ export type TUpdateProjectDTO = {
|
||||
update: {
|
||||
name?: string;
|
||||
description?: string;
|
||||
pitVersionLimit?: number;
|
||||
autoCapitalization?: boolean;
|
||||
hasDeleteProtection?: boolean;
|
||||
defaultProduct?: ProjectType;
|
||||
|
||||
@@ -47,7 +47,7 @@ type TSecretFolderServiceFactoryDep = {
|
||||
folderCommitService: Pick<TFolderCommitServiceFactory, "createCommit">;
|
||||
projectDAL: Pick<TProjectDALFactory, "findProjectBySlug">;
|
||||
secretApprovalPolicyService: Pick<TSecretApprovalPolicyServiceFactory, "getSecretApprovalPolicy">;
|
||||
secretV2BridgeDAL: Pick<TSecretV2BridgeDALFactory, "findByFolderIds">;
|
||||
secretV2BridgeDAL: Pick<TSecretV2BridgeDALFactory, "findByFolderIds" | "invalidateSecretCacheByProjectId">;
|
||||
};
|
||||
|
||||
export type TSecretFolderServiceFactory = ReturnType<typeof secretFolderServiceFactory>;
|
||||
@@ -398,6 +398,7 @@ export const secretFolderServiceFactory = ({
|
||||
|
||||
await Promise.all(result.map(async (res) => snapshotService.performSnapshot(res.newFolder.parentId as string)));
|
||||
|
||||
await secretV2BridgeDAL.invalidateSecretCacheByProjectId(projectId);
|
||||
return {
|
||||
projectId,
|
||||
newFolders: result.map((res) => res.newFolder),
|
||||
@@ -522,6 +523,7 @@ export const secretFolderServiceFactory = ({
|
||||
}
|
||||
|
||||
await snapshotService.performSnapshot(newFolder.parentId as string);
|
||||
await secretV2BridgeDAL.invalidateSecretCacheByProjectId(projectId);
|
||||
return {
|
||||
folder: { ...newFolder, path: newFolderWithFullPath.path },
|
||||
old: { ...folder, path: folderWithFullPath.path }
|
||||
@@ -724,6 +726,7 @@ export const secretFolderServiceFactory = ({
|
||||
});
|
||||
|
||||
await snapshotService.performSnapshot(folder.parentId as string);
|
||||
await secretV2BridgeDAL.invalidateSecretCacheByProjectId(projectId);
|
||||
return folder;
|
||||
};
|
||||
|
||||
|
||||
@@ -2970,14 +2970,23 @@ export const secretServiceFactory = ({
|
||||
actor,
|
||||
actorId,
|
||||
actorAuthMethod,
|
||||
actorOrgId
|
||||
actorOrgId,
|
||||
projectId: inputProjectId
|
||||
}: TMoveSecretsDTO) => {
|
||||
const project = await projectDAL.findProjectBySlug(projectSlug, actorOrgId);
|
||||
let project;
|
||||
if (projectSlug) {
|
||||
project = await projectDAL.findProjectBySlug(projectSlug, actorOrgId);
|
||||
} else if (inputProjectId) {
|
||||
project = await projectDAL.findById(inputProjectId);
|
||||
}
|
||||
|
||||
if (!project) {
|
||||
throw new NotFoundError({
|
||||
message: `Project with slug '${projectSlug}' not found`
|
||||
});
|
||||
}
|
||||
|
||||
const projectId = project.id;
|
||||
if (project.version === ProjectVersion.V3) {
|
||||
return secretV2BridgeService.moveSecrets({
|
||||
sourceEnvironment,
|
||||
@@ -3170,7 +3179,7 @@ export const secretServiceFactory = ({
|
||||
});
|
||||
}
|
||||
const destinationFolderPolicy = await secretApprovalPolicyService.getSecretApprovalPolicy(
|
||||
project.id,
|
||||
projectId,
|
||||
destinationFolder.environment.slug,
|
||||
destinationFolder.path
|
||||
);
|
||||
@@ -3257,7 +3266,7 @@ export const secretServiceFactory = ({
|
||||
}
|
||||
if (locallyUpdatedSecrets.length) {
|
||||
await fnSecretBulkUpdate({
|
||||
projectId: project.id,
|
||||
projectId,
|
||||
folderId: destinationFolder.id,
|
||||
secretVersionDAL,
|
||||
secretDAL,
|
||||
@@ -3300,7 +3309,7 @@ export const secretServiceFactory = ({
|
||||
const locallyDeletedSecrets = decryptedSourceSecrets.map((el) => ({ ...el, operation: SecretOperations.Delete }));
|
||||
|
||||
const sourceFolderPolicy = await secretApprovalPolicyService.getSecretApprovalPolicy(
|
||||
project.id,
|
||||
projectId,
|
||||
sourceFolder.environment.slug,
|
||||
sourceFolder.path
|
||||
);
|
||||
|
||||
@@ -534,7 +534,8 @@ export type TSyncSecretsDTO<T extends boolean = false> = {
|
||||
});
|
||||
|
||||
export type TMoveSecretsDTO = {
|
||||
projectSlug: string;
|
||||
projectId?: string;
|
||||
projectSlug?: string;
|
||||
sourceEnvironment: string;
|
||||
sourceSecretPath: string;
|
||||
destinationEnvironment: string;
|
||||
|
||||
@@ -46,7 +46,7 @@ export type TSecretModifiedEvent = {
|
||||
properties: {
|
||||
numberOfSecrets: number;
|
||||
environment: string;
|
||||
workspaceId: string;
|
||||
projectId: string;
|
||||
secretPath: string;
|
||||
channel?: string;
|
||||
userAgent?: string;
|
||||
|
||||
Reference in New Issue
Block a user