Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

Move secretSuffix to separate metadata field

Tuan Dang41cd8b740867
diff --git a/backend/src/controllers/v1/integrationController.ts b/backend/src/controllers/v1/integrationController.ts
index 3c665fbea5..84d00f6bb6 100644
--- a/backend/src/controllers/v1/integrationController.ts
+++ b/backend/src/controllers/v1/integrationController.ts
@@ -1,9 +1,8 @@
import { Request, Response } from "express";
import { Types } from "mongoose";
-import { Integration } from "../../models";
+import { Folder, Integration } from "../../models";
import { EventService } from "../../services";
import { eventStartIntegration } from "../../events";
-import Folder from "../../models/folder";
import { getFolderByPath } from "../../services/FolderService";
import { BadRequestError } from "../../utils/errors";
import { EEAuditLogService } from "../../ee/services";
@@ -31,7 +30,7 @@ export const createIntegration = async (req: Request, res: Response) => {
path,
region,
secretPath,
- secretSuffix
+ metadata
} = req.body;
const folders = await Folder.findOne({
@@ -65,9 +64,9 @@ export const createIntegration = async (req: Request, res: Response) => {
path,
region,
secretPath,
- secretSuffix,
integration: req.integrationAuth.integration,
- integrationAuth: new Types.ObjectId(integrationAuthId)
+ integrationAuth: new Types.ObjectId(integrationAuthId),
+ metadata
}).save();
if (integration) {
diff --git a/backend/src/controllers/v1/secretImportController.ts b/backend/src/controllers/v1/secretImportController.ts
index 76b4945bdc..23be98096c 100644
--- a/backend/src/controllers/v1/secretImportController.ts
+++ b/backend/src/controllers/v1/secretImportController.ts
@@ -1,8 +1,6 @@
import { Request, Response } from "express";
import { isValidScope, validateMembership } from "../../helpers";
-import { ServiceTokenData } from "../../models";
-import Folder from "../../models/folder";
-import SecretImport from "../../models/secretImports";
+import { Folder, SecretImport, ServiceTokenData } from "../../models";
import { getAllImportedSecrets } from "../../services/SecretImportService";
import { getFolderWithPathFromId } from "../../services/FolderService";
import { BadRequestError, ResourceNotFoundError,UnauthorizedRequestError } from "../../utils/errors";
diff --git a/backend/src/controllers/v1/secretsFolderController.ts b/backend/src/controllers/v1/secretsFolderController.ts
index 46d4c3c1f9..cbc6425928 100644
--- a/backend/src/controllers/v1/secretsFolderController.ts
+++ b/backend/src/controllers/v1/secretsFolderController.ts
@@ -4,8 +4,7 @@ import { EventType, FolderVersion } from "../../ee/models";
import { EEAuditLogService, EESecretService } from "../../ee/services";
import { validateMembership } from "../../helpers/membership";
import { isValidScope } from "../../helpers/secrets";
-import { Secret, ServiceTokenData } from "../../models";
-import Folder from "../../models/folder";
+import { Folder, Secret, ServiceTokenData } from "../../models";
import {
appendFolder,
deleteFolderById,
diff --git a/backend/src/controllers/v1/webhookController.ts b/backend/src/controllers/v1/webhookController.ts
index a79b794cf8..7e84aae87a 100644
--- a/backend/src/controllers/v1/webhookController.ts
+++ b/backend/src/controllers/v1/webhookController.ts
@@ -2,7 +2,7 @@ import { Request, Response } from "express";
import { Types } from "mongoose";
import { client, getRootEncryptionKey } from "../../config";
import { validateMembership } from "../../helpers";
-import Webhook from "../../models/webhooks";
+import { Webhook } from "../../models";
import { getWebhookPayload, triggerWebhookRequest } from "../../services/WebhookService";
import { BadRequestError, ResourceNotFoundError } from "../../utils/errors";
import { EEAuditLogService } from "../../ee/services";
diff --git a/backend/src/controllers/v2/secretController.ts b/backend/src/controllers/v2/secretController.ts
index 5581a2ac71..bd36d6ab46 100644
--- a/backend/src/controllers/v2/secretController.ts
+++ b/backend/src/controllers/v2/secretController.ts
@@ -1,6 +1,5 @@
import { Request, Response } from "express";
import mongoose, { Types } from "mongoose";
-import Secret, { ISecret } from "../../models/secret";
import {
CreateSecretRequestBody,
ModifySecretRequestBody,
@@ -20,7 +19,7 @@ import {
SECRET_SHARED
} from "../../variables";
import { TelemetryService } from "../../services";
-import { User } from "../../models";
+import { ISecret, Secret, User } from "../../models";
import { AccountNotFoundError } from "../../utils/errors";
/**
diff --git a/backend/src/controllers/v2/secretsController.ts b/backend/src/controllers/v2/secretsController.ts
index b22bd63fe2..6c9b292032 100644
--- a/backend/src/controllers/v2/secretsController.ts
+++ b/backend/src/controllers/v2/secretsController.ts
@@ -1,6 +1,6 @@
import { Types } from "mongoose";
import { Request, Response } from "express";
-import { ISecret, Secret, ServiceTokenData } from "../../models";
+import { Folder, ISecret, Secret, ServiceTokenData, Tag } from "../../models";
import { AuditLog, EventType, IAction, SecretVersion } from "../../ee/models";
import {
ACTION_ADD_SECRETS,
@@ -24,10 +24,8 @@ import {
userHasWorkspaceAccess,
userHasWriteOnlyAbility
} from "../../ee/helpers/checkMembershipPermissions";
-import Tag from "../../models/tag";
import _ from "lodash";
import { BatchSecret, BatchSecretRequest } from "../../types/secret";
-import Folder from "../../models/folder";
import {
getFolderByPath,
getFolderIdFromServiceToken,
diff --git a/backend/src/controllers/v2/tagController.ts b/backend/src/controllers/v2/tagController.ts
index fa21fc971e..4a7e68bb76 100644
--- a/backend/src/controllers/v2/tagController.ts
+++ b/backend/src/controllers/v2/tagController.ts
@@ -1,7 +1,6 @@
import { Request, Response } from "express";
import { Types } from "mongoose";
-import { Membership, Secret } from "../../models";
-import Tag from "../../models/tag";
+import { Membership, Secret, Tag } from "../../models";
import { BadRequestError, UnauthorizedRequestError } from "../../utils/errors";
export const createWorkspaceTag = async (req: Request, res: Response) => {
diff --git a/backend/src/controllers/v3/secretsController.ts b/backend/src/controllers/v3/secretsController.ts
index ded996a4ab..4a57beba39 100644
--- a/backend/src/controllers/v3/secretsController.ts
+++ b/backend/src/controllers/v3/secretsController.ts
@@ -6,10 +6,9 @@ import { BotService } from "../../services";
import { containsGlobPatterns, repackageSecretToRaw } from "../../helpers/secrets";
import { encryptSymmetric128BitHexKeyUTF8 } from "../../utils/crypto";
import { getAllImportedSecrets } from "../../services/SecretImportService";
-import Folder from "../../models/folder";
+import { Folder, IServiceTokenData } from "../../models";
import { getFolderByPath } from "../../services/FolderService";
import { BadRequestError } from "../../utils/errors";
-import { IServiceTokenData } from "../../models";
import { requireWorkspaceAuth } from "../../middleware";
import { ADMIN, MEMBER, PERMISSION_READ_SECRETS } from "../../variables";
diff --git a/backend/src/ee/controllers/v1/workspaceController.ts b/backend/src/ee/controllers/v1/workspaceController.ts
index 9354c4f13d..1e21dd5918 100644
--- a/backend/src/ee/controllers/v1/workspaceController.ts
+++ b/backend/src/ee/controllers/v1/workspaceController.ts
@@ -1,6 +1,6 @@
import { Request, Response } from "express";
import { PipelineStage, Types } from "mongoose";
-import { Membership, Secret, ServiceTokenData, User } from "../../../models";
+import { Folder, Membership, Secret, ServiceTokenData, TFolderSchema, User } from "../../../models";
import {
ActorType,
AuditLog,
@@ -18,7 +18,7 @@ import {
} from "../../models";
import { EESecretService } from "../../services";
import { getLatestSecretVersionIds } from "../../helpers/secretVersion";
-import Folder, { TFolderSchema } from "../../../models/folder";
+// import Folder, { TFolderSchema } from "../../../models/folder";
import { searchByFolderId } from "../../../services/FolderService";
import { EEAuditLogService, EELicenseService } from "../../services";
import { extractIPDetails, isValidIpOrCidr } from "../../../utils/ip";
diff --git a/backend/src/helpers/bot.ts b/backend/src/helpers/bot.ts
index cf6d31e4fd..245fe11922 100644
--- a/backend/src/helpers/bot.ts
+++ b/backend/src/helpers/bot.ts
@@ -14,7 +14,7 @@ import {
} from "../variables";
import { client, getEncryptionKey, getRootEncryptionKey } from "../config";
import { InternalServerError } from "../utils/errors";
-import Folder from "../models/folder";
+import { Folder } from "../models";
import { getFolderByPath } from "../services/FolderService";
import { getAllImportedSecrets } from "../services/SecretImportService";
import { expandSecrets } from "./secrets";
diff --git a/backend/src/helpers/secrets.ts b/backend/src/helpers/secrets.ts
index c4d6c78710..e8c3419baf 100644
--- a/backend/src/helpers/secrets.ts
+++ b/backend/src/helpers/secrets.ts
@@ -7,11 +7,13 @@ import {
UpdateSecretParams
} from "../interfaces/services/SecretService";
import {
+ Folder,
ISecret,
IServiceTokenData,
Secret,
SecretBlindIndexData,
- ServiceTokenData
+ ServiceTokenData,
+ TFolderRootSchema
} from "../models";
import { EventType, SecretVersion } from "../ee/models";
import {
@@ -46,7 +48,6 @@ import { getAuthDataPayloadIdObj, getAuthDataPayloadUserObj } from "../utils/aut
import { getFolderByPath, getFolderIdFromServiceToken } from "../services/FolderService";
import picomatch from "picomatch";
import path from "path";
-import Folder, { TFolderRootSchema } from "../models/folder";
export const isValidScope = (
authPayload: IServiceTokenData,
diff --git a/backend/src/integrations/sync.ts b/backend/src/integrations/sync.ts
index c0aca40566..89d8ba0e6c 100644
--- a/backend/src/integrations/sync.ts
+++ b/backend/src/integrations/sync.ts
@@ -2004,7 +2004,7 @@ const syncSecretsCheckly = async ({
secrets: Record<string, { value: string; comment?: string }>;
accessToken: string;
}) => {
- // get secrets from travis-ci
+
const getSecretsRes = (
await standardRequest.get(`${INTEGRATION_CHECKLY_API_URL}/v1/variables`, {
headers: {
@@ -2026,7 +2026,6 @@ const syncSecretsCheckly = async ({
if (!(key in getSecretsRes)) {
// case: secret does not exist in checkly
// -> add secret
-
await standardRequest.post(
`${INTEGRATION_CHECKLY_API_URL}/v1/variables`,
{
@@ -2066,7 +2065,7 @@ const syncSecretsCheckly = async ({
}
for await (const key of Object.keys(getSecretsRes)) {
- if (!(key in secrets) && key.endsWith(integration?.secretSuffix)) {
+ if (!(key in secrets)) {
// delete secret
await standardRequest.delete(`${INTEGRATION_CHECKLY_API_URL}/v1/variables/${key}`, {
headers: {
diff --git a/backend/src/models/apiKeyData.ts b/backend/src/models/apiKeyData.ts
index 622e62be17..0b88c5ddb5 100644
--- a/backend/src/models/apiKeyData.ts
+++ b/backend/src/models/apiKeyData.ts
@@ -36,6 +36,4 @@ const apiKeyDataSchema = new Schema<IAPIKeyData>(
}
);
-const APIKeyData = model<IAPIKeyData>("APIKeyData", apiKeyDataSchema);
-
-export default APIKeyData;
+export const APIKeyData = model<IAPIKeyData>("APIKeyData", apiKeyDataSchema);
\ No newline at end of file
diff --git a/backend/src/models/backupPrivateKey.ts b/backend/src/models/backupPrivateKey.ts
index 01f0dae218..09df1dda79 100644
--- a/backend/src/models/backupPrivateKey.ts
+++ b/backend/src/models/backupPrivateKey.ts
@@ -68,9 +68,7 @@ const backupPrivateKeySchema = new Schema<IBackupPrivateKey>(
}
);
-const BackupPrivateKey = model<IBackupPrivateKey>(
+export const BackupPrivateKey = model<IBackupPrivateKey>(
"BackupPrivateKey",
backupPrivateKeySchema
);
-
-export default BackupPrivateKey;
diff --git a/backend/src/models/bot.ts b/backend/src/models/bot.ts
index 96107a2317..5a5c83b135 100644
--- a/backend/src/models/bot.ts
+++ b/backend/src/models/bot.ts
@@ -74,6 +74,4 @@ const botSchema = new Schema<IBot>(
}
);
-const Bot = model<IBot>("Bot", botSchema);
-
-export default Bot;
+export const Bot = model<IBot>("Bot", botSchema);
\ No newline at end of file
diff --git a/backend/src/models/botKey.ts b/backend/src/models/botKey.ts
index b7be364dd9..02a6d6ea95 100644
--- a/backend/src/models/botKey.ts
+++ b/backend/src/models/botKey.ts
@@ -40,6 +40,4 @@ const botKeySchema = new Schema<IBotKey>(
}
);
-const BotKey = model<IBotKey>("BotKey", botKeySchema);
-
-export default BotKey;
+export const BotKey = model<IBotKey>("BotKey", botKeySchema);
\ No newline at end of file
diff --git a/backend/src/models/botOrg.ts b/backend/src/models/botOrg.ts
index f7d3cd3ae1..177294ef9e 100644
--- a/backend/src/models/botOrg.ts
+++ b/backend/src/models/botOrg.ts
@@ -93,6 +93,4 @@ const botOrgSchema = new Schema<IBotOrg>(
}
);
-const BotOrg = model<IBotOrg>("BotOrg", botOrgSchema);
-
-export default BotOrg;
+export const BotOrg = model<IBotOrg>("BotOrg", botOrgSchema);
\ No newline at end of file
diff --git a/backend/src/models/folder.ts b/backend/src/models/folder.ts
index 46f532c7d7..b3016822dc 100644
--- a/backend/src/models/folder.ts
+++ b/backend/src/models/folder.ts
@@ -51,6 +51,4 @@ const folderRootSchema = new Schema<TFolderRootSchema>(
}
);
-const Folder = model<TFolderRootSchema>("Folder", folderRootSchema);
-
-export default Folder;
+export const Folder = model<TFolderRootSchema>("Folder", folderRootSchema);
\ No newline at end of file
diff --git a/backend/src/models/incidentContactOrg.ts b/backend/src/models/incidentContactOrg.ts
index 16e5e4f025..905b9263f4 100644
--- a/backend/src/models/incidentContactOrg.ts
+++ b/backend/src/models/incidentContactOrg.ts
@@ -23,9 +23,7 @@ const incidentContactOrgSchema = new Schema<IIncidentContactOrg>(
}
);
-const IncidentContactOrg = model<IIncidentContactOrg>(
+export const IncidentContactOrg = model<IIncidentContactOrg>(
"IncidentContactOrg",
incidentContactOrgSchema
-);
-
-export default IncidentContactOrg;
+);
\ No newline at end of file
diff --git a/backend/src/models/index.ts b/backend/src/models/index.ts
index e588364ee3..7a431592b3 100644
--- a/backend/src/models/index.ts
+++ b/backend/src/models/index.ts
@@ -1,89 +1,30 @@
-import BackupPrivateKey, { IBackupPrivateKey } from "./backupPrivateKey";
-import Bot, { IBot } from "./bot";
-import BotOrg, { IBotOrg } from "./botOrg";
-import BotKey, { IBotKey } from "./botKey";
-import IncidentContactOrg, { IIncidentContactOrg } from "./incidentContactOrg";
-import Integration, { IIntegration } from "./integration";
-import IntegrationAuth, { IIntegrationAuth } from "./integrationAuth";
-import Key, { IKey } from "./key";
-import Membership, { IMembership } from "./membership";
-import MembershipOrg, { IMembershipOrg } from "./membershipOrg";
-import Organization, { IOrganization } from "./organization";
-import Secret, { ISecret } from "./secret";
-import Folder, { TFolderRootSchema, TFolderSchema } from "./folder";
-import SecretImport, { ISecretImports } from "./secretImports";
-import SecretBlindIndexData, { ISecretBlindIndexData } from "./secretBlindIndexData";
-import ServiceToken, { IServiceToken } from "./serviceToken";
-import ServiceAccount, { IServiceAccount } from "./serviceAccount"; // new
-import ServiceAccountKey, { IServiceAccountKey } from "./serviceAccountKey"; // new
-import ServiceAccountOrganizationPermission, { IServiceAccountOrganizationPermission } from "./serviceAccountOrganizationPermission"; // new
-import ServiceAccountWorkspacePermission, { IServiceAccountWorkspacePermission } from "./serviceAccountWorkspacePermission"; // new
-import TokenData, { ITokenData } from "./tokenData";
-import User, { AuthMethod, IUser } from "./user";
-import UserAction, { IUserAction } from "./userAction";
-import Workspace, { IWorkspace } from "./workspace";
-import ServiceTokenData, { IServiceTokenData } from "./serviceTokenData";
-import APIKeyData, { IAPIKeyData } from "./apiKeyData";
-import LoginSRPDetail, { ILoginSRPDetail } from "./loginSRPDetail";
-import TokenVersion, { ITokenVersion } from "./tokenVersion";
-
-export {
- AuthMethod,
- BackupPrivateKey,
- IBackupPrivateKey,
- Bot,
- IBot,
- BotOrg,
- IBotOrg,
- BotKey,
- IBotKey,
- IncidentContactOrg,
- IIncidentContactOrg,
- Integration,
- IIntegration,
- IntegrationAuth,
- IIntegrationAuth,
- Key,
- IKey,
- Membership,
- IMembership,
- MembershipOrg,
- IMembershipOrg,
- Organization,
- IOrganization,
- Secret,
- ISecret,
- Folder,
- TFolderRootSchema,
- TFolderSchema,
- SecretImport,
- ISecretImports,
- SecretBlindIndexData,
- ISecretBlindIndexData,
- ServiceToken,
- IServiceToken,
- ServiceAccount,
- IServiceAccount,
- ServiceAccountKey,
- IServiceAccountKey,
- ServiceAccountOrganizationPermission,
- IServiceAccountOrganizationPermission,
- ServiceAccountWorkspacePermission,
- IServiceAccountWorkspacePermission,
- TokenData,
- ITokenData,
- User,
- IUser,
- UserAction,
- IUserAction,
- Workspace,
- IWorkspace,
- ServiceTokenData,
- IServiceTokenData,
- APIKeyData,
- IAPIKeyData,
- LoginSRPDetail,
- ILoginSRPDetail,
- TokenVersion,
- ITokenVersion
-};
+export * from "./backupPrivateKey";
+export * from "./bot";
+export * from "./botOrg";
+export * from "./botKey";
+export * from "./incidentContactOrg";
+export * from "./integration/integration";
+export * from "./integrationAuth";
+export * from "./key";
+export * from "./membership";
+export * from "./membershipOrg";
+export * from "./organization";
+export * from "./secret";
+export * from "./tag";
+export * from "./folder";
+export * from "./secretImports";
+export * from "./secretBlindIndexData";
+export * from "./serviceToken";
+export * from "./serviceAccount";
+export * from "./serviceAccountKey";
+export * from "./serviceAccountOrganizationPermission";
+export * from "./serviceAccountWorkspacePermission";
+export * from "./tokenData";
+export * from "./user";
+export * from "./userAction";
+export * from "./workspace";
+export * from "./serviceTokenData";
+export * from "./apiKeyData";
+export * from "./loginSRPDetail";
+export * from "./tokenVersion";
+export * from "./webhooks";
\ No newline at end of file
diff --git a/backend/src/models/integration/index.ts b/backend/src/models/integration/index.ts
new file mode 100644
index 0000000000..2ed44cd28c
--- /dev/null
+++ b/backend/src/models/integration/index.ts
@@ -0,0 +1 @@
+export * from "./integration";
\ No newline at end of file
diff --git a/backend/src/models/integration.ts b/backend/src/models/integration/integration.ts
similarity index 94%
rename from backend/src/models/integration.ts
rename to backend/src/models/integration/integration.ts
index 6c4bf7b13b..7a7775bac2 100644
--- a/backend/src/models/integration.ts
+++ b/backend/src/models/integration/integration.ts
@@ -26,8 +26,9 @@ import {
INTEGRATION_TRAVISCI,
INTEGRATION_VERCEL,
INTEGRATION_WINDMILL
-} from "../variables";
+} from "../../variables";
import { Schema, Types, model } from "mongoose";
+import { Metadata } from "./types";
export interface IIntegration {
_id: Types.ObjectId;
@@ -45,7 +46,6 @@ export interface IIntegration {
path: string;
region: string;
secretPath: string;
- secretSuffix: string;
integration:
| "azure-key-vault"
| "aws-parameter-store"
@@ -75,6 +75,7 @@ export interface IIntegration {
| "windmill"
| "gcp-secret-manager";
integrationAuth: Types.ObjectId;
+ metadata: Metadata;
}
const integrationSchema = new Schema<IIntegration>(
@@ -185,10 +186,8 @@ const integrationSchema = new Schema<IIntegration>(
required: true,
default: "/",
},
- secretSuffix: {
- type: String,
- required: false,
- default: "",
+ metadata: {
+ type: Schema.Types.Mixed
}
},
{
@@ -196,6 +195,4 @@ const integrationSchema = new Schema<IIntegration>(
}
);
-const Integration = model<IIntegration>("Integration", integrationSchema);
-
-export default Integration;
+export const Integration = model<IIntegration>("Integration", integrationSchema);
\ No newline at end of file
diff --git a/backend/src/models/integration/types.ts b/backend/src/models/integration/types.ts
new file mode 100644
index 0000000000..0415a9556b
--- /dev/null
+++ b/backend/src/models/integration/types.ts
@@ -0,0 +1,3 @@
+export type Metadata = {
+ secretSuffix?: string;
+}
\ No newline at end of file
diff --git a/backend/src/models/integrationAuth.ts b/backend/src/models/integrationAuth.ts
index 5b05c22426..5dcd3dfe85 100644
--- a/backend/src/models/integrationAuth.ts
+++ b/backend/src/models/integrationAuth.ts
@@ -193,9 +193,7 @@ const integrationAuthSchema = new Schema<IIntegrationAuth>(
}
);
-const IntegrationAuth = model<IIntegrationAuth>(
+export const IntegrationAuth = model<IIntegrationAuth>(
"IntegrationAuth",
integrationAuthSchema
-);
-
-export default IntegrationAuth;
+);
\ No newline at end of file
diff --git a/backend/src/models/key.ts b/backend/src/models/key.ts
index faa37cd869..fcc6e6f60c 100644
--- a/backend/src/models/key.ts
+++ b/backend/src/models/key.ts
@@ -40,6 +40,4 @@ const keySchema = new Schema<IKey>(
}
);
-const Key = model<IKey>("Key", keySchema);
-
-export default Key;
+export const Key = model<IKey>("Key", keySchema);
\ No newline at end of file
diff --git a/backend/src/models/loginSRPDetail.ts b/backend/src/models/loginSRPDetail.ts
index 8e9e121c51..26f8972704 100644
--- a/backend/src/models/loginSRPDetail.ts
+++ b/backend/src/models/loginSRPDetail.ts
@@ -24,6 +24,4 @@ const loginSRPDetailSchema = new Schema<ILoginSRPDetail>(
}
);
-const LoginSRPDetail = model("LoginSRPDetail", loginSRPDetailSchema);
-
-export default LoginSRPDetail;
+export const LoginSRPDetail = model("LoginSRPDetail", loginSRPDetailSchema);
\ No newline at end of file
diff --git a/backend/src/models/membership.ts b/backend/src/models/membership.ts
index 0fca743b4c..6c32ff64f8 100644
--- a/backend/src/models/membership.ts
+++ b/backend/src/models/membership.ts
@@ -52,6 +52,4 @@ const membershipSchema = new Schema<IMembership>(
}
);
-const Membership = model<IMembership>("Membership", membershipSchema);
-
-export default Membership;
+export const Membership = model<IMembership>("Membership", membershipSchema);
\ No newline at end of file
diff --git a/backend/src/models/membershipOrg.ts b/backend/src/models/membershipOrg.ts
index 74a09b8050..b45f9cfe82 100644
--- a/backend/src/models/membershipOrg.ts
+++ b/backend/src/models/membershipOrg.ts
@@ -39,9 +39,7 @@ const membershipOrgSchema = new Schema(
}
);
-const MembershipOrg = model<IMembershipOrg>(
+export const MembershipOrg = model<IMembershipOrg>(
"MembershipOrg",
membershipOrgSchema
-);
-
-export default MembershipOrg;
+);
\ No newline at end of file
diff --git a/backend/src/models/organization.ts b/backend/src/models/organization.ts
index bafcc05f8a..1ae3bcb452 100644
--- a/backend/src/models/organization.ts
+++ b/backend/src/models/organization.ts
@@ -21,6 +21,4 @@ const organizationSchema = new Schema<IOrganization>(
}
);
-const Organization = model<IOrganization>("Organization", organizationSchema);
-
-export default Organization;
+export const Organization = model<IOrganization>("Organization", organizationSchema);
\ No newline at end of file
diff --git a/backend/src/models/secret.ts b/backend/src/models/secret.ts
index 4ef3de456b..b7d7c266df 100644
--- a/backend/src/models/secret.ts
+++ b/backend/src/models/secret.ts
@@ -145,6 +145,4 @@ const secretSchema = new Schema<ISecret>(
secretSchema.index({ tags: 1 }, { background: true });
-const Secret = model<ISecret>("Secret", secretSchema);
-
-export default Secret;
+export const Secret = model<ISecret>("Secret", secretSchema);
\ No newline at end of file
diff --git a/backend/src/models/secretApprovalRequest.ts b/backend/src/models/secretApprovalRequest.ts
index 008274dd95..910ca9135f 100644
--- a/backend/src/models/secretApprovalRequest.ts
+++ b/backend/src/models/secretApprovalRequest.ts
@@ -1,5 +1,5 @@
import mongoose, { Schema, model } from "mongoose";
-import Secret, { ISecret } from "./secret";
+import { ISecret, Secret } from "./secret";
interface ISecretApprovalRequest {
secret: mongoose.Types.ObjectId;
@@ -78,6 +78,4 @@ const secretApprovalRequestSchema = new Schema<ISecretApprovalRequest>(
}
);
-const SecretApprovalRequest = model<ISecretApprovalRequest>("SecretApprovalRequest", secretApprovalRequestSchema);
-
-export default SecretApprovalRequest;
+export const SecretApprovalRequest = model<ISecretApprovalRequest>("SecretApprovalRequest", secretApprovalRequestSchema);
\ No newline at end of file
diff --git a/backend/src/models/secretBlindIndexData.ts b/backend/src/models/secretBlindIndexData.ts
index ca277d19e3..5d0cd976a6 100644
--- a/backend/src/models/secretBlindIndexData.ts
+++ b/backend/src/models/secretBlindIndexData.ts
@@ -53,6 +53,4 @@ const secretBlindIndexDataSchema = new Schema<ISecretBlindIndexData>(
}
);
-const SecretBlindIndexData = model<ISecretBlindIndexData>("SecretBlindIndexData", secretBlindIndexDataSchema);
-
-export default SecretBlindIndexData;
\ No newline at end of file
+export const SecretBlindIndexData = model<ISecretBlindIndexData>("SecretBlindIndexData", secretBlindIndexDataSchema);
\ No newline at end of file
diff --git a/backend/src/models/secretImports.ts b/backend/src/models/secretImports.ts
index 0041abc292..79046a4895 100644
--- a/backend/src/models/secretImports.ts
+++ b/backend/src/models/secretImports.ts
@@ -48,5 +48,4 @@ const secretImportSchema = new Schema<ISecretImports>(
}
);
-const SecretImport = model<ISecretImports>("SecretImports", secretImportSchema);
-export default SecretImport;
+export const SecretImport = model<ISecretImports>("SecretImports", secretImportSchema);
\ No newline at end of file
diff --git a/backend/src/models/serviceAccount.ts b/backend/src/models/serviceAccount.ts
index 090d55c214..75ae157c62 100644
--- a/backend/src/models/serviceAccount.ts
+++ b/backend/src/models/serviceAccount.ts
@@ -48,6 +48,4 @@ const serviceAccountSchema = new Schema<IServiceAccount>(
}
);
-const ServiceAccount = model<IServiceAccount>("ServiceAccount", serviceAccountSchema);
-
-export default ServiceAccount;
\ No newline at end of file
+export const ServiceAccount = model<IServiceAccount>("ServiceAccount", serviceAccountSchema);
\ No newline at end of file
diff --git a/backend/src/models/serviceAccountKey.ts b/backend/src/models/serviceAccountKey.ts
index d442dcb082..538e391034 100644
--- a/backend/src/models/serviceAccountKey.ts
+++ b/backend/src/models/serviceAccountKey.ts
@@ -39,6 +39,4 @@ const serviceAccountKeySchema = new Schema<IServiceAccountKey>(
}
);
-const ServiceAccountKey = model<IServiceAccountKey>("ServiceAccountKey", serviceAccountKeySchema);
-
-export default ServiceAccountKey;
+export const ServiceAccountKey = model<IServiceAccountKey>("ServiceAccountKey", serviceAccountKeySchema);
\ No newline at end of file
diff --git a/backend/src/models/serviceAccountOrganizationPermission.ts b/backend/src/models/serviceAccountOrganizationPermission.ts
index 4519bd8322..970ec7461b 100644
--- a/backend/src/models/serviceAccountOrganizationPermission.ts
+++ b/backend/src/models/serviceAccountOrganizationPermission.ts
@@ -18,6 +18,4 @@ const serviceAccountOrganizationPermissionSchema = new Schema<IServiceAccountOrg
}
);
-const ServiceAccountOrganizationPermission = model<IServiceAccountOrganizationPermission>("ServiceAccountOrganizationPermission", serviceAccountOrganizationPermissionSchema);
-
-export default ServiceAccountOrganizationPermission;
\ No newline at end of file
+export const ServiceAccountOrganizationPermission = model<IServiceAccountOrganizationPermission>("ServiceAccountOrganizationPermission", serviceAccountOrganizationPermissionSchema);
\ No newline at end of file
diff --git a/backend/src/models/serviceAccountWorkspacePermission.ts b/backend/src/models/serviceAccountWorkspacePermission.ts
index 5814923e57..1d35237663 100644
--- a/backend/src/models/serviceAccountWorkspacePermission.ts
+++ b/backend/src/models/serviceAccountWorkspacePermission.ts
@@ -39,6 +39,4 @@ const serviceAccountWorkspacePermissionSchema = new Schema<IServiceAccountWorksp
}
);
-const ServiceAccountWorkspacePermission = model<IServiceAccountWorkspacePermission>("ServiceAccountWorkspacePermission", serviceAccountWorkspacePermissionSchema);
-
-export default ServiceAccountWorkspacePermission;
\ No newline at end of file
+export const ServiceAccountWorkspacePermission = model<IServiceAccountWorkspacePermission>("ServiceAccountWorkspacePermission", serviceAccountWorkspacePermissionSchema);
\ No newline at end of file
diff --git a/backend/src/models/serviceToken.ts b/backend/src/models/serviceToken.ts
index ce5fa3c9be..4734a50e29 100644
--- a/backend/src/models/serviceToken.ts
+++ b/backend/src/models/serviceToken.ts
@@ -56,6 +56,4 @@ const serviceTokenSchema = new Schema<IServiceToken>(
}
);
-const ServiceToken = model<IServiceToken>("ServiceToken", serviceTokenSchema);
-
-export default ServiceToken;
+export const ServiceToken = model<IServiceToken>("ServiceToken", serviceTokenSchema);
\ No newline at end of file
diff --git a/backend/src/models/serviceTokenData.ts b/backend/src/models/serviceTokenData.ts
index 804184386a..ea7d00eaad 100644
--- a/backend/src/models/serviceTokenData.ts
+++ b/backend/src/models/serviceTokenData.ts
@@ -89,6 +89,4 @@ const serviceTokenDataSchema = new Schema<IServiceTokenData>(
}
);
-const ServiceTokenData = model<IServiceTokenData>("ServiceTokenData", serviceTokenDataSchema);
-
-export default ServiceTokenData;
+export const ServiceTokenData = model<IServiceTokenData>("ServiceTokenData", serviceTokenDataSchema);
\ No newline at end of file
diff --git a/backend/src/models/tag.ts b/backend/src/models/tag.ts
index ec649e254a..a5f0bd307b 100644
--- a/backend/src/models/tag.ts
+++ b/backend/src/models/tag.ts
@@ -50,6 +50,4 @@ const tagSchema = new Schema<ITag>(
tagSchema.index({ slug: 1, workspace: 1 }, { unique: true })
tagSchema.index({ workspace: 1 })
-const Tag = model<ITag>("Tag", tagSchema);
-
-export default Tag;
+export const Tag = model<ITag>("Tag", tagSchema);
\ No newline at end of file
diff --git a/backend/src/models/token.ts b/backend/src/models/token.ts
index ab0a69c9e0..62d342b0a1 100644
--- a/backend/src/models/token.ts
+++ b/backend/src/models/token.ts
@@ -27,6 +27,4 @@ const tokenSchema = new Schema<IToken>({
tokenSchema.index({ email: 1 });
-const Token = model<IToken>("Token", tokenSchema);
-
-export default Token;
+export const Token = model<IToken>("Token", tokenSchema);
\ No newline at end of file
diff --git a/backend/src/models/tokenData.ts b/backend/src/models/tokenData.ts
index 615c9019d8..2544c05f1a 100644
--- a/backend/src/models/tokenData.ts
+++ b/backend/src/models/tokenData.ts
@@ -50,6 +50,4 @@ const tokenDataSchema = new Schema<ITokenData>({
timestamps: true,
});
-const TokenData = model<ITokenData>("TokenData", tokenDataSchema);
-
-export default TokenData;
+export const TokenData = model<ITokenData>("TokenData", tokenDataSchema);
\ No newline at end of file
diff --git a/backend/src/models/tokenVersion.ts b/backend/src/models/tokenVersion.ts
index 1103fc3169..b162e019eb 100644
--- a/backend/src/models/tokenVersion.ts
+++ b/backend/src/models/tokenVersion.ts
@@ -42,6 +42,4 @@ const tokenVersionSchema = new Schema<ITokenVersion>(
}
);
-const TokenVersion = model<ITokenVersion>("TokenVersion", tokenVersionSchema);
-
-export default TokenVersion;
\ No newline at end of file
+export const TokenVersion = model<ITokenVersion>("TokenVersion", tokenVersionSchema);
\ No newline at end of file
diff --git a/backend/src/models/user.ts b/backend/src/models/user.ts
index 10139c85eb..c85c0936bf 100644
--- a/backend/src/models/user.ts
+++ b/backend/src/models/user.ts
@@ -121,6 +121,4 @@ const userSchema = new Schema<IUser>(
}
);
-const User = model<IUser>("User", userSchema);
-
-export default User;
+export const User = model<IUser>("User", userSchema);
\ No newline at end of file
diff --git a/backend/src/models/userAction.ts b/backend/src/models/userAction.ts
index 11eda05e86..68fae22be0 100644
--- a/backend/src/models/userAction.ts
+++ b/backend/src/models/userAction.ts
@@ -23,6 +23,4 @@ const userActionSchema = new Schema<IUserAction>(
}
);
-const UserAction = model<IUserAction>("UserAction", userActionSchema);
-
-export default UserAction;
+export const UserAction = model<IUserAction>("UserAction", userActionSchema);
\ No newline at end of file
diff --git a/backend/src/models/webhooks.ts b/backend/src/models/webhooks.ts
index b4a168878f..845c6ada2f 100644
--- a/backend/src/models/webhooks.ts
+++ b/backend/src/models/webhooks.ts
@@ -80,6 +80,4 @@ const WebhookSchema = new Schema<IWebhook>(
}
);
-const Webhook = model<IWebhook>("Webhook", WebhookSchema);
-
-export default Webhook;
+export const Webhook = model<IWebhook>("Webhook", WebhookSchema);
\ No newline at end of file
diff --git a/backend/src/models/workspace.ts b/backend/src/models/workspace.ts
index b3dd28b00a..9d7a19fcc9 100644
--- a/backend/src/models/workspace.ts
+++ b/backend/src/models/workspace.ts
@@ -49,6 +49,4 @@ const workspaceSchema = new Schema<IWorkspace>({
},
});
-const Workspace = model<IWorkspace>("Workspace", workspaceSchema);
-
-export default Workspace;
\ No newline at end of file
+export const Workspace = model<IWorkspace>("Workspace", workspaceSchema);
\ No newline at end of file
diff --git a/backend/src/queues/integrations/syncSecretsToThirdPartyServices.ts b/backend/src/queues/integrations/syncSecretsToThirdPartyServices.ts
index f9675fa45d..3b5e04a3ca 100644
--- a/backend/src/queues/integrations/syncSecretsToThirdPartyServices.ts
+++ b/backend/src/queues/integrations/syncSecretsToThirdPartyServices.ts
@@ -1,6 +1,5 @@
import Queue, { Job } from "bull";
-import Integration from "../../models/integration";
-import IntegrationAuth from "../../models/integrationAuth";
+import { Integration, IntegrationAuth } from "../../models";
import { BotService } from "../../services";
import { getIntegrationAuthAccessHelper } from "../../helpers";
import { syncSecrets } from "../../integrations/sync"
@@ -37,9 +36,9 @@ syncSecretsToThirdPartyServices.process(async (job: Job) => {
});
const suffixedSecrets: any = {};
- if (integration?.secretSuffix) {
+ if (integration.metadata?.secretSuffix) {
for (const key in secrets) {
- const newKey = key + integration?.secretSuffix;
+ const newKey = key + integration.metadata?.secretSuffix;
suffixedSecrets[newKey] = secrets[key];
}
}
diff --git a/backend/src/routes/v1/integration.ts b/backend/src/routes/v1/integration.ts
index d5709dcc39..a5d32349e3 100644
--- a/backend/src/routes/v1/integration.ts
+++ b/backend/src/routes/v1/integration.ts
@@ -29,7 +29,6 @@ router.post(
body("isActive").exists().isBoolean(),
body("appId").trim(),
body("secretPath").default("/").isString().trim(),
- body("secretSuffix").default("").isString().trim(),
body("sourceEnvironment").trim(),
body("targetEnvironment").trim(),
body("targetEnvironmentId").trim(),
@@ -38,6 +37,8 @@ router.post(
body("owner").trim(),
body("path").trim(),
body("region").trim(),
+ body("metadata").optional().isObject().withMessage("Metadata should be an object"),
+ body("metadata.secretSuffix").optional().isString().withMessage("Suffix should be a string"),
validateRequest,
integrationController.createIntegration
);
diff --git a/backend/src/services/FolderService.ts b/backend/src/services/FolderService.ts
index 81f169f4b3..cb4ef42867 100644
--- a/backend/src/services/FolderService.ts
+++ b/backend/src/services/FolderService.ts
@@ -1,6 +1,6 @@
import { nanoid } from "nanoid";
import { Types } from "mongoose";
-import Folder, { TFolderSchema } from "../models/folder";
+import { Folder, TFolderSchema } from "../models";
import path from "path";
type TAppendFolderDTO = {
diff --git a/backend/src/services/SecretImportService.ts b/backend/src/services/SecretImportService.ts
index 8892cdb316..d4442b8351 100644
--- a/backend/src/services/SecretImportService.ts
+++ b/backend/src/services/SecretImportService.ts
@@ -1,7 +1,10 @@
import { Types } from "mongoose";
-import Folder from "../models/folder";
-import Secret, { ISecret } from "../models/secret";
-import SecretImport from "../models/secretImports";
+import {
+ Folder,
+ ISecret,
+ Secret,
+ SecretImport
+} from "../models";
import { getFolderByPath } from "./FolderService";
type TSecretImportFid = { environment: string; folderId: string; secretPath: string };
diff --git a/backend/src/services/WebhookService.ts b/backend/src/services/WebhookService.ts
index c66f44e47c..7506e25c10 100644
--- a/backend/src/services/WebhookService.ts
+++ b/backend/src/services/WebhookService.ts
@@ -3,7 +3,7 @@ import crypto from "crypto";
import { Types } from "mongoose";
import picomatch from "picomatch";
import { client, getRootEncryptionKey } from "../config";
-import Webhook, { IWebhook } from "../models/webhooks";
+import { IWebhook, Webhook } from "../models";
export const triggerWebhookRequest = async (
{ url, encryptedSecretKey, iv, tag }: IWebhook,
diff --git a/frontend/src/hooks/api/integrations/queries.tsx b/frontend/src/hooks/api/integrations/queries.tsx
index 3e1882f6e9..6e7b65eed4 100644
--- a/frontend/src/hooks/api/integrations/queries.tsx
+++ b/frontend/src/hooks/api/integrations/queries.tsx
@@ -41,7 +41,7 @@ export const useCreateIntegration = () => {
path,
region,
secretPath,
- secretSuffix
+ metadata
}: {
integrationAuthId: string;
isActive: boolean;
@@ -56,7 +56,9 @@ export const useCreateIntegration = () => {
owner: string | null;
path: string | null;
region: string | null;
- secretSuffix: string;
+ metadata?: {
+ secretSuffix?: string;
+ }
}) => {
const { data: { integration } } = await apiRequest.post("/api/v1/integration", {
integrationAuthId,
@@ -72,7 +74,7 @@ export const useCreateIntegration = () => {
path,
region,
secretPath,
- secretSuffix
+ metadata
});
return integration;
diff --git a/frontend/src/hooks/api/integrations/types.ts b/frontend/src/hooks/api/integrations/types.ts
index 89dbfea66e..199d029750 100644
--- a/frontend/src/hooks/api/integrations/types.ts
+++ b/frontend/src/hooks/api/integrations/types.ts
@@ -27,8 +27,10 @@ export type TIntegration = {
integration: string;
integrationAuth: string;
secretPath: string;
- secretSuffix: string;
createdAt: string;
updatedAt: string;
__v: number;
+ metadata?: {
+ secretSuffix?: string;
+ }
};
diff --git a/frontend/src/pages/integrations/checkly/create.tsx b/frontend/src/pages/integrations/checkly/create.tsx
index 92d6ae3237..6b3febfb85 100644
--- a/frontend/src/pages/integrations/checkly/create.tsx
+++ b/frontend/src/pages/integrations/checkly/create.tsx
@@ -80,7 +80,9 @@ export default function ChecklyCreateIntegrationPage() {
path: null,
region: null,
secretPath,
- secretSuffix
+ metadata: {
+ secretSuffix
+ }
});
setIsLoading(false);
diff --git a/frontend/src/views/IntegrationsPage/components/IntegrationsSection/IntegrationsSection.tsx b/frontend/src/views/IntegrationsPage/components/IntegrationsSection/IntegrationsSection.tsx
index 3c51fcbb86..72533796d0 100644
--- a/frontend/src/views/IntegrationsPage/components/IntegrationsSection/IntegrationsSection.tsx
+++ b/frontend/src/views/IntegrationsPage/components/IntegrationsSection/IntegrationsSection.tsx
@@ -119,7 +119,7 @@ export const IntegrationsSection = ({
<div className="ml-2 flex flex-col">
<FormLabel label="Secret Suffix" />
<div className="rounded-md border border-mineshaft-700 bg-mineshaft-900 px-3 py-2 font-inter text-sm text-bunker-200">
- {integration.secretSuffix || "-"}
+ {integration?.metadata?.secretSuffix || "-"}
</div>
</div>
)}