mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 18:27:36 +00:00
Block duplicate destinations on updates if flag is enabled
This commit is contained in:
@@ -454,6 +454,33 @@ export const secretSyncServiceFactory = ({
|
|||||||
|
|
||||||
let { folderId } = secretSync;
|
let { folderId } = secretSync;
|
||||||
|
|
||||||
|
if (params.destinationConfig) {
|
||||||
|
const project = await projectDAL.findById(secretSync.projectId);
|
||||||
|
if (!project) {
|
||||||
|
throw new NotFoundError({ message: "Project not found" });
|
||||||
|
}
|
||||||
|
const organization = await orgDAL.findById(project.orgId);
|
||||||
|
|
||||||
|
if (organization?.blockDuplicateSecretSyncDestinations) {
|
||||||
|
const duplicateCheck = await checkDuplicateDestination(
|
||||||
|
{
|
||||||
|
destination,
|
||||||
|
destinationConfig: params.destinationConfig,
|
||||||
|
projectId: secretSync.projectId,
|
||||||
|
excludeSyncId: secretSync.id
|
||||||
|
},
|
||||||
|
actor
|
||||||
|
);
|
||||||
|
if (duplicateCheck.hasDuplicate) {
|
||||||
|
throw new BadRequestError({
|
||||||
|
message: `A secret sync with this destination already exists${
|
||||||
|
duplicateCheck.duplicateProjectId ? ` in project ${duplicateCheck.duplicateProjectId}` : ""
|
||||||
|
}.`
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (params.connectionId) {
|
if (params.connectionId) {
|
||||||
const destinationApp = SECRET_SYNC_CONNECTION_MAP[secretSync.destination as SecretSync];
|
const destinationApp = SECRET_SYNC_CONNECTION_MAP[secretSync.destination as SecretSync];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user