Skip to content

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

only cancel the restore revocation when a lease is renewed

DimitrisStaratzise562ae49fcc2
diff --git a/backend/src/ee/services/dynamic-secret-lease/dynamic-secret-lease-queue.ts b/backend/src/ee/services/dynamic-secret-lease/dynamic-secret-lease-queue.ts
index 001aee17f3..002c4af3c0 100644
--- a/backend/src/ee/services/dynamic-secret-lease/dynamic-secret-lease-queue.ts
+++ b/backend/src/ee/services/dynamic-secret-lease/dynamic-secret-lease-queue.ts
@@ -42,13 +42,15 @@ export type TDynamicSecretLeaseQueueServiceFactory = {
pruneDynamicSecret: (dynamicSecretCfgId: string) => Promise<void>;
setLeaseRevocation: (leaseId: string, dynamicSecretId: string, expiryAt: Date, jobId?: string) => Promise<void>;
unsetLeaseRevocation: (leaseId: string) => Promise<void>;
+ unsetRestoredLeaseRevocation: (leaseId: string) => Promise<void>;
queueFailedRevocation: (leaseId: string, dynamicSecretId: string) => Promise<void>;
};
const MAX_REVOCATION_RETRY_COUNT = 3;
// Restoring a project re-queues revocation of its expired leases under this id, so an older retry, which stops the
-// job under the lease id when it gives up, can't cancel it.
+// job under the lease id when it gives up, can't cancel it. Only renewal cancels it: pruning keeps it in case its own
+// revoke fails.
export const getRestoredLeaseRevocationJobId = (leaseId: string) => `${leaseId}-restore`;
export const dynamicSecretLeaseQueueServiceFactory = ({
@@ -97,6 +99,9 @@ export const dynamicSecretLeaseQueueServiceFactory = ({
const unsetLeaseRevocation = async (leaseId: string) => {
await queueService.stopJobById(QueueName.DynamicSecretRevocation, leaseId);
+ };
+
+ const unsetRestoredLeaseRevocation = async (leaseId: string) => {
await queueService.stopJobById(QueueName.DynamicSecretRevocation, getRestoredLeaseRevocationJobId(leaseId));
};
@@ -448,6 +453,7 @@ export const dynamicSecretLeaseQueueServiceFactory = ({
pruneDynamicSecret,
setLeaseRevocation,
unsetLeaseRevocation,
+ unsetRestoredLeaseRevocation,
queueFailedRevocation
};
};
diff --git a/backend/src/ee/services/dynamic-secret-lease/dynamic-secret-lease-service.ts b/backend/src/ee/services/dynamic-secret-lease/dynamic-secret-lease-service.ts
index 9f8823dd42..8d7e62d461 100644
--- a/backend/src/ee/services/dynamic-secret-lease/dynamic-secret-lease-service.ts
+++ b/backend/src/ee/services/dynamic-secret-lease/dynamic-secret-lease-service.ts
@@ -341,6 +341,7 @@ export const dynamicSecretLeaseServiceFactory = ({
);
await dynamicSecretQueueService.unsetLeaseRevocation(dynamicSecretLease.id);
+ await dynamicSecretQueueService.unsetRestoredLeaseRevocation(dynamicSecretLease.id);
await dynamicSecretQueueService.setLeaseRevocation(dynamicSecretLease.id, dynamicSecretCfg.id, expireAt);
const updatedDynamicSecretLease = await dynamicSecretLeaseDAL.updateById(dynamicSecretLease.id, {
expireAt,