mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 16:27:40 +00:00
Revert "Remove mongodb direct dependency from backend"
This commit is contained in:
Generated
+1
@@ -43,6 +43,7 @@
|
|||||||
"jsrp": "^0.2.4",
|
"jsrp": "^0.2.4",
|
||||||
"libsodium-wrappers": "^0.7.10",
|
"libsodium-wrappers": "^0.7.10",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
|
"mongodb": "^5.7.0",
|
||||||
"mongoose": "^7.4.1",
|
"mongoose": "^7.4.1",
|
||||||
"nanoid": "^3.3.6",
|
"nanoid": "^3.3.6",
|
||||||
"node-cache": "^5.1.2",
|
"node-cache": "^5.1.2",
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
"jsrp": "^0.2.4",
|
"jsrp": "^0.2.4",
|
||||||
"libsodium-wrappers": "^0.7.10",
|
"libsodium-wrappers": "^0.7.10",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
|
"mongodb": "^5.7.0",
|
||||||
"mongoose": "^7.4.1",
|
"mongoose": "^7.4.1",
|
||||||
"nanoid": "^3.3.6",
|
"nanoid": "^3.3.6",
|
||||||
"node-cache": "^5.1.2",
|
"node-cache": "^5.1.2",
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import {
|
|||||||
} from "../../ee/services/ProjectRoleService";
|
} from "../../ee/services/ProjectRoleService";
|
||||||
import { ForbiddenError } from "@casl/ability";
|
import { ForbiddenError } from "@casl/ability";
|
||||||
import { getIntegrationAuthAccessHelper } from "../../helpers";
|
import { getIntegrationAuthAccessHelper } from "../../helpers";
|
||||||
|
import { ObjectId } from "mongodb";
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* Return integration authorization with id [integrationAuthId]
|
* Return integration authorization with id [integrationAuthId]
|
||||||
@@ -221,7 +222,7 @@ export const getIntegrationAuthApps = async (req: Request, res: Response) => {
|
|||||||
|
|
||||||
// TODO(akhilmhdh): remove class -> static function path and makes these into reusable independent functions
|
// TODO(akhilmhdh): remove class -> static function path and makes these into reusable independent functions
|
||||||
const { integrationAuth, accessToken, accessId } = await getIntegrationAuthAccessHelper({
|
const { integrationAuth, accessToken, accessId } = await getIntegrationAuthAccessHelper({
|
||||||
integrationAuthId: new Types.ObjectId(integrationAuthId)
|
integrationAuthId: new ObjectId(integrationAuthId)
|
||||||
});
|
});
|
||||||
|
|
||||||
const { permission } = await getUserProjectPermissions(
|
const { permission } = await getUserProjectPermissions(
|
||||||
@@ -259,7 +260,7 @@ export const getIntegrationAuthTeams = async (req: Request, res: Response) => {
|
|||||||
|
|
||||||
// TODO(akhilmhdh): remove class -> static function path and makes these into reusable independent functions
|
// TODO(akhilmhdh): remove class -> static function path and makes these into reusable independent functions
|
||||||
const { integrationAuth, accessToken } = await getIntegrationAuthAccessHelper({
|
const { integrationAuth, accessToken } = await getIntegrationAuthAccessHelper({
|
||||||
integrationAuthId: new Types.ObjectId(integrationAuthId)
|
integrationAuthId: new ObjectId(integrationAuthId)
|
||||||
});
|
});
|
||||||
|
|
||||||
const { permission } = await getUserProjectPermissions(
|
const { permission } = await getUserProjectPermissions(
|
||||||
@@ -295,7 +296,7 @@ export const getIntegrationAuthVercelBranches = async (req: Request, res: Respon
|
|||||||
|
|
||||||
// TODO(akhilmhdh): remove class -> static function path and makes these into reusable independent functions
|
// TODO(akhilmhdh): remove class -> static function path and makes these into reusable independent functions
|
||||||
const { integrationAuth, accessToken } = await getIntegrationAuthAccessHelper({
|
const { integrationAuth, accessToken } = await getIntegrationAuthAccessHelper({
|
||||||
integrationAuthId: new Types.ObjectId(integrationAuthId)
|
integrationAuthId: new ObjectId(integrationAuthId)
|
||||||
});
|
});
|
||||||
|
|
||||||
const { permission } = await getUserProjectPermissions(
|
const { permission } = await getUserProjectPermissions(
|
||||||
@@ -356,7 +357,7 @@ export const getIntegrationAuthQoveryOrgs = async (req: Request, res: Response)
|
|||||||
|
|
||||||
// TODO(akhilmhdh): remove class -> static function path and makes these into reusable independent functions
|
// TODO(akhilmhdh): remove class -> static function path and makes these into reusable independent functions
|
||||||
const { integrationAuth, accessToken } = await getIntegrationAuthAccessHelper({
|
const { integrationAuth, accessToken } = await getIntegrationAuthAccessHelper({
|
||||||
integrationAuthId: new Types.ObjectId(integrationAuthId)
|
integrationAuthId: new ObjectId(integrationAuthId)
|
||||||
});
|
});
|
||||||
|
|
||||||
const { permission } = await getUserProjectPermissions(
|
const { permission } = await getUserProjectPermissions(
|
||||||
@@ -408,7 +409,7 @@ export const getIntegrationAuthQoveryProjects = async (req: Request, res: Respon
|
|||||||
|
|
||||||
// TODO(akhilmhdh): remove class -> static function path and makes these into reusable independent functions
|
// TODO(akhilmhdh): remove class -> static function path and makes these into reusable independent functions
|
||||||
const { integrationAuth, accessToken } = await getIntegrationAuthAccessHelper({
|
const { integrationAuth, accessToken } = await getIntegrationAuthAccessHelper({
|
||||||
integrationAuthId: new Types.ObjectId(integrationAuthId)
|
integrationAuthId: new ObjectId(integrationAuthId)
|
||||||
});
|
});
|
||||||
|
|
||||||
const { permission } = await getUserProjectPermissions(
|
const { permission } = await getUserProjectPermissions(
|
||||||
@@ -469,7 +470,7 @@ export const getIntegrationAuthQoveryEnvironments = async (req: Request, res: Re
|
|||||||
|
|
||||||
// TODO(akhilmhdh): remove class -> static function path and makes these into reusable independent functions
|
// TODO(akhilmhdh): remove class -> static function path and makes these into reusable independent functions
|
||||||
const { integrationAuth, accessToken } = await getIntegrationAuthAccessHelper({
|
const { integrationAuth, accessToken } = await getIntegrationAuthAccessHelper({
|
||||||
integrationAuthId: new Types.ObjectId(integrationAuthId)
|
integrationAuthId: new ObjectId(integrationAuthId)
|
||||||
});
|
});
|
||||||
|
|
||||||
const { permission } = await getUserProjectPermissions(
|
const { permission } = await getUserProjectPermissions(
|
||||||
@@ -530,7 +531,7 @@ export const getIntegrationAuthQoveryApps = async (req: Request, res: Response)
|
|||||||
|
|
||||||
// TODO(akhilmhdh): remove class -> static function path and makes these into reusable independent functions
|
// TODO(akhilmhdh): remove class -> static function path and makes these into reusable independent functions
|
||||||
const { integrationAuth, accessToken } = await getIntegrationAuthAccessHelper({
|
const { integrationAuth, accessToken } = await getIntegrationAuthAccessHelper({
|
||||||
integrationAuthId: new Types.ObjectId(integrationAuthId)
|
integrationAuthId: new ObjectId(integrationAuthId)
|
||||||
});
|
});
|
||||||
|
|
||||||
const { permission } = await getUserProjectPermissions(
|
const { permission } = await getUserProjectPermissions(
|
||||||
@@ -591,7 +592,7 @@ export const getIntegrationAuthQoveryContainers = async (req: Request, res: Resp
|
|||||||
|
|
||||||
// TODO(akhilmhdh): remove class -> static function path and makes these into reusable independent functions
|
// TODO(akhilmhdh): remove class -> static function path and makes these into reusable independent functions
|
||||||
const { integrationAuth, accessToken } = await getIntegrationAuthAccessHelper({
|
const { integrationAuth, accessToken } = await getIntegrationAuthAccessHelper({
|
||||||
integrationAuthId: new Types.ObjectId(integrationAuthId)
|
integrationAuthId: new ObjectId(integrationAuthId)
|
||||||
});
|
});
|
||||||
|
|
||||||
const { permission } = await getUserProjectPermissions(
|
const { permission } = await getUserProjectPermissions(
|
||||||
@@ -652,7 +653,7 @@ export const getIntegrationAuthQoveryJobs = async (req: Request, res: Response)
|
|||||||
|
|
||||||
// TODO(akhilmhdh): remove class -> static function path and makes these into reusable independent functions
|
// TODO(akhilmhdh): remove class -> static function path and makes these into reusable independent functions
|
||||||
const { integrationAuth, accessToken } = await getIntegrationAuthAccessHelper({
|
const { integrationAuth, accessToken } = await getIntegrationAuthAccessHelper({
|
||||||
integrationAuthId: new Types.ObjectId(integrationAuthId)
|
integrationAuthId: new ObjectId(integrationAuthId)
|
||||||
});
|
});
|
||||||
|
|
||||||
const { permission } = await getUserProjectPermissions(
|
const { permission } = await getUserProjectPermissions(
|
||||||
@@ -714,7 +715,7 @@ export const getIntegrationAuthRailwayEnvironments = async (req: Request, res: R
|
|||||||
|
|
||||||
// TODO(akhilmhdh): remove class -> static function path and makes these into reusable independent functions
|
// TODO(akhilmhdh): remove class -> static function path and makes these into reusable independent functions
|
||||||
const { integrationAuth, accessToken } = await getIntegrationAuthAccessHelper({
|
const { integrationAuth, accessToken } = await getIntegrationAuthAccessHelper({
|
||||||
integrationAuthId: new Types.ObjectId(integrationAuthId)
|
integrationAuthId: new ObjectId(integrationAuthId)
|
||||||
});
|
});
|
||||||
|
|
||||||
const { permission } = await getUserProjectPermissions(
|
const { permission } = await getUserProjectPermissions(
|
||||||
@@ -807,7 +808,7 @@ export const getIntegrationAuthRailwayServices = async (req: Request, res: Respo
|
|||||||
|
|
||||||
// TODO(akhilmhdh): remove class -> static function path and makes these into reusable independent functions
|
// TODO(akhilmhdh): remove class -> static function path and makes these into reusable independent functions
|
||||||
const { integrationAuth, accessToken } = await getIntegrationAuthAccessHelper({
|
const { integrationAuth, accessToken } = await getIntegrationAuthAccessHelper({
|
||||||
integrationAuthId: new Types.ObjectId(integrationAuthId)
|
integrationAuthId: new ObjectId(integrationAuthId)
|
||||||
});
|
});
|
||||||
|
|
||||||
const { permission } = await getUserProjectPermissions(
|
const { permission } = await getUserProjectPermissions(
|
||||||
@@ -931,7 +932,7 @@ export const getIntegrationAuthBitBucketWorkspaces = async (req: Request, res: R
|
|||||||
|
|
||||||
// TODO(akhilmhdh): remove class -> static function path and makes these into reusable independent functions
|
// TODO(akhilmhdh): remove class -> static function path and makes these into reusable independent functions
|
||||||
const { integrationAuth, accessToken } = await getIntegrationAuthAccessHelper({
|
const { integrationAuth, accessToken } = await getIntegrationAuthAccessHelper({
|
||||||
integrationAuthId: new Types.ObjectId(integrationAuthId)
|
integrationAuthId: new ObjectId(integrationAuthId)
|
||||||
});
|
});
|
||||||
|
|
||||||
const { permission } = await getUserProjectPermissions(
|
const { permission } = await getUserProjectPermissions(
|
||||||
@@ -987,7 +988,7 @@ export const getIntegrationAuthNorthflankSecretGroups = async (req: Request, res
|
|||||||
|
|
||||||
// TODO(akhilmhdh): remove class -> static function path and makes these into reusable independent functions
|
// TODO(akhilmhdh): remove class -> static function path and makes these into reusable independent functions
|
||||||
const { integrationAuth, accessToken } = await getIntegrationAuthAccessHelper({
|
const { integrationAuth, accessToken } = await getIntegrationAuthAccessHelper({
|
||||||
integrationAuthId: new Types.ObjectId(integrationAuthId)
|
integrationAuthId: new ObjectId(integrationAuthId)
|
||||||
});
|
});
|
||||||
|
|
||||||
const { permission } = await getUserProjectPermissions(
|
const { permission } = await getUserProjectPermissions(
|
||||||
@@ -1075,7 +1076,7 @@ export const getIntegrationAuthTeamCityBuildConfigs = async (req: Request, res:
|
|||||||
|
|
||||||
// TODO(akhilmhdh): remove class -> static function path and makes these into reusable independent functions
|
// TODO(akhilmhdh): remove class -> static function path and makes these into reusable independent functions
|
||||||
const { integrationAuth, accessToken } = await getIntegrationAuthAccessHelper({
|
const { integrationAuth, accessToken } = await getIntegrationAuthAccessHelper({
|
||||||
integrationAuthId: new Types.ObjectId(integrationAuthId)
|
integrationAuthId: new ObjectId(integrationAuthId)
|
||||||
});
|
});
|
||||||
|
|
||||||
const { permission } = await getUserProjectPermissions(
|
const { permission } = await getUserProjectPermissions(
|
||||||
@@ -1144,7 +1145,7 @@ export const deleteIntegrationAuth = async (req: Request, res: Response) => {
|
|||||||
|
|
||||||
// TODO(akhilmhdh): remove class -> static function path and makes these into reusable independent functions
|
// TODO(akhilmhdh): remove class -> static function path and makes these into reusable independent functions
|
||||||
const { integrationAuth, accessToken } = await getIntegrationAuthAccessHelper({
|
const { integrationAuth, accessToken } = await getIntegrationAuthAccessHelper({
|
||||||
integrationAuthId: new Types.ObjectId(integrationAuthId)
|
integrationAuthId: new ObjectId(integrationAuthId)
|
||||||
});
|
});
|
||||||
|
|
||||||
const { permission } = await getUserProjectPermissions(
|
const { permission } = await getUserProjectPermissions(
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import {
|
|||||||
ValidationError as RouteValidationError,
|
ValidationError as RouteValidationError,
|
||||||
UnauthorizedRequestError
|
UnauthorizedRequestError
|
||||||
} from "../../utils/errors";
|
} from "../../utils/errors";
|
||||||
|
import { AnyBulkWriteOperation } from "mongodb";
|
||||||
import {
|
import {
|
||||||
ALGORITHM_AES_256_GCM,
|
ALGORITHM_AES_256_GCM,
|
||||||
ENCODING_SCHEME_UTF8,
|
ENCODING_SCHEME_UTF8,
|
||||||
@@ -18,7 +19,7 @@ import {
|
|||||||
SECRET_SHARED
|
SECRET_SHARED
|
||||||
} from "../../variables";
|
} from "../../variables";
|
||||||
import { TelemetryService } from "../../services";
|
import { TelemetryService } from "../../services";
|
||||||
import { Secret, User } from "../../models";
|
import { ISecret, Secret, User } from "../../models";
|
||||||
import { AccountNotFoundError } from "../../utils/errors";
|
import { AccountNotFoundError } from "../../utils/errors";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -144,22 +145,22 @@ export const deleteSecrets = async (req: Request, res: Response) => {
|
|||||||
const secretsUserCanDeleteSet: Set<string> = new Set(
|
const secretsUserCanDeleteSet: Set<string> = new Set(
|
||||||
secretIdsUserCanDelete.map((objectId) => objectId._id.toString())
|
secretIdsUserCanDelete.map((objectId) => objectId._id.toString())
|
||||||
);
|
);
|
||||||
|
const deleteOperationsToPerform: AnyBulkWriteOperation<ISecret>[] = [];
|
||||||
|
|
||||||
// Filter out IDs that user can delete and then map them to delete operations
|
let numSecretsDeleted = 0;
|
||||||
const deleteOperationsToPerform = secretIdsToDelete
|
secretIdsToDelete.forEach((secretIdToDelete) => {
|
||||||
.filter(secretIdToDelete => {
|
if (secretsUserCanDeleteSet.has(secretIdToDelete)) {
|
||||||
if (!secretsUserCanDeleteSet.has(secretIdToDelete)) {
|
const deleteOperation = {
|
||||||
throw RouteValidationError({
|
deleteOne: { filter: { _id: new Types.ObjectId(secretIdToDelete) } }
|
||||||
message: "You cannot delete secrets that you do not have access to"
|
};
|
||||||
});
|
deleteOperationsToPerform.push(deleteOperation);
|
||||||
}
|
numSecretsDeleted++;
|
||||||
return true;
|
} else {
|
||||||
})
|
throw RouteValidationError({
|
||||||
.map(secretIdToDelete => ({
|
message: "You cannot delete secrets that you do not have access to"
|
||||||
deleteOne: { filter: { _id: new Types.ObjectId(secretIdToDelete) } }
|
});
|
||||||
}));
|
}
|
||||||
|
});
|
||||||
const numSecretsDeleted = deleteOperationsToPerform.length;
|
|
||||||
|
|
||||||
await Secret.bulkWrite(deleteOperationsToPerform);
|
await Secret.bulkWrite(deleteOperationsToPerform);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user