Skip to content

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

fix(global-approvals): return grant statuses as expired when expiredAt is reached

x032205aae86640fb0d
diff --git a/backend/src/services/approval-policy/approval-policy-service.ts b/backend/src/services/approval-policy/approval-policy-service.ts
index 3e43bcd728..bbe13742a2 100644
--- a/backend/src/services/approval-policy/approval-policy-service.ts
+++ b/backend/src/services/approval-policy/approval-policy-service.ts
@@ -820,7 +820,18 @@ export const approvalPolicyServiceFactory = ({
);
const grants = await approvalRequestGrantsDAL.find({ projectId, type: policyType });
- return { grants };
+ const updatedGrants = grants.map((grant) => {
+ if (
+ grant.status === ApprovalRequestGrantStatus.Active &&
+ grant.expiresAt &&
+ new Date(grant.expiresAt) < new Date()
+ ) {
+ return { ...grant, status: ApprovalRequestGrantStatus.Expired };
+ }
+ return grant;
+ });
+
+ return { grants: updatedGrants };
};
const getGrantById = async (grantId: string, actor: OrgServiceActor) => {
@@ -843,7 +854,15 @@ export const approvalPolicyServiceFactory = ({
ProjectPermissionSub.ApprovalRequestGrants
);
- return { grant };
+ let status = grant.status;
+ if (
+ grant.status === ApprovalRequestGrantStatus.Active &&
+ grant.expiresAt &&
+ new Date(grant.expiresAt) < new Date()
+ ) {
+ status = ApprovalRequestGrantStatus.Expired;
+ }
+ return { grant: { ...grant, status } };
};
const revokeGrant = async (