Skip to content

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

fix(pki): show code signing access as expired or revoked once its grant ends (#9117)

Saif Ur Rahmandabf96e66c7d
diff --git a/backend/e2e-test/signer-request-dal.spec.ts b/backend/e2e-test/signer-request-dal.spec.ts
new file mode 100644
index 0000000000..27908e5263
--- /dev/null
+++ b/backend/e2e-test/signer-request-dal.spec.ts
@@ -0,0 +1,181 @@
+import { randomUUID } from "node:crypto";
+
+import { Knex } from "knex";
+import { afterAll, beforeAll, describe, expect, test } from "vitest";
+
+import { TableName } from "@app/db/schemas";
+import { seedData1 } from "@app/db/seed-data";
+import {
+ ApprovalPolicyScope,
+ ApprovalPolicyType,
+ ApprovalRequestGrantStatus,
+ ApprovalRequestStatus
+} from "@app/services/approval-policy/approval-policy-enums";
+import { signerRequestDALFactory } from "@app/services/signer/signer-request-dal";
+
+declare const testDb: Knex;
+
+const dal = signerRequestDALFactory(testDb as never);
+
+const PROJECT_ID = seedData1.project.id;
+const ORG_ID = seedData1.organization.id;
+const SIGNER_ID = randomUUID();
+const HOUR_MS = 60 * 60 * 1000;
+const now = Date.now();
+
+type TCase = {
+ key: string;
+ status: ApprovalRequestStatus;
+ grant?: { status: ApprovalRequestGrantStatus; expiresAt: Date | null; revokedAt?: Date };
+ expectedAccessStatus: string;
+};
+
+const CASES: TCase[] = [
+ { key: "pending", status: ApprovalRequestStatus.Pending, expectedAccessStatus: "pending" },
+ {
+ key: "active",
+ status: ApprovalRequestStatus.Approved,
+ grant: { status: ApprovalRequestGrantStatus.Active, expiresAt: new Date(now + HOUR_MS) },
+ expectedAccessStatus: "approved"
+ },
+ {
+ key: "noWindow",
+ status: ApprovalRequestStatus.Approved,
+ grant: { status: ApprovalRequestGrantStatus.Active, expiresAt: null },
+ expectedAccessStatus: "approved"
+ },
+ {
+ key: "pastWindowStillActive",
+ status: ApprovalRequestStatus.Approved,
+ grant: { status: ApprovalRequestGrantStatus.Active, expiresAt: new Date(now - 60_000) },
+ expectedAccessStatus: "expired"
+ },
+ {
+ key: "signingsUsedUp",
+ status: ApprovalRequestStatus.Approved,
+ grant: { status: ApprovalRequestGrantStatus.Expired, expiresAt: new Date(now + HOUR_MS) },
+ expectedAccessStatus: "expired"
+ },
+ {
+ key: "grantRevoked",
+ status: ApprovalRequestStatus.Approved,
+ grant: { status: ApprovalRequestGrantStatus.Revoked, expiresAt: new Date(now + HOUR_MS) },
+ expectedAccessStatus: "cancelled"
+ },
+ {
+ key: "revokedAfterWindowEnded",
+ status: ApprovalRequestStatus.Approved,
+ grant: {
+ status: ApprovalRequestGrantStatus.Revoked,
+ expiresAt: new Date(now - 2 * HOUR_MS),
+ revokedAt: new Date(now - HOUR_MS)
+ },
+ expectedAccessStatus: "expired"
+ },
+ {
+ key: "revokedDuringWindowSinceEnded",
+ status: ApprovalRequestStatus.Approved,
+ grant: {
+ status: ApprovalRequestGrantStatus.Revoked,
+ expiresAt: new Date(now - HOUR_MS),
+ revokedAt: new Date(now - 2 * HOUR_MS)
+ },
+ expectedAccessStatus: "cancelled"
+ },
+ {
+ key: "cancelled",
+ status: ApprovalRequestStatus.Cancelled,
+ grant: { status: ApprovalRequestGrantStatus.Revoked, expiresAt: new Date(now + HOUR_MS) },
+ expectedAccessStatus: "cancelled"
+ },
+ { key: "rejected", status: ApprovalRequestStatus.Rejected, expectedAccessStatus: "rejected" }
+];
+
+const requestIds = {} as Record<string, string>;
+
+const base = { signerId: SIGNER_ID, projectId: PROJECT_ID, type: ApprovalPolicyType.CertCodeSigning };
+
+const keysOf = (rows: { id: string }[]) =>
+ rows.map((row) => Object.keys(requestIds).find((key) => requestIds[key] === row.id)).sort();
+
+describe("Signer request DAL access status", () => {
+ beforeAll(async () => {
+ // eslint-disable-next-line no-restricted-syntax
+ for (const [index, testCase] of CASES.entries()) {
+ // createdAt is not part of the insert type, but setting it fixes the list order the pagination test relies on.
+ const requestRow = {
+ projectId: PROJECT_ID,
+ organizationId: ORG_ID,
+ requesterName: "e2e",
+ requesterEmail: "[email protected]",
+ type: ApprovalPolicyType.CertCodeSigning,
+ status: testCase.status,
+ currentStep: 1,
+ requestData: JSON.stringify({ version: 1, requestData: {} }),
+ scopeType: ApprovalPolicyScope.Signer,
+ scopeId: SIGNER_ID,
+ createdAt: new Date(now - index * 60_000)
+ };
+ // eslint-disable-next-line no-await-in-loop
+ const [request] = await testDb(TableName.ApprovalRequests).insert(requestRow).returning("id");
+ requestIds[testCase.key] = request.id;
+
+ if (testCase.grant) {
+ // eslint-disable-next-line no-await-in-loop
+ await testDb(TableName.ApprovalRequestGrants).insert({
+ projectId: PROJECT_ID,
+ requestId: request.id,
+ type: ApprovalPolicyType.CertCodeSigning,
+ status: testCase.grant.status,
+ expiresAt: testCase.grant.expiresAt,
+ revokedAt: testCase.grant.revokedAt ?? null,
+ attributes: JSON.stringify({ maxSignings: 10 })
+ });
+ }
+ }
+ });
+
+ afterAll(async () => {
+ const ids = Object.values(requestIds);
+ await testDb(TableName.ApprovalRequestGrants).whereIn("requestId", ids).del();
+ await testDb(TableName.ApprovalRequests).whereIn("id", ids).del();
+ });
+
+ test("derives the access status from the grant and leaves the request status as stored", async () => {
+ const rows = await dal.listSignerRequestsPaginated({ ...base, offset: 0, limit: 25 });
+
+ expect(rows).toHaveLength(CASES.length);
+ CASES.forEach((testCase) => {
+ const row = rows.find((r) => r.id === requestIds[testCase.key]);
+ expect(row, testCase.key).toBeDefined();
+ expect(row?.accessStatus, testCase.key).toBe(testCase.expectedAccessStatus);
+ expect(row?.status, testCase.key).toBe(testCase.status);
+ });
+ });
+
+ test.each([
+ { filter: ["pending"], expected: ["pending"] },
+ { filter: ["approved"], expected: ["active", "noWindow"] },
+ { filter: ["expired"], expected: ["pastWindowStillActive", "revokedAfterWindowEnded", "signingsUsedUp"] },
+ {
+ filter: ["cancelled", "rejected"],
+ expected: ["cancelled", "grantRevoked", "rejected", "revokedDuringWindowSinceEnded"]
+ }
+ ])("filters on $filter by access status, and the count matches", async ({ filter, expected }) => {
+ const rows = await dal.listSignerRequestsPaginated({ ...base, statuses: filter, offset: 0, limit: 25 });
+ const count = await dal.countSignerRequests({ ...base, statuses: filter });
+
+ expect(keysOf(rows)).toEqual([...expected].sort());
+ expect(count).toBe(expected.length);
+ });
+
+ test("counts every request when no filter is passed", async () => {
+ expect(await dal.countSignerRequests(base)).toBe(CASES.length);
+ });
+
+ test("paginates after filtering", async () => {
+ const rows = await dal.listSignerRequestsPaginated({ ...base, statuses: ["expired"], offset: 1, limit: 1 });
+
+ expect(keysOf(rows)).toEqual(["signingsUsedUp"]);
+ });
+});
diff --git a/backend/src/services/signer/signer-policy-service.ts b/backend/src/services/signer/signer-policy-service.ts
index 310748173f..41f2f4b04b 100644
--- a/backend/src/services/signer/signer-policy-service.ts
+++ b/backend/src/services/signer/signer-policy-service.ts
@@ -1,6 +1,6 @@
import { ForbiddenError } from "@casl/ability";
-import { RESOURCE_SCOPE, ResourceMembershipRole, ResourceType } from "@app/db/schemas";
+import { RESOURCE_SCOPE, ResourceMembershipRole, ResourceType, TApprovalRequestGrants } from "@app/db/schemas";
import { TIdentityGroupMembershipDALFactory } from "@app/ee/services/group/identity-group-membership-dal";
import { TUserGroupMembershipDALFactory } from "@app/ee/services/group/user-group-membership-dal";
import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service-types";
@@ -50,6 +50,7 @@ import { TSmtpService } from "../smtp/smtp-service";
import { TUserDALFactory } from "../user/user-dal";
import { TSignerDALFactory } from "./signer-dal";
import { TSignerRequestDALFactory } from "./signer-request-dal";
+import { isSignerRequestRevocable } from "./signer-request-fns";
import {
TGetSignerPolicyDTO,
TListSignerRequestsDTO,
@@ -67,12 +68,15 @@ type TSignerPolicyServiceFactoryDep = {
approvalPolicyStepApproversDAL: Pick<TApprovalPolicyStepApproversDALFactory, "create" | "delete">;
approvalRequestDAL: Pick<
TApprovalRequestDALFactory,
- "create" | "find" | "findById" | "findStepsByRequestId" | "updateById" | "transaction"
+ "create" | "find" | "findById" | "findByIdForUpdate" | "findStepsByRequestId" | "updateById" | "transaction"
>;
signerRequestDAL: TSignerRequestDALFactory;
approvalRequestStepsDAL: Pick<TApprovalRequestStepsDALFactory, "create">;
approvalRequestStepEligibleApproversDAL: Pick<TApprovalRequestStepEligibleApproversDALFactory, "create">;
- approvalRequestGrantsDAL: Pick<TApprovalRequestGrantsDALFactory, "create" | "find" | "updateById">;
+ approvalRequestGrantsDAL: Pick<
+ TApprovalRequestGrantsDALFactory,
+ "create" | "find" | "findByIdForUpdate" | "updateById"
+ >;
membershipDAL: Pick<TMembershipDALFactory, "find" | "transaction">;
membershipRoleDAL: Pick<TMembershipRoleDALFactory, "find">;
userGroupMembershipDAL: Pick<TUserGroupMembershipDALFactory, "find">;
@@ -824,10 +828,27 @@ export const signerPolicyServiceFactory = ({
}
await membershipDAL.transaction(async (tx) => {
- const grants = await approvalRequestGrantsDAL.find(
+ // Decide on rows locked in this transaction: the request read above can come from a lagging replica, and a
+ // reject or the last allowed signing can change the request or its grant while this runs.
+ const lockedRequest = await approvalRequestDAL.findByIdForUpdate(dto.requestId, tx);
+ if (!lockedRequest) {
+ throw new NotFoundError({ message: `Request '${dto.requestId}' not found on this signer.` });
+ }
+ const activeGrants = await approvalRequestGrantsDAL.find(
{ requestId: dto.requestId, status: ApprovalRequestGrantStatus.Active },
{ tx }
);
+ const grants: TApprovalRequestGrants[] = [];
+ for (const activeGrant of activeGrants) {
+ // eslint-disable-next-line no-await-in-loop
+ const lockedGrant = await approvalRequestGrantsDAL.findByIdForUpdate(activeGrant.id, tx);
+ if (lockedGrant?.status === ApprovalRequestGrantStatus.Active) grants.push(lockedGrant);
+ }
+ if (!isSignerRequestRevocable(lockedRequest, grants)) {
+ throw new BadRequestError({
+ message: `Request '${dto.requestId}' has no signing access left to revoke. Its access already expired, was revoked, or was never approved.`
+ });
+ }
for (const grant of grants) {
// eslint-disable-next-line no-await-in-loop
await approvalRequestGrantsDAL.updateById(
diff --git a/backend/src/services/signer/signer-request-dal.ts b/backend/src/services/signer/signer-request-dal.ts
index c43e7ed9e5..aaa8d9a7b6 100644
--- a/backend/src/services/signer/signer-request-dal.ts
+++ b/backend/src/services/signer/signer-request-dal.ts
@@ -5,12 +5,83 @@ import { DatabaseError } from "@app/lib/errors";
import {
ApprovalPolicyScope,
ApprovalPolicyType,
- ApprovalRequestGrantStatus
+ ApprovalRequestGrantStatus,
+ ApprovalRequestStatus
} from "../approval-policy/approval-policy-enums";
export type TSignerRequestDALFactory = ReturnType<typeof signerRequestDALFactory>;
export const signerRequestDALFactory = (db: TDbClient) => {
+ const $buildSignerRequestsQuery = ({
+ signerId,
+ projectId,
+ type
+ }: {
+ signerId: string;
+ projectId: string;
+ type: ApprovalPolicyType;
+ }) => {
+ const usageSubquery = db
+ .replicaNode()(TableName.PkiSigningOperations)
+ .select("approvalGrantId")
+ .count("* as usedSignings")
+ .where({ status: "success" })
+ .whereNotNull("approvalGrantId")
+ .groupBy("approvalGrantId")
+ .as("usage");
+
+ return db
+ .replicaNode()(TableName.ApprovalRequests)
+ .leftJoin(TableName.ApprovalRequestGrants, function joinGrants() {
+ this.on(`${TableName.ApprovalRequestGrants}.requestId`, "=", `${TableName.ApprovalRequests}.id`);
+ })
+ .leftJoin(usageSubquery, "usage.approvalGrantId", `${TableName.ApprovalRequestGrants}.id`)
+ .where(`${TableName.ApprovalRequests}.projectId`, projectId)
+ .where(`${TableName.ApprovalRequests}.type`, type)
+ .where(`${TableName.ApprovalRequests}.scopeType`, ApprovalPolicyScope.Signer)
+ .where(`${TableName.ApprovalRequests}.scopeId`, signerId)
+ .distinctOn(`${TableName.ApprovalRequests}.id`)
+ .select(
+ `${TableName.ApprovalRequests}.*`,
+ db.ref("attributes").withSchema(TableName.ApprovalRequestGrants).as("grantAttributes"),
+ db.ref("expiresAt").withSchema(TableName.ApprovalRequestGrants).as("grantExpiresAt"),
+ db.ref("status").withSchema(TableName.ApprovalRequestGrants).as("grantStatus"),
+ db.raw('COALESCE("usage"."usedSignings", 0) AS "usedSignings"'),
+ // An approved request stays "approved" for good; the grant carries what happened to the access afterwards.
+ // A grant past its expiresAt can still read "active" until the next sign attempt or the hourly cleanup marks
+ // it, so the time is compared directly. A revoked grant reads as "cancelled", the status the signer's own
+ // revoke sets, unless it was revoked after its window had already ended: that access expired on its own.
+ db.raw(
+ `CASE
+ WHEN "${TableName.ApprovalRequests}"."status" = ? AND "${TableName.ApprovalRequestGrants}"."status" = ?
+ AND (
+ "${TableName.ApprovalRequestGrants}"."expiresAt" IS NULL
+ OR "${TableName.ApprovalRequestGrants}"."revokedAt" IS NULL
+ OR "${TableName.ApprovalRequestGrants}"."revokedAt" < "${TableName.ApprovalRequestGrants}"."expiresAt"
+ )
+ THEN ?
+ WHEN "${TableName.ApprovalRequests}"."status" = ?
+ AND ("${TableName.ApprovalRequestGrants}"."status" = ? OR "${TableName.ApprovalRequestGrants}"."expiresAt" <= NOW())
+ THEN ?
+ ELSE "${TableName.ApprovalRequests}"."status"
+ END AS "accessStatus"`,
+ [
+ ApprovalRequestStatus.Approved,
+ ApprovalRequestGrantStatus.Revoked,
+ ApprovalRequestStatus.Cancelled,
+ ApprovalRequestStatus.Approved,
+ ApprovalRequestGrantStatus.Expired,
+ ApprovalRequestStatus.Expired
+ ]
+ )
+ )
+ .orderByRaw(
+ `"${TableName.ApprovalRequests}"."id", ("${TableName.ApprovalRequestGrants}"."status" = ?) DESC NULLS LAST, "${TableName.ApprovalRequestGrants}"."createdAt" DESC NULLS LAST`,
+ [ApprovalRequestGrantStatus.Active]
+ )
+ .as("dedup");
+ };
+
const listSignerRequestsPaginated = async ({
signerId,
projectId,
@@ -27,48 +98,15 @@ export const signerRequestDALFactory = (db: TDbClient) => {
limit: number;
}) => {
try {
- const usageSubquery = db
- .replicaNode()(TableName.PkiSigningOperations)
- .select("approvalGrantId")
- .count("* as usedSignings")
- .where({ status: "success" })
- .whereNotNull("approvalGrantId")
- .groupBy("approvalGrantId")
- .as("usage");
-
- const dedupedRequests = db
- .replicaNode()(TableName.ApprovalRequests)
- .leftJoin(TableName.ApprovalRequestGrants, function joinGrants() {
- this.on(`${TableName.ApprovalRequestGrants}.requestId`, "=", `${TableName.ApprovalRequests}.id`);
- })
- .leftJoin(usageSubquery, "usage.approvalGrantId", `${TableName.ApprovalRequestGrants}.id`)
- .where(`${TableName.ApprovalRequests}.projectId`, projectId)
- .where(`${TableName.ApprovalRequests}.type`, type)
- .where(`${TableName.ApprovalRequests}.scopeType`, ApprovalPolicyScope.Signer)
- .where(`${TableName.ApprovalRequests}.scopeId`, signerId)
+ const rows = (await db
+ .replicaNode()
+ .select("*")
+ .from($buildSignerRequestsQuery({ signerId, projectId, type }))
.modify((qb) => {
if (statuses?.length) {
- void qb.whereIn(`${TableName.ApprovalRequests}.status`, statuses);
+ void qb.whereIn("accessStatus", statuses);
}
})
- .distinctOn(`${TableName.ApprovalRequests}.id`)
- .select(
- `${TableName.ApprovalRequests}.*`,
- db.ref("attributes").withSchema(TableName.ApprovalRequestGrants).as("grantAttributes"),
- db.ref("expiresAt").withSchema(TableName.ApprovalRequestGrants).as("grantExpiresAt"),
- db.ref("status").withSchema(TableName.ApprovalRequestGrants).as("grantStatus"),
- db.raw('COALESCE("usage"."usedSignings", 0) AS "usedSignings"')
- )
- .orderByRaw(
- `"${TableName.ApprovalRequests}"."id", ("${TableName.ApprovalRequestGrants}"."status" = ?) DESC NULLS LAST, "${TableName.ApprovalRequestGrants}"."createdAt" DESC NULLS LAST`,
- [ApprovalRequestGrantStatus.Active]
- )
- .as("dedup");
-
- const rows = (await db
- .replicaNode()
- .select("*")
- .from(dedupedRequests)
.orderBy("createdAt", "desc")
.offset(offset)
.limit(limit)) as (TApprovalRequests & {
@@ -76,6 +114,7 @@ export const signerRequestDALFactory = (db: TDbClient) => {
grantExpiresAt?: Date | string | null;
grantStatus?: string | null;
usedSignings?: string | number;
+ accessStatus: string;
})[];
return rows.map((row) => ({
...row,
@@ -101,13 +140,16 @@ export const signerRequestDALFactory = (db: TDbClient) => {
statuses?: string[];
}) => {
try {
- const query = db
- .replicaNode()(TableName.ApprovalRequests)
- .where({ projectId, type, scopeType: ApprovalPolicyScope.Signer, scopeId: signerId });
- if (statuses?.length) {
- void query.whereIn("status", statuses);
- }
- const result = (await query.count("* as count").first()) as { count: string | number } | undefined;
+ const result = (await db
+ .replicaNode()
+ .from($buildSignerRequestsQuery({ signerId, projectId, type }))
+ .modify((qb) => {
+ if (statuses?.length) {
+ void qb.whereIn("accessStatus", statuses);
+ }
+ })
+ .count("* as count")
+ .first()) as { count: string | number } | undefined;
return Number(result?.count ?? 0);
} catch (error) {
throw new DatabaseError({ error, name: "CountSignerRequests" });
diff --git a/backend/src/services/signer/signer-request-fns.test.ts b/backend/src/services/signer/signer-request-fns.test.ts
new file mode 100644
index 0000000000..35cf9f5787
--- /dev/null
+++ b/backend/src/services/signer/signer-request-fns.test.ts
@@ -0,0 +1,57 @@
+import { describe, expect, it } from "vitest";
+
+import { ApprovalRequestGrantStatus, ApprovalRequestStatus } from "../approval-policy/approval-policy-enums";
+import { isSignerRequestRevocable } from "./signer-request-fns";
+
+const now = new Date("2026-11-03T12:00:00.000Z");
+const past = new Date("2026-11-03T11:59:00.000Z");
+const future = new Date("2026-11-03T12:01:00.000Z");
+
+describe("isSignerRequestRevocable", () => {
+ it("allows revoking a pending request", () => {
+ expect(isSignerRequestRevocable({ status: ApprovalRequestStatus.Pending }, [], now)).toBe(true);
+ });
+
+ it("allows revoking an approved request whose grant is still inside its window", () => {
+ expect(
+ isSignerRequestRevocable(
+ { status: ApprovalRequestStatus.Approved },
+ [{ status: ApprovalRequestGrantStatus.Active, expiresAt: future }],
+ now
+ )
+ ).toBe(true);
+ });
+
+ it("allows revoking an approved request whose grant has no window", () => {
+ expect(
+ isSignerRequestRevocable(
+ { status: ApprovalRequestStatus.Approved },
+ [{ status: ApprovalRequestGrantStatus.Active, expiresAt: null }],
+ now
+ )
+ ).toBe(true);
+ });
+
+ it("refuses an approved request whose grant is past its window but not yet marked expired", () => {
+ expect(
+ isSignerRequestRevocable(
+ { status: ApprovalRequestStatus.Approved },
+ [{ status: ApprovalRequestGrantStatus.Active, expiresAt: past }],
+ now
+ )
+ ).toBe(false);
+ });
+
+ it("refuses an approved request with no active grant", () => {
+ expect(isSignerRequestRevocable({ status: ApprovalRequestStatus.Approved }, [], now)).toBe(false);
+ });
+
+ it.each([ApprovalRequestStatus.Rejected, ApprovalRequestStatus.Cancelled, ApprovalRequestStatus.Expired])(
+ "refuses a %s request",
+ (status) => {
+ expect(
+ isSignerRequestRevocable({ status }, [{ status: ApprovalRequestGrantStatus.Active, expiresAt: future }], now)
+ ).toBe(false);
+ }
+ );
+});
diff --git a/backend/src/services/signer/signer-request-fns.ts b/backend/src/services/signer/signer-request-fns.ts
new file mode 100644
index 0000000000..81ef08b2f4
--- /dev/null
+++ b/backend/src/services/signer/signer-request-fns.ts
@@ -0,0 +1,20 @@
+import { ApprovalRequestGrantStatus, ApprovalRequestStatus } from "../approval-policy/approval-policy-enums";
+
+type TRevocableGrant = { status: string; expiresAt?: Date | string | null };
+
+// A request that is no longer pending can only be revoked while one of its grants still gives access. Revoking one
+// whose access already ended would rewrite its history from expired to revoked.
+export const isSignerRequestRevocable = (
+ request: { status: string },
+ activeGrants: TRevocableGrant[],
+ now: Date = new Date()
+) => {
+ if (request.status === ApprovalRequestStatus.Pending) return true;
+ if (request.status !== ApprovalRequestStatus.Approved) return false;
+
+ return activeGrants.some(
+ (grant) =>
+ grant.status === ApprovalRequestGrantStatus.Active &&
+ (!grant.expiresAt || new Date(grant.expiresAt).getTime() > now.getTime())
+ );
+};
diff --git a/frontend/src/hooks/api/signers/types.ts b/frontend/src/hooks/api/signers/types.ts
index 8bec3e7065..b235d1b7b8 100644
--- a/frontend/src/hooks/api/signers/types.ts
+++ b/frontend/src/hooks/api/signers/types.ts
@@ -318,6 +318,7 @@ export type TSignerRequest = {
maxSignings?: number | null;
usedSignings?: number;
grantStatus?: string | null;
+ accessStatus?: SignerRequestStatus;
createdAt: string;
updatedAt: string;
};
diff --git a/frontend/src/pages/cert-manager/SignerDetailPage/components/SignerRequestsTab/ExpiresCell.tsx b/frontend/src/pages/cert-manager/SignerDetailPage/components/SignerRequestsTab/ExpiresCell.tsx
index f2a9a62e19..1f8d40f736 100644
--- a/frontend/src/pages/cert-manager/SignerDetailPage/components/SignerRequestsTab/ExpiresCell.tsx
+++ b/frontend/src/pages/cert-manager/SignerDetailPage/components/SignerRequestsTab/ExpiresCell.tsx
@@ -10,17 +10,22 @@ export const ExpiresCell = ({ req }: { req: TSignerRequest }) => {
if (req.status === SignerRequestStatus.Pending) {
return <span>Awaiting approval</span>;
}
- if (req.status !== SignerRequestStatus.Approved) return null;
+ if (!req.grantStatus) return null;
+ const accessStatus = req.accessStatus ?? req.status;
const max = req.maxSignings ?? null;
const used = req.usedSignings ?? 0;
const left = max != null ? Math.max(0, max - used) : null;
- const grantInactive = req.grantStatus != null && req.grantStatus !== "active";
+ const windowEnded = !!req.expiresAt && new Date(req.expiresAt).getTime() <= Date.now();
let expiryLabel: string;
let expiryTooltip: string;
- if (grantInactive) {
- expiryLabel = `Grant ${req.grantStatus}`;
+ if (
+ accessStatus === SignerRequestStatus.Cancelled ||
+ (req.grantStatus === "expired" && !windowEnded)
+ ) {
+ expiryLabel =
+ accessStatus === SignerRequestStatus.Cancelled ? "Grant revoked" : "Grant expired";
expiryTooltip = req.expiresAt
? format(new Date(req.expiresAt), "MMM d, yyyy 'at' h:mm a")
: "Grant no longer active";
diff --git a/frontend/src/pages/cert-manager/SignerDetailPage/components/SignerRequestsTab/SignerRequestsTab.tsx b/frontend/src/pages/cert-manager/SignerDetailPage/components/SignerRequestsTab/SignerRequestsTab.tsx
index 5124ffe869..dbaf33535f 100644
--- a/frontend/src/pages/cert-manager/SignerDetailPage/components/SignerRequestsTab/SignerRequestsTab.tsx
+++ b/frontend/src/pages/cert-manager/SignerDetailPage/components/SignerRequestsTab/SignerRequestsTab.tsx
@@ -243,9 +243,10 @@ export const SignerRequestsTab = ({ signerId, canPreApprove, canRequestSign }: P
<TableBody>
{requests.map((req: TSignerRequest) => {
const member = resolveMember(req);
+ const accessStatus = req.accessStatus ?? req.status;
const isRevocable =
- req.status === SignerRequestStatus.Pending ||
- req.status === SignerRequestStatus.Approved;
+ accessStatus === SignerRequestStatus.Pending ||
+ accessStatus === SignerRequestStatus.Approved;
const created = new Date(req.createdAt);
return (
<TableRow
@@ -303,7 +304,9 @@ export const SignerRequestsTab = ({ signerId, canPreApprove, canRequestSign }: P
</div>
</TableCell>
<TableCell>
- <Badge variant={statusVariant(req.status)}>{statusLabel(req.status)}</Badge>
+ <Badge variant={statusVariant(accessStatus)}>
+ {statusLabel(accessStatus)}
+ </Badge>
</TableCell>
<TableCell className="text-accent">
<Tooltip>