Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
Added secret reminder handler on updates
Daniel Hougaard80ce69535502
diff --git a/backend/src/controllers/v3/secretsController.ts b/backend/src/controllers/v3/secretsController.tsindex 2e0c8514ae..d4f8f46743 100644--- a/backend/src/controllers/v3/secretsController.ts+++ b/backend/src/controllers/v3/secretsController.ts@@ -32,6 +32,7 @@ import {} from "../../ee/services/SecretApprovalService";import { CommitType } from "../../ee/models/secretApprovalRequest";import { IRole } from "../../ee/models/role";+import { createReminder, deleteReminder } from "../../helpers/reminder";const checkSecretsPermission = async ({authData,@@ -361,7 +362,14 @@ export const createSecretRaw = async (req: Request, res: Response) => {export const updateSecretByNameRaw = async (req: Request, res: Response) => {const {params: { secretName },- body: { secretValue, environment, secretPath, type, workspaceId, skipMultilineEncoding }+ body: {+ secretValue,+ environment,+ secretPath,+ type,+ workspaceId,+ skipMultilineEncoding,+ }} = await validateRequest(reqValidator.UpdateSecretByNameRawV3, req);await checkSecretsPermission({@@ -686,7 +694,9 @@ export const updateSecretByName = async (req: Request, res: Response) => {secretKeyIV,secretKeyTag,secretKeyCiphertext,- skipMultilineEncoding+ skipMultilineEncoding,+ secretReminderCron,+ secretReminderNote,},params: { secretName }} = await validateRequest(reqValidator.UpdateSecretByNameV3, req);@@ -706,6 +716,9 @@ export const updateSecretByName = async (req: Request, res: Response) => {if (membership && type !== "personal") {const secretApprovalPolicy = await getSecretPolicyOfBoard(workspaceId, environment, secretPath);if (secretApprovalPolicy) {++ // ? QUESTION+ // ? Here we could also expand upon the reminders feature, by adding it to the approval process.const secretApprovalRequest = await generateSecretApprovalRequest({workspaceId,environment,@@ -737,6 +750,32 @@ export const updateSecretByName = async (req: Request, res: Response) => {}}+ if(type !== "personal") {+ const existingSecret = await SecretService.getSecret({+ secretName,+ workspaceId: new Types.ObjectId(workspaceId),+ environment,+ type,+ secretPath,+ authData: req.authData+ });++ if((secretReminderCron && existingSecret.secretReminderCron !== secretReminderCron) || (secretReminderNote && existingSecret.secretReminderNote !== secretReminderNote)) {+ await createReminder(existingSecret, {+ _id: existingSecret._id,+ secretReminderCron,+ secretReminderNote,+ workspace: existingSecret.workspace,+ })+ } else if(secretReminderCron === null && secretReminderNote === null && existingSecret.secretReminderCron) {+ await deleteReminder({+ _id: existingSecret._id,+ secretReminderCron: existingSecret.secretReminderCron,+ })+ }+ }++const secret = await SecretService.updateSecret({secretName,workspaceId: new Types.ObjectId(workspaceId),@@ -747,6 +786,8 @@ export const updateSecretByName = async (req: Request, res: Response) => {newSecretName,secretValueCiphertext,secretValueIV,+ secretReminderCron,+ secretReminderNote,secretValueTag,secretPath,tags,