Skip to content

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

Merge branch 'daniel/assignment' of https://github.com/DanielHougaard/infisical into daniel/assignment

Daniel Hougaard4ec0c9cdbf57
diff --cc backend/src/controllers/v3/secretsController.ts
index 297976acac,8318742f06..c733da60c8
--- a/backend/src/controllers/v3/secretsController.ts
+++ b/backend/src/controllers/v3/secretsController.ts
@@@ -1061,51 -706,42 +1061,83 @@@ export const updateSecretByName = asyn
secretAction: ProjectPermissionActions.Edit
});
- 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({
+ if (req.authData.authPayload instanceof User) {
+ const membership = await Membership.findOne({
+ user: req.authData.authPayload._id,
+ workspace: new Types.ObjectId(workspaceId)
+ });
+
+ if (membership && type !== "personal") {
+ const secretApprovalPolicy = await getSecretPolicyOfBoard(
workspaceId,
environment,
- secretPath,
- policy: secretApprovalPolicy,
- commiterMembershipId: membership._id.toString(),
- authData: req.authData,
- data: {
- [CommitType.UPDATE]: [
- {
- secretName,
- newSecretName,
- secretValueCiphertext,
- secretValueIV,
- secretValueTag,
- tags,
- secretCommentIV,
- secretCommentTag,
- secretCommentCiphertext,
- skipMultilineEncoding,
- secretKeyTag,
- secretKeyCiphertext,
- secretKeyIV
- }
- ]
- }
+ secretPath
+ );
+ if (secretApprovalPolicy) {
+ const secretApprovalRequest = await generateSecretApprovalRequest({
+ workspaceId,
+ environment,
+ secretPath,
+ policy: secretApprovalPolicy,
+ commiterMembershipId: membership._id.toString(),
+ authData: req.authData,
+ data: {
+ [CommitType.UPDATE]: [
+ {
+ secretName,
+ newSecretName,
+ secretValueCiphertext,
+ secretValueIV,
+ secretValueTag,
+ tags,
+ secretCommentIV,
+ secretCommentTag,
+ secretCommentCiphertext,
+ skipMultilineEncoding,
+ secretKeyTag,
+ secretKeyCiphertext,
+ secretKeyIV
+ }
+ ]
+ }
+ });
+ return res.send({ approval: secretApprovalRequest });
+ }
+ }
+ }
+
++ 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
+ });
- return res.send({ approval: secretApprovalRequest });
+ }
+ }
+
if (type !== "personal") {
const existingSecret = await SecretService.getSecret({
secretName,