Skip to content

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

misc review fixes

Andreyd9e7ac2ea8fb
diff --git a/backend/src/ee/routes/v1/pam-routers/pam-access-request-router.ts b/backend/src/ee/routes/v1/pam-routers/pam-access-request-router.ts
index 5361c49a53..9ee401de74 100644
--- a/backend/src/ee/routes/v1/pam-routers/pam-access-request-router.ts
+++ b/backend/src/ee/routes/v1/pam-routers/pam-access-request-router.ts
@@ -17,7 +17,7 @@ import {
AutoApprovalOutcomeSchema
} from "@app/services/approval-policy/auto-approval/auto-approval-schemas";
import { parsePamAccessDuration } from "@app/services/approval-policy/pam-access/pam-access-policy-fns";
-import { AuthMode } from "@app/services/auth/auth-type";
+import { ActorType, AuthMode } from "@app/services/auth/auth-type";
import { PostHogEventTypes } from "@app/services/telemetry/telemetry-types";
// The evidence holds data fetched from other services, so only its outcome is returned
@@ -154,6 +154,7 @@ export const registerPamAccessRequestRouter = async (server: FastifyZodProvider)
if (autoApprovedEvent) {
await server.services.auditLog.createAuditLog({
...req.auditLogInfo,
+ actor: { type: ActorType.PLATFORM, metadata: {} },
orgId: req.permission.orgId,
projectId: req.internalPamProjectId,
event: autoApprovedEvent
diff --git a/backend/src/ee/services/audit-log/audit-log-types.ts b/backend/src/ee/services/audit-log/audit-log-types.ts
index 8b92d4f532..ba7d228ed3 100644
--- a/backend/src/ee/services/audit-log/audit-log-types.ts
+++ b/backend/src/ee/services/audit-log/audit-log-types.ts
@@ -7161,7 +7161,7 @@ interface PamAccessPolicyBypassedEvent {
interface PamAccessRequestAutoApprovedEvent {
type: EventType.PAM_ACCESS_REQUEST_AUTO_APPROVED;
metadata: {
- requestId: string;
+ approvalRequestId: string;
grantId?: string;
accountId?: string;
accountName?: string;
diff --git a/backend/src/ee/services/pam-access-request/pam-access-approval-resource.ts b/backend/src/ee/services/pam-access-request/pam-access-approval-resource.ts
index 1d7e2c0c39..33d70084d1 100644
--- a/backend/src/ee/services/pam-access-request/pam-access-approval-resource.ts
+++ b/backend/src/ee/services/pam-access-request/pam-access-approval-resource.ts
@@ -1074,7 +1074,7 @@ export const pamAccessApprovalResourceFactory = ({
type: EventType.PAM_ACCESS_REQUEST_AUTO_APPROVED,
metadata: {
...scope,
- requestId: request.id,
+ approvalRequestId: request.id,
grantId: grantId ?? grant?.id,
requesterName: request.requesterName,
requesterEmail: request.requesterEmail,
@@ -1163,6 +1163,7 @@ export const pamAccessApprovalResourceFactory = ({
verifyPolicyActors,
assertCanCreateRequest,
assertCanReview,
+ supportsAutoApproval: true,
allowsAutoApproval,
isBreakGlassEligible,
assertBreakGlassEligible,
diff --git a/backend/src/server/routes/v1/approval-policy-routers/approval-policy-endpoints.ts b/backend/src/server/routes/v1/approval-policy-routers/approval-policy-endpoints.ts
index c85929a60a..8fb01434f4 100644
--- a/backend/src/server/routes/v1/approval-policy-routers/approval-policy-endpoints.ts
+++ b/backend/src/server/routes/v1/approval-policy-routers/approval-policy-endpoints.ts
@@ -37,7 +37,7 @@ import {
CreatePamAccessPolicySchema,
UpdatePamAccessPolicySchema
} from "@app/services/approval-policy/pam-access/pam-access-policy-schemas";
-import { AuthMode } from "@app/services/auth/auth-type";
+import { ActorType, AuthMode } from "@app/services/auth/auth-type";
import { PostHogEventTypes, TPostHogEvent } from "@app/services/telemetry/telemetry-types";
type TCreatePolicySchema =
@@ -534,6 +534,7 @@ export const registerApprovalPolicyEndpoints = ({
if (autoApprovalSummary) {
await server.services.auditLog.createAuditLog({
...req.auditLogInfo,
+ actor: { type: ActorType.PLATFORM, metadata: {} },
orgId: req.permission.orgId,
projectId: request.projectId,
event: (await server.services.approvalPolicy.buildAuditEvent({
diff --git a/backend/src/services/app-connection/jira/jira-connection-fns.ts b/backend/src/services/app-connection/jira/jira-connection-fns.ts
index cc89288dd4..9aff58421d 100644
--- a/backend/src/services/app-connection/jira/jira-connection-fns.ts
+++ b/backend/src/services/app-connection/jira/jira-connection-fns.ts
@@ -36,6 +36,7 @@ export type TJiraRequestConfig = DiscriminativePick<
type TJiraRequest = {
path: string;
params?: Record<string, string | number | undefined>;
+ headers?: Record<string, string>;
};
export const getJiraConnectionListItem = () => ({
@@ -76,7 +77,7 @@ const getJiraTlsOptions = (config: TJiraRequestConfig) => {
export const jiraRequest = async <T>(
config: TJiraRequestConfig,
- { path, params }: TJiraRequest,
+ { path, params, headers: extraHeaders }: TJiraRequest,
{ gatewayV2Service, gatewayPoolService }: TJiraGatewayDeps = {}
): Promise<T> => {
const { gatewayId: directGatewayId, gatewayPoolId } = config;
@@ -98,7 +99,7 @@ export const jiraRequest = async <T>(
}
const url = new URL(`${removeTrailingSlash(config.credentials.instanceUrl)}${path}`);
- const headers = { Authorization: getJiraAuthorizationHeader(config), Accept: "application/json" };
+ const headers = { Authorization: getJiraAuthorizationHeader(config), Accept: "application/json", ...extraHeaders };
const { ca, rejectUnauthorized } = getJiraTlsOptions(config);
const baseRequestConfig: AxiosRequestConfig = {
@@ -441,7 +442,9 @@ export const listJiraIssueApprovals = async (
config,
{
path: `/rest/servicedeskapi/request/${encodeURIComponent(issueKey)}/approval`,
- params: { start, limit: JIRA_PAGE_SIZE }
+ params: { start, limit: JIRA_PAGE_SIZE },
+ // Data Center rejects this experimental endpoint without the opt-in header
+ headers: { "X-ExperimentalApi": "opt-in" }
},
deps
);
@@ -452,8 +455,9 @@ export const listJiraIssueApprovals = async (
page += 1;
}
+ // The newest decision could be on a page that wasn't read
if (!isLastPage) {
- logger.warn(`listJiraIssueApprovals: stopped after ${JIRA_MAX_PAGES} pages [issueKey=${issueKey}]`);
+ throw new BadRequestError({ message: `${issueKey} has more Jira approvals than Infisical can read` });
}
return approvals;
diff --git a/backend/src/services/approval-policy/approval-policy-service.ts b/backend/src/services/approval-policy/approval-policy-service.ts
index a9ce2270c4..1aee5a64b9 100644
--- a/backend/src/services/approval-policy/approval-policy-service.ts
+++ b/backend/src/services/approval-policy/approval-policy-service.ts
@@ -326,9 +326,9 @@ export const approvalPolicyServiceFactory = ({
const $assertSupportsAutoApproval = (policyType: ApprovalPolicyType, autoApproval?: TAutoApprovalConfig) => {
const configuresAutoApproval = Boolean(autoApproval?.rules.length || autoApproval?.inputs.length);
- if (configuresAutoApproval && policyType === ApprovalPolicyType.CertRequest) {
+ if (configuresAutoApproval && !resources[policyType]?.supportsAutoApproval) {
throw new BadRequestError({
- message: "Auto-approval rules aren't available for certificate request policies"
+ message: `Auto-approval rules aren't available for ${policyType} policies`
});
}
};
@@ -1347,30 +1347,25 @@ export const approvalPolicyServiceFactory = ({
}
}
- const parsedInputs = await autoApprovalService.parseInputValues({
- stored: storedAutoApproval,
- values: autoApprovalInputs ?? [],
- orgId: actor.orgId,
- projectId
- });
-
let autoApprovalEvidence: TAutoApprovalEvidence | null = null;
- if (storedAutoApproval?.rules.length && !skipAutoApproval) {
+ if (storedAutoApproval?.rules.length && !skipAutoApproval && actor.type === ActorType.USER) {
const allowed =
(await resource.allowsAutoApproval?.({ projectId, requestData: requestData as TApprovalRequestData })) ?? true;
if (allowed) {
+ const parsedInputs = await autoApprovalService.parseInputValues({
+ stored: storedAutoApproval,
+ values: autoApprovalInputs ?? [],
+ orgId: actor.orgId,
+ projectId
+ });
autoApprovalEvidence = await autoApprovalService.evaluate({
stored: storedAutoApproval,
parsedInputs,
usedInputIds: await $findUsedInputIds(policy.id, storedAutoApproval, parsedInputs),
orgId: actor.orgId,
projectId,
- ctx: {
- requester: {
- email: actor.type === ActorType.USER ? requesterEmail || null : null
- }
- }
+ ctx: { requester: { email: requesterEmail || null } }
});
}
}
@@ -2306,7 +2301,7 @@ export const approvalPolicyServiceFactory = ({
scopeType,
scopeId,
actor,
- ResourcePermissionApprovalPolicyActions.Read,
+ ResourcePermissionApprovalPolicyActions.Edit,
policyType
);
diff --git a/backend/src/services/approval-policy/approval-policy-types.ts b/backend/src/services/approval-policy/approval-policy-types.ts
index f1c53b953c..114106c12d 100644
--- a/backend/src/services/approval-policy/approval-policy-types.ts
+++ b/backend/src/services/approval-policy/approval-policy-types.ts
@@ -213,6 +213,8 @@ export type TApprovalResource<
) => Promise<{ grantId: string } | void>;
postApprovalRoutine?: (request: TApprovalRequest, actor?: TApprovalActor) => Promise<void>;
+ // Policies of this type can hold auto-approval rules
+ supportsAutoApproval?: boolean;
// Whether the policy's auto-approval rules may decide this request
allowsAutoApproval?: (args: {
projectId: string;
diff --git a/backend/src/services/approval-policy/auto-approval/auto-approval-dal.ts b/backend/src/services/approval-policy/auto-approval/auto-approval-dal.ts
index a18af187f8..5bbee4c0f7 100644
--- a/backend/src/services/approval-policy/auto-approval/auto-approval-dal.ts
+++ b/backend/src/services/approval-policy/auto-approval/auto-approval-dal.ts
@@ -85,6 +85,7 @@ export const approvalPolicyAutoApprovalDALFactory = (db: TDbClient) => {
// Replaces a policy's inputs and rules, the way policy steps are replaced
const replaceForPolicy = async (policyId: string, config: TAutoApprovalConfig, tx: Knex) => {
+ await tx(TableName.ApprovalPolicies).where({ id: policyId }).forUpdate().first();
await rulesOrm.delete({ policyId }, tx);
await inputsOrm.delete({ policyId }, tx);
diff --git a/backend/src/services/approval-policy/auto-approval/auto-approval-schemas.ts b/backend/src/services/approval-policy/auto-approval/auto-approval-schemas.ts
index c3a10aec98..488fb2d002 100644
--- a/backend/src/services/approval-policy/auto-approval/auto-approval-schemas.ts
+++ b/backend/src/services/approval-policy/auto-approval/auto-approval-schemas.ts
@@ -1,15 +1,11 @@
import { z } from "zod";
import { APPROVAL_POLICY_AUTO_APPROVAL as DOCS } from "@app/lib/api-docs";
+import { slugSchema } from "@app/server/lib/schemas";
import { AutoApprovalConstraintValue } from "./auto-approval-types";
-const IdentifierSchema = z
- .string()
- .trim()
- .min(1)
- .max(64)
- .regex(/^[a-z0-9-]+$/, "Must contain only lowercase letters, numbers, and hyphens");
+const IdentifierSchema = slugSchema({ field: "Identifier" });
const ConditionValueSchema = z.string().trim().min(1, "Values cannot be empty").max(255);
diff --git a/backend/src/services/approval-policy/auto-approval/providers/jira-auto-approval-provider.ts b/backend/src/services/approval-policy/auto-approval/providers/jira-auto-approval-provider.ts
index 22ee50b4a1..cefd8cad6b 100644
--- a/backend/src/services/approval-policy/auto-approval/providers/jira-auto-approval-provider.ts
+++ b/backend/src/services/approval-policy/auto-approval/providers/jira-auto-approval-provider.ts
@@ -1,5 +1,8 @@
+import RE2 from "re2";
+
import { BadRequestError } from "@app/lib/errors";
import { removeTrailingSlash } from "@app/lib/fn";
+import { logger } from "@app/lib/logger";
import { AppConnection } from "@app/services/app-connection/app-connection-enums";
import {
getJiraErrorMessage,
@@ -46,7 +49,7 @@ export type TJiraTicketFacts = {
};
const JIRA_TICKET_FIELDS = ["status", "project", "issuetype", "labels", "assignee"];
-const JIRA_ISSUE_KEY_REGEX = /^[A-Z][A-Z0-9_]+-[1-9][0-9]*$/;
+const JIRA_ISSUE_KEY_REGEX = new RE2("^[A-Z][A-Z0-9_]+-[1-9][0-9]*$");
const MAX_TICKET_INPUT_LENGTH = 2048;
const MAX_STORED_LABELS = 100;
const MAX_OPTIONS = 100;
@@ -124,13 +127,20 @@ export const parseJiraTicket = (userInput: string, conn: Pick<TJiraConnection, "
return key;
};
-// A hidden email can't be confirmed to be the requester's, so only an exact, visible email matches
const matchAssigneeToRequester = (
issue: TJiraIssue,
ctx: TAutoApprovalContext
): NonNullable<TJiraTicketFacts["assignee"]> => {
+ const assignee = issue.fields?.assignee;
+ if (!assignee) return { matchesRequester: false, reason: `${issue.key} isn't assigned to anyone` };
+
+ // A hidden email can't be confirmed to be the requester's, so only an exact, visible email matches
+ const assigneeEmail = assignee.emailAddress?.trim().toLowerCase();
+ if (!assigneeEmail) {
+ return { matchesRequester: false, reason: `Jira doesn't share the email address of ${issue.key}'s assignee` };
+ }
+
const email = ctx.requester.email?.trim().toLowerCase();
- const assigneeEmail = issue.fields?.assignee?.emailAddress?.trim().toLowerCase();
return email && assigneeEmail === email
? { matchesRequester: true, reason: null }
: { matchesRequester: false, reason: `${issue.key} isn't assigned to the requester` };
@@ -141,14 +151,24 @@ const readLatestApproval = async (
key: string,
deps: TAutoApprovalProviderDeps
): Promise<NonNullable<TJiraTicketFacts["approval"]>> => {
- const notApproved = { approved: false, reason: `${key} isn't approved in Jira` };
try {
const approvals = await listJiraIssueApprovals(conn, key, deps);
+ if (!approvals.length) return { approved: false, reason: `${key} has no approvals in Jira yet` };
+
const sorted = [...approvals].sort((a, b) => (a.createdDate?.epochMillis ?? 0) - (b.createdDate?.epochMillis ?? 0));
- return sorted[sorted.length - 1]?.finalDecision === "approved" ? { approved: true, reason: null } : notApproved;
+ return sorted[sorted.length - 1]?.finalDecision === "approved"
+ ? { approved: true, reason: null }
+ : { approved: false, reason: `${key} isn't approved in Jira` };
} catch (error) {
- if (isJiraNotFoundError(error)) return notApproved;
- return { approved: false, reason: `Couldn't read Jira approvals on ${key}: ${getJiraErrorMessage(error)}` };
+ if (isJiraNotFoundError(error)) {
+ return {
+ approved: false,
+ reason: `${key} isn't a Jira Service Management request, or the Jira connection can't see its approvals`
+ };
+ }
+ if (error instanceof BadRequestError) return { approved: false, reason: error.message };
+ logger.warn({ err: error }, `Couldn't read Jira approvals [issueKey=${key}]`);
+ return { approved: false, reason: `Couldn't read Jira approvals on ${key}` };
}
};
@@ -178,7 +198,9 @@ export const JIRA_AUTO_APPROVAL_PROVIDER: TAutoApprovalProvider<TJiraConnection>
message: `Jira ticket ${id} doesn't exist, or the Jira connection can't see it`
});
}
- throw new BadRequestError({ message: `Couldn't read Jira ticket ${id}: ${getJiraErrorMessage(error)}` });
+ if (error instanceof BadRequestError) throw error;
+ logger.warn({ err: error }, `Couldn't read Jira ticket [issueKey=${id}]`);
+ throw new BadRequestError({ message: `Couldn't read Jira ticket ${id}` });
}
const key = issue.key || id;
diff --git a/docs/documentation/platform/pam/access-requests/auto-approval.mdx b/docs/documentation/platform/pam/access-requests/auto-approval.mdx
index 4c2df5b66a..b88552ac2d 100644
--- a/docs/documentation/platform/pam/access-requests/auto-approval.mdx
+++ b/docs/documentation/platform/pam/access-requests/auto-approval.mdx
@@ -85,7 +85,7 @@ Every linked record also has a **hasn't been used before** check. It passes only
| Check | Passes when |
| --- | --- |
-| **is assigned to the requester** | The ticket's assignee has the same email address in Jira as the requester has in Infisical (it never passes if the assignee hides their email address in Jira) |
+| **is assigned to the requester** | The ticket's assignee has the same email address in Jira as the requester has in Infisical (it never passes if Jira hides the assignee's email address, through the assignee's profile on Jira Cloud or the **User email visibility** setting on Jira Data Center) |
| **is approved in Jira** | The ticket is a Jira Service Management request, and its latest approval was approved |
| **has status** | The ticket's status is one of the values |
| **is in project** | The ticket is in one of the projects |
@@ -110,9 +110,9 @@ If you turn on **Break glass** in the form, the record fields disappear, because
The outcome of the rules shows up in these places:
-- **Approval Requests**: the **Auto-approval status** section of each request shows the rule that approved it and the linked records, or, if no rule passed, why each rule failed (select a rule to see all of its conditions)
+- **Approval Requests**: for each request waiting on your approval, the **Auto-approval status** section shows the linked records and why each rule failed (select a rule to see all of its conditions)
- Notifications: approvers get an email and an in-app notification when a rule approves a request
-- The folder's **Approvals** tab: under **Access Requests**, auto-approved requests have the **Auto-approved** status, and a Folder Admin can revoke the access from an auto-approved request, as with any other approved request
+- The folder's **Approvals** tab: under **Access Requests**, auto-approved requests have the **Auto-approved** status. Hover over it to see the rule that approved the request. A Folder Admin can revoke the access from an auto-approved request, as with any other approved request
- The [audit log](/documentation/platform/pam/auditing): each auto-approval adds a **PAM Access Request Auto-Approved** event with the rule, its conditions, the linked records, the account, and the folder
## How Infisical checks the rules
@@ -122,6 +122,7 @@ Infisical checks the rules once, when the request is submitted, by reading each
- Later changes in the service don't affect the result, so closing a ticket doesn't revoke access that a rule granted, and a pending request isn't approved when its record passes later
- If no record was linked, or Infisical can't read the record (the service doesn't respond or rejects the connection's credentials, the record doesn't exist, or the connection's user can't see it), every condition on that record fails
- A record can be linked to any number of requests, and each request passes as long as the record still passes the rule (unless the rule also requires that the record **hasn't been used before**)
+- Rules only apply to requests from users. A machine identity's request waits for the folder's approvers, or is rejected if the folder has none
<Warning>
Infisical trusts what the linked service reports. It can't tell whether a requester approved their own ticket or assigned another person's ticket to themselves before linking it. Prevent both in the service itself. For example, in Jira Service Management, exclude the reporter and assignee from approving requests, and limit who can assign tickets.
diff --git a/frontend/src/hooks/api/auditLogs/types.tsx b/frontend/src/hooks/api/auditLogs/types.tsx
index 1e4b4d6777..cdcb74bb06 100644
--- a/frontend/src/hooks/api/auditLogs/types.tsx
+++ b/frontend/src/hooks/api/auditLogs/types.tsx
@@ -981,7 +981,7 @@ interface PamAccessPolicyBypassedEvent {
interface PamAccessRequestAutoApprovedEvent {
type: EventType.PAM_ACCESS_REQUEST_AUTO_APPROVED;
metadata: {
- requestId: string;
+ approvalRequestId: string;
grantId?: string;
accountId?: string;
accountName?: string;
diff --git a/frontend/src/pages/pam/PamAccountsPage/components/FolderApprovalsTab.tsx b/frontend/src/pages/pam/PamAccountsPage/components/FolderApprovalsTab.tsx
index 5174b1607c..9b3ab1d9ed 100644
--- a/frontend/src/pages/pam/PamAccountsPage/components/FolderApprovalsTab.tsx
+++ b/frontend/src/pages/pam/PamAccountsPage/components/FolderApprovalsTab.tsx
@@ -78,7 +78,7 @@ import { getRequestStatusInfo, isGrantActive } from "../../components/approvalRe
import { AutoApprovalCard } from "../../components/auto-approval/AutoApprovalCard";
import {
EMPTY_AUTO_APPROVAL_DRAFT,
- getRuleError,
+ isRuleComplete,
serializeAutoApprovalDraft,
TAutoApprovalDraft,
toAutoApprovalConfig,
@@ -369,7 +369,7 @@ export const FolderApprovalsTab = ({ folderId, onDirtyChange }: Props) => {
return;
}
- if (autoApprovalDraft.rules.some((rule) => getRuleError(rule, autoApprovalCatalog))) {
+ if (autoApprovalDraft.rules.some((rule) => !isRuleComplete(rule, autoApprovalCatalog))) {
setShowAutoApprovalErrors(true);
createNotification({ type: "error", text: "Finish the auto-approval rules before saving" });
return;
diff --git a/frontend/src/pages/pam/PamApprovalRequestsPage/components/ApprovalRequestDetailSheet.tsx b/frontend/src/pages/pam/PamApprovalRequestsPage/components/ApprovalRequestDetailSheet.tsx
index 1881c940d2..bda914380c 100644
--- a/frontend/src/pages/pam/PamApprovalRequestsPage/components/ApprovalRequestDetailSheet.tsx
+++ b/frontend/src/pages/pam/PamApprovalRequestsPage/components/ApprovalRequestDetailSheet.tsx
@@ -26,7 +26,10 @@ import { TPamAccessRequest } from "@app/hooks/api/pam/types";
import { AccountPlatformIcon } from "../../components/AccountPlatformIcon";
import { getRequestStatusInfo, isGrantActive } from "../../components/approvalRequestStatus";
-import { AutoApprovalResults } from "../../components/auto-approval/AutoApprovalResults";
+import {
+ AutoApprovalResults,
+ LinkedRecordValue
+} from "../../components/auto-approval/AutoApprovalResults";
import { formatDuration } from "../../components/formatDuration";
import { PamDetailSheet } from "../../components/PamDetailSheet";
import { isMachineIdentityRequest } from "../../components/requesterDisplay";
@@ -143,7 +146,11 @@ export const ApprovalRequestDetailSheet = ({ request, isOpen, onOpenChange }: Pr
}
]
: []),
- { label: "Reason", value: requestData?.reason || "No reason provided" }
+ { label: "Reason", value: requestData?.reason || "No reason provided" },
+ ...(request?.autoApproval?.inputs ?? []).map((input) => ({
+ label: input.label,
+ value: <LinkedRecordValue input={input} />
+ }))
]}
contentFooter={
(isPending || canRevoke) && (
diff --git a/frontend/src/pages/pam/components/PamAccountRow.tsx b/frontend/src/pages/pam/components/PamAccountRow.tsx
index 2a668bb027..fdfd923650 100644
--- a/frontend/src/pages/pam/components/PamAccountRow.tsx
+++ b/frontend/src/pages/pam/components/PamAccountRow.tsx
@@ -40,7 +40,6 @@ const useNow = () => useSyncExternalStore(subscribeToTick, () => tickNow);
// Compact remaining time for the grant-expiry badge, e.g. "3h 41m"
const formatRemaining = (expiresAt: string, now: number) => {
const remainingMs = new Date(expiresAt).getTime() - now;
- if (remainingMs <= 0) return "Expired";
const totalMinutes = Math.floor(remainingMs / 60000);
const days = Math.floor(totalMinutes / 1440);
const hours = Math.floor((totalMinutes % 1440) / 60);
@@ -95,6 +94,7 @@ export const PamAccountRow = ({
const typeName = map[accountType]?.name ?? accountType;
const isGranted = accessStatus === PamAccessStatus.Granted;
+ const isGrantExpired = Boolean(grantExpiresAt && new Date(grantExpiresAt).getTime() <= now);
const isPending = accessStatus === PamAccessStatus.Pending;
// Row click mirrors the primary action icon, and only fires when the user can actually act.
@@ -216,9 +216,9 @@ export const PamAccountRow = ({
<TableCell className="w-40">
<div className="flex items-center justify-end gap-2.5">
{isGranted && grantExpiresAt && (
- <Badge variant="success">
+ <Badge variant={isGrantExpired ? "neutral" : "success"}>
<Clock className="mr-1 size-3" />
- Expires in {formatRemaining(grantExpiresAt, now)}
+ {isGrantExpired ? "Expired" : `Expires in ${formatRemaining(grantExpiresAt, now)}`}
</Badge>
)}
<div className="flex items-center gap-0.5">
diff --git a/frontend/src/pages/pam/components/auto-approval/AutoApprovalResults.tsx b/frontend/src/pages/pam/components/auto-approval/AutoApprovalResults.tsx
index 27b84a64be..ac2f8b2b46 100644
--- a/frontend/src/pages/pam/components/auto-approval/AutoApprovalResults.tsx
+++ b/frontend/src/pages/pam/components/auto-approval/AutoApprovalResults.tsx
@@ -7,6 +7,21 @@ type Props = {
outcome: TAutoApprovalOutcome;
};
+export const LinkedRecordValue = ({ input }: { input: TAutoApprovalOutcome["inputs"][number] }) =>
+ input.url ? (
+ <a
+ href={input.url}
+ target="_blank"
+ rel="noopener noreferrer"
+ className="inline-flex items-center gap-1 text-foreground underline-offset-2 hover:underline"
+ >
+ {input.value}
+ <ExternalLink className="size-3" />
+ </a>
+ ) : (
+ <span className="text-foreground">{input.value}</span>
+ );
+
const LinkedRecords = ({ inputs }: { inputs: TAutoApprovalOutcome["inputs"] }) => {
if (!inputs.length) return null;
@@ -14,20 +29,7 @@ const LinkedRecords = ({ inputs }: { inputs: TAutoApprovalOutcome["inputs"] }) =
<div className="flex flex-wrap gap-x-4 gap-y-1 text-xs">
{inputs.map((input) => (
<span key={`${input.label}:${input.value}`} className="text-muted">
- {input.label}:{" "}
- {input.url ? (
- <a
- href={input.url}
- target="_blank"
- rel="noopener noreferrer"
- className="inline-flex items-center gap-1 text-foreground underline-offset-2 hover:underline"
- >
- {input.value}
- <ExternalLink className="size-3" />
- </a>
- ) : (
- <span className="text-foreground">{input.value}</span>
- )}
+ {input.label}: <LinkedRecordValue input={input} />
</span>
))}
</div>
diff --git a/frontend/src/pages/pam/components/auto-approval/AutoApprovalRuleCard.tsx b/frontend/src/pages/pam/components/auto-approval/AutoApprovalRuleCard.tsx
index 4e71d26240..084115d08f 100644
--- a/frontend/src/pages/pam/components/auto-approval/AutoApprovalRuleCard.tsx
+++ b/frontend/src/pages/pam/components/auto-approval/AutoApprovalRuleCard.tsx
@@ -190,7 +190,7 @@ export const AutoApprovalRuleCard = ({
onRemove
}: Props) => {
const choices = getSubjectChoices(inputs, catalog);
- const ruleError = showErrors ? getRuleError(rule, catalog) : null;
+ const ruleError = showErrors ? getRuleError(rule) : null;
const missingChecks = [
...getSubjectsMissingCheck(rule, catalog, ASSIGNED_TO_REQUESTER_CONSTRAINT).map(
(condition) => ({
@@ -254,6 +254,7 @@ export const AutoApprovalRuleCard = ({
onChange={(e) => onChange({ ...rule, name: e.target.value })}
placeholder="Name this rule"
aria-label="Rule name"
+ aria-invalid={showErrors && !rule.name.trim()}
maxLength={128}
className={cn(
"-mx-1 min-w-0 flex-1 rounded-sm bg-transparent px-1 py-0.5 text-sm text-foreground outline-none placeholder:text-muted hover:bg-foreground/5 focus:bg-foreground/5",
diff --git a/frontend/src/pages/pam/components/auto-approval/autoApprovalDraft.ts b/frontend/src/pages/pam/components/auto-approval/autoApprovalDraft.ts
index 86ebad26d4..2ff1e30488 100644
--- a/frontend/src/pages/pam/components/auto-approval/autoApprovalDraft.ts
+++ b/frontend/src/pages/pam/components/auto-approval/autoApprovalDraft.ts
@@ -102,19 +102,19 @@ export const getConditionError = (
return null;
};
-export const getRuleError = (
- rule: TDraftRule,
- catalog: TAutoApprovalCatalogConnection[] | undefined
-): string | null => {
+export const getRuleError = (rule: TDraftRule): string | null => {
if (!rule.name.trim()) return "Name this rule";
- if (rule.conditions.length === 0) {
- return "Add at least one condition, or this rule would approve every request";
- }
- return rule.conditions.some((condition) => getConditionError(condition, catalog))
- ? "Finish every condition"
- : null;
+ if (rule.conditions.length === 0) return "Add at least one condition";
+ return null;
};
+export const isRuleComplete = (
+ rule: TDraftRule,
+ catalog: TAutoApprovalCatalogConnection[] | undefined
+) =>
+ !getRuleError(rule) &&
+ !rule.conditions.some((condition) => getConditionError(condition, catalog));
+
// The rule checks a record without this check, like an assignee check or the reuse check
export const getSubjectsMissingCheck = (
rule: TDraftRule,