diff --git a/backend/src/controllers/v1/integrationController.ts b/backend/src/controllers/v1/integrationController.ts index e5f6e7393..84d00f6bb 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"; @@ -30,7 +29,8 @@ export const createIntegration = async (req: Request, res: Response) => { owner, path, region, - secretPath + secretPath, + metadata } = req.body; const folders = await Folder.findOne({ @@ -65,7 +65,8 @@ export const createIntegration = async (req: Request, res: Response) => { region, secretPath, 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 76b4945bd..23be98096 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 46d4c3c1f..cbc642592 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 a79b794cf..7e84aae87 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 5581a2ac7..bd36d6ab4 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 b22bd63fe..6c9b29203 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 fa21fc971..4a7e68bb7 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 ded996a4a..4a57beba3 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 9354c4f13..1e21dd591 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 cf6d31e4f..245fe1192 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 c4d6c7871..e8c3419ba 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 1803a37bb..89d8ba0e6 100644 --- a/backend/src/integrations/sync.ts +++ b/backend/src/integrations/sync.ts @@ -2004,7 +2004,7 @@ const syncSecretsCheckly = async ({ secrets: Record; 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`, { diff --git a/backend/src/models/apiKeyData.ts b/backend/src/models/apiKeyData.ts index 622e62be1..0b88c5ddb 100644 --- a/backend/src/models/apiKeyData.ts +++ b/backend/src/models/apiKeyData.ts @@ -36,6 +36,4 @@ const apiKeyDataSchema = new Schema( } ); -const APIKeyData = model("APIKeyData", apiKeyDataSchema); - -export default APIKeyData; +export const APIKeyData = model("APIKeyData", apiKeyDataSchema); \ No newline at end of file diff --git a/backend/src/models/backupPrivateKey.ts b/backend/src/models/backupPrivateKey.ts index 01f0dae21..09df1dda7 100644 --- a/backend/src/models/backupPrivateKey.ts +++ b/backend/src/models/backupPrivateKey.ts @@ -68,9 +68,7 @@ const backupPrivateKeySchema = new Schema( } ); -const BackupPrivateKey = model( +export const BackupPrivateKey = model( "BackupPrivateKey", backupPrivateKeySchema ); - -export default BackupPrivateKey; diff --git a/backend/src/models/bot.ts b/backend/src/models/bot.ts index 96107a231..5a5c83b13 100644 --- a/backend/src/models/bot.ts +++ b/backend/src/models/bot.ts @@ -74,6 +74,4 @@ const botSchema = new Schema( } ); -const Bot = model("Bot", botSchema); - -export default Bot; +export const Bot = model("Bot", botSchema); \ No newline at end of file diff --git a/backend/src/models/botKey.ts b/backend/src/models/botKey.ts index b7be364dd..02a6d6ea9 100644 --- a/backend/src/models/botKey.ts +++ b/backend/src/models/botKey.ts @@ -40,6 +40,4 @@ const botKeySchema = new Schema( } ); -const BotKey = model("BotKey", botKeySchema); - -export default BotKey; +export const BotKey = model("BotKey", botKeySchema); \ No newline at end of file diff --git a/backend/src/models/botOrg.ts b/backend/src/models/botOrg.ts index f7d3cd3ae..177294ef9 100644 --- a/backend/src/models/botOrg.ts +++ b/backend/src/models/botOrg.ts @@ -93,6 +93,4 @@ const botOrgSchema = new Schema( } ); -const BotOrg = model("BotOrg", botOrgSchema); - -export default BotOrg; +export const BotOrg = model("BotOrg", botOrgSchema); \ No newline at end of file diff --git a/backend/src/models/folder.ts b/backend/src/models/folder.ts index 46f532c7d..b3016822d 100644 --- a/backend/src/models/folder.ts +++ b/backend/src/models/folder.ts @@ -51,6 +51,4 @@ const folderRootSchema = new Schema( } ); -const Folder = model("Folder", folderRootSchema); - -export default Folder; +export const Folder = model("Folder", folderRootSchema); \ No newline at end of file diff --git a/backend/src/models/incidentContactOrg.ts b/backend/src/models/incidentContactOrg.ts index 16e5e4f02..905b9263f 100644 --- a/backend/src/models/incidentContactOrg.ts +++ b/backend/src/models/incidentContactOrg.ts @@ -23,9 +23,7 @@ const incidentContactOrgSchema = new Schema( } ); -const IncidentContactOrg = model( +export const IncidentContactOrg = model( "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 e588364ee..7a431592b 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 000000000..2ed44cd28 --- /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 95% rename from backend/src/models/integration.ts rename to backend/src/models/integration/integration.ts index b5c467458..7a7775bac 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; @@ -74,6 +75,7 @@ export interface IIntegration { | "windmill" | "gcp-secret-manager"; integrationAuth: Types.ObjectId; + metadata: Metadata; } const integrationSchema = new Schema( @@ -183,6 +185,9 @@ const integrationSchema = new Schema( type: String, required: true, default: "/", + }, + metadata: { + type: Schema.Types.Mixed } }, { @@ -190,6 +195,4 @@ const integrationSchema = new Schema( } ); -const Integration = model("Integration", integrationSchema); - -export default Integration; +export const Integration = model("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 000000000..0415a9556 --- /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 5b05c2242..5dcd3dfe8 100644 --- a/backend/src/models/integrationAuth.ts +++ b/backend/src/models/integrationAuth.ts @@ -193,9 +193,7 @@ const integrationAuthSchema = new Schema( } ); -const IntegrationAuth = model( +export const IntegrationAuth = model( "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 faa37cd86..fcc6e6f60 100644 --- a/backend/src/models/key.ts +++ b/backend/src/models/key.ts @@ -40,6 +40,4 @@ const keySchema = new Schema( } ); -const Key = model("Key", keySchema); - -export default Key; +export const Key = model("Key", keySchema); \ No newline at end of file diff --git a/backend/src/models/loginSRPDetail.ts b/backend/src/models/loginSRPDetail.ts index 8e9e121c5..26f897270 100644 --- a/backend/src/models/loginSRPDetail.ts +++ b/backend/src/models/loginSRPDetail.ts @@ -24,6 +24,4 @@ const loginSRPDetailSchema = new Schema( } ); -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 0fca743b4..6c32ff64f 100644 --- a/backend/src/models/membership.ts +++ b/backend/src/models/membership.ts @@ -52,6 +52,4 @@ const membershipSchema = new Schema( } ); -const Membership = model("Membership", membershipSchema); - -export default Membership; +export const Membership = model("Membership", membershipSchema); \ No newline at end of file diff --git a/backend/src/models/membershipOrg.ts b/backend/src/models/membershipOrg.ts index 74a09b805..b45f9cfe8 100644 --- a/backend/src/models/membershipOrg.ts +++ b/backend/src/models/membershipOrg.ts @@ -39,9 +39,7 @@ const membershipOrgSchema = new Schema( } ); -const MembershipOrg = model( +export const MembershipOrg = model( "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 bafcc05f8..1ae3bcb45 100644 --- a/backend/src/models/organization.ts +++ b/backend/src/models/organization.ts @@ -21,6 +21,4 @@ const organizationSchema = new Schema( } ); -const Organization = model("Organization", organizationSchema); - -export default Organization; +export const Organization = model("Organization", organizationSchema); \ No newline at end of file diff --git a/backend/src/models/secret.ts b/backend/src/models/secret.ts index 4ef3de456..b7d7c266d 100644 --- a/backend/src/models/secret.ts +++ b/backend/src/models/secret.ts @@ -145,6 +145,4 @@ const secretSchema = new Schema( secretSchema.index({ tags: 1 }, { background: true }); -const Secret = model("Secret", secretSchema); - -export default Secret; +export const Secret = model("Secret", secretSchema); \ No newline at end of file diff --git a/backend/src/models/secretApprovalRequest.ts b/backend/src/models/secretApprovalRequest.ts index 008274dd9..910ca9135 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( } ); -const SecretApprovalRequest = model("SecretApprovalRequest", secretApprovalRequestSchema); - -export default SecretApprovalRequest; +export const SecretApprovalRequest = model("SecretApprovalRequest", secretApprovalRequestSchema); \ No newline at end of file diff --git a/backend/src/models/secretBlindIndexData.ts b/backend/src/models/secretBlindIndexData.ts index ca277d19e..5d0cd976a 100644 --- a/backend/src/models/secretBlindIndexData.ts +++ b/backend/src/models/secretBlindIndexData.ts @@ -53,6 +53,4 @@ const secretBlindIndexDataSchema = new Schema( } ); -const SecretBlindIndexData = model("SecretBlindIndexData", secretBlindIndexDataSchema); - -export default SecretBlindIndexData; \ No newline at end of file +export const SecretBlindIndexData = model("SecretBlindIndexData", secretBlindIndexDataSchema); \ No newline at end of file diff --git a/backend/src/models/secretImports.ts b/backend/src/models/secretImports.ts index 0041abc29..79046a489 100644 --- a/backend/src/models/secretImports.ts +++ b/backend/src/models/secretImports.ts @@ -48,5 +48,4 @@ const secretImportSchema = new Schema( } ); -const SecretImport = model("SecretImports", secretImportSchema); -export default SecretImport; +export const SecretImport = model("SecretImports", secretImportSchema); \ No newline at end of file diff --git a/backend/src/models/serviceAccount.ts b/backend/src/models/serviceAccount.ts index 090d55c21..75ae157c6 100644 --- a/backend/src/models/serviceAccount.ts +++ b/backend/src/models/serviceAccount.ts @@ -48,6 +48,4 @@ const serviceAccountSchema = new Schema( } ); -const ServiceAccount = model("ServiceAccount", serviceAccountSchema); - -export default ServiceAccount; \ No newline at end of file +export const ServiceAccount = model("ServiceAccount", serviceAccountSchema); \ No newline at end of file diff --git a/backend/src/models/serviceAccountKey.ts b/backend/src/models/serviceAccountKey.ts index d442dcb08..538e39103 100644 --- a/backend/src/models/serviceAccountKey.ts +++ b/backend/src/models/serviceAccountKey.ts @@ -39,6 +39,4 @@ const serviceAccountKeySchema = new Schema( } ); -const ServiceAccountKey = model("ServiceAccountKey", serviceAccountKeySchema); - -export default ServiceAccountKey; +export const ServiceAccountKey = model("ServiceAccountKey", serviceAccountKeySchema); \ No newline at end of file diff --git a/backend/src/models/serviceAccountOrganizationPermission.ts b/backend/src/models/serviceAccountOrganizationPermission.ts index 4519bd832..970ec7461 100644 --- a/backend/src/models/serviceAccountOrganizationPermission.ts +++ b/backend/src/models/serviceAccountOrganizationPermission.ts @@ -18,6 +18,4 @@ const serviceAccountOrganizationPermissionSchema = new Schema("ServiceAccountOrganizationPermission", serviceAccountOrganizationPermissionSchema); - -export default ServiceAccountOrganizationPermission; \ No newline at end of file +export const ServiceAccountOrganizationPermission = model("ServiceAccountOrganizationPermission", serviceAccountOrganizationPermissionSchema); \ No newline at end of file diff --git a/backend/src/models/serviceAccountWorkspacePermission.ts b/backend/src/models/serviceAccountWorkspacePermission.ts index 5814923e5..1d3523766 100644 --- a/backend/src/models/serviceAccountWorkspacePermission.ts +++ b/backend/src/models/serviceAccountWorkspacePermission.ts @@ -39,6 +39,4 @@ const serviceAccountWorkspacePermissionSchema = new Schema("ServiceAccountWorkspacePermission", serviceAccountWorkspacePermissionSchema); - -export default ServiceAccountWorkspacePermission; \ No newline at end of file +export const ServiceAccountWorkspacePermission = model("ServiceAccountWorkspacePermission", serviceAccountWorkspacePermissionSchema); \ No newline at end of file diff --git a/backend/src/models/serviceToken.ts b/backend/src/models/serviceToken.ts index ce5fa3c9b..4734a50e2 100644 --- a/backend/src/models/serviceToken.ts +++ b/backend/src/models/serviceToken.ts @@ -56,6 +56,4 @@ const serviceTokenSchema = new Schema( } ); -const ServiceToken = model("ServiceToken", serviceTokenSchema); - -export default ServiceToken; +export const ServiceToken = model("ServiceToken", serviceTokenSchema); \ No newline at end of file diff --git a/backend/src/models/serviceTokenData.ts b/backend/src/models/serviceTokenData.ts index 804184386..ea7d00eaa 100644 --- a/backend/src/models/serviceTokenData.ts +++ b/backend/src/models/serviceTokenData.ts @@ -89,6 +89,4 @@ const serviceTokenDataSchema = new Schema( } ); -const ServiceTokenData = model("ServiceTokenData", serviceTokenDataSchema); - -export default ServiceTokenData; +export const ServiceTokenData = model("ServiceTokenData", serviceTokenDataSchema); \ No newline at end of file diff --git a/backend/src/models/tag.ts b/backend/src/models/tag.ts index ec649e254..a5f0bd307 100644 --- a/backend/src/models/tag.ts +++ b/backend/src/models/tag.ts @@ -50,6 +50,4 @@ const tagSchema = new Schema( tagSchema.index({ slug: 1, workspace: 1 }, { unique: true }) tagSchema.index({ workspace: 1 }) -const Tag = model("Tag", tagSchema); - -export default Tag; +export const Tag = model("Tag", tagSchema); \ No newline at end of file diff --git a/backend/src/models/token.ts b/backend/src/models/token.ts index ab0a69c9e..62d342b0a 100644 --- a/backend/src/models/token.ts +++ b/backend/src/models/token.ts @@ -27,6 +27,4 @@ const tokenSchema = new Schema({ tokenSchema.index({ email: 1 }); -const Token = model("Token", tokenSchema); - -export default Token; +export const Token = model("Token", tokenSchema); \ No newline at end of file diff --git a/backend/src/models/tokenData.ts b/backend/src/models/tokenData.ts index 615c9019d..2544c05f1 100644 --- a/backend/src/models/tokenData.ts +++ b/backend/src/models/tokenData.ts @@ -50,6 +50,4 @@ const tokenDataSchema = new Schema({ timestamps: true, }); -const TokenData = model("TokenData", tokenDataSchema); - -export default TokenData; +export const TokenData = model("TokenData", tokenDataSchema); \ No newline at end of file diff --git a/backend/src/models/tokenVersion.ts b/backend/src/models/tokenVersion.ts index 1103fc316..b162e019e 100644 --- a/backend/src/models/tokenVersion.ts +++ b/backend/src/models/tokenVersion.ts @@ -42,6 +42,4 @@ const tokenVersionSchema = new Schema( } ); -const TokenVersion = model("TokenVersion", tokenVersionSchema); - -export default TokenVersion; \ No newline at end of file +export const TokenVersion = model("TokenVersion", tokenVersionSchema); \ No newline at end of file diff --git a/backend/src/models/user.ts b/backend/src/models/user.ts index 10139c85e..c85c0936b 100644 --- a/backend/src/models/user.ts +++ b/backend/src/models/user.ts @@ -121,6 +121,4 @@ const userSchema = new Schema( } ); -const User = model("User", userSchema); - -export default User; +export const User = model("User", userSchema); \ No newline at end of file diff --git a/backend/src/models/userAction.ts b/backend/src/models/userAction.ts index 11eda05e8..68fae22be 100644 --- a/backend/src/models/userAction.ts +++ b/backend/src/models/userAction.ts @@ -23,6 +23,4 @@ const userActionSchema = new Schema( } ); -const UserAction = model("UserAction", userActionSchema); - -export default UserAction; +export const UserAction = model("UserAction", userActionSchema); \ No newline at end of file diff --git a/backend/src/models/webhooks.ts b/backend/src/models/webhooks.ts index b4a168878..845c6ada2 100644 --- a/backend/src/models/webhooks.ts +++ b/backend/src/models/webhooks.ts @@ -80,6 +80,4 @@ const WebhookSchema = new Schema( } ); -const Webhook = model("Webhook", WebhookSchema); - -export default Webhook; +export const Webhook = model("Webhook", WebhookSchema); \ No newline at end of file diff --git a/backend/src/models/workspace.ts b/backend/src/models/workspace.ts index b3dd28b00..9d7a19fcc 100644 --- a/backend/src/models/workspace.ts +++ b/backend/src/models/workspace.ts @@ -49,6 +49,4 @@ const workspaceSchema = new Schema({ }, }); -const Workspace = model("Workspace", workspaceSchema); - -export default Workspace; \ No newline at end of file +export const Workspace = model("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 2a12c0e5d..3b5e04a3c 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" @@ -36,6 +35,14 @@ syncSecretsToThirdPartyServices.process(async (job: Job) => { secretPath: integration.secretPath }); + const suffixedSecrets: any = {}; + if (integration.metadata?.secretSuffix) { + for (const key in secrets) { + const newKey = key + integration.metadata?.secretSuffix; + suffixedSecrets[newKey] = secrets[key]; + } + } + const integrationAuth = await IntegrationAuth.findById(integration.integrationAuth); if (!integrationAuth) throw new Error("Failed to find integration auth"); @@ -49,7 +56,7 @@ syncSecretsToThirdPartyServices.process(async (job: Job) => { await syncSecrets({ integration, integrationAuth, - secrets, + secrets: Object.keys(suffixedSecrets).length !== 0 ? suffixedSecrets : secrets, accessId: access.accessId === undefined ? null : access.accessId, accessToken: access.accessToken }); diff --git a/backend/src/routes/v1/integration.ts b/backend/src/routes/v1/integration.ts index dc97e66c0..a5d32349e 100644 --- a/backend/src/routes/v1/integration.ts +++ b/backend/src/routes/v1/integration.ts @@ -37,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 81f169f4b..cb4ef4286 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 8892cdb31..d4442b835 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 c66f44e47..7506e25c1 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/docs/integrations/cloud/checkly.mdx b/docs/integrations/cloud/checkly.mdx index 90c0850d3..315764ce8 100644 --- a/docs/integrations/cloud/checkly.mdx +++ b/docs/integrations/cloud/checkly.mdx @@ -35,3 +35,9 @@ Select which Infisical environment secrets you want to sync to Checkly and press ![integrations checkly](../../images/integrations-checkly-create.png) ![integrations checkly](../../images/integrations-checkly.png) + + + In the new version of the Checkly integration, you are able to specify suffixes that depend on the secrets' environment and path. + If you choose to do so, you should utilize such suffixes for ALL Checkly integrations – otherwise the integration system + might run into issues with deleting secrets from the wrong environments. + diff --git a/frontend/src/hooks/api/integrations/queries.tsx b/frontend/src/hooks/api/integrations/queries.tsx index bfca2f407..6e7b65eed 100644 --- a/frontend/src/hooks/api/integrations/queries.tsx +++ b/frontend/src/hooks/api/integrations/queries.tsx @@ -40,7 +40,8 @@ export const useCreateIntegration = () => { owner, path, region, - secretPath + secretPath, + metadata }: { integrationAuthId: string; isActive: boolean; @@ -55,6 +56,9 @@ export const useCreateIntegration = () => { owner: string | null; path: string | null; region: string | null; + metadata?: { + secretSuffix?: string; + } }) => { const { data: { integration } } = await apiRequest.post("/api/v1/integration", { integrationAuthId, @@ -69,7 +73,8 @@ export const useCreateIntegration = () => { owner, path, region, - secretPath + secretPath, + metadata }); return integration; diff --git a/frontend/src/hooks/api/integrations/types.ts b/frontend/src/hooks/api/integrations/types.ts index 5ff2bbac7..199d02975 100644 --- a/frontend/src/hooks/api/integrations/types.ts +++ b/frontend/src/hooks/api/integrations/types.ts @@ -30,4 +30,7 @@ export type TIntegration = { 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 7f3b5397b..6b3febfb8 100644 --- a/frontend/src/pages/integrations/checkly/create.tsx +++ b/frontend/src/pages/integrations/checkly/create.tsx @@ -35,6 +35,7 @@ export default function ChecklyCreateIntegrationPage() { const [selectedSourceEnvironment, setSelectedSourceEnvironment] = useState(""); const [secretPath, setSecretPath] = useState("/"); + const [secretSuffix, setSecretSuffix] = useState(""); const [targetApp, setTargetApp] = useState(""); const [targetAppId, setTargetAppId] = useState(""); @@ -78,7 +79,10 @@ export default function ChecklyCreateIntegrationPage() { owner: null, path: null, region: null, - secretPath + secretPath, + metadata: { + secretSuffix + } }); setIsLoading(false); @@ -148,6 +152,13 @@ export default function ChecklyCreateIntegrationPage() { )} + + setSecretSuffix(evt.target.value)} + placeholder="Provide a suffix for secret names, default is no suffix" + /> +