Skip to content

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

address review

Andrey4a93323d116b
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 de3adda42a..20aaada79e 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
@@ -831,14 +831,14 @@ export const pamAccessApprovalResourceFactory = ({
const summary = getAutoApprovalSummary(request.autoApprovalEvidence);
const ruleName = summary?.ruleName ?? "an auto-approval rule";
const linkedRecords = summary?.linkedRecords.map(({ label, value }) => `${label} ${value}`).join(", ");
- const requestUrl = `${cfg.SITE_URL}/organizations/${orgId}/pam/approval-requests?requestId=${request.id}`;
+ const folderUrl = `${accountsUrl}/${encodeURIComponent(inputs.folderId)}`;
return {
inApp: {
type: NotificationType.ACCESS_APPROVAL_REQUEST_UPDATED,
title: "Access auto-approved",
body: `**${escapeMarkdown(requesterName)}** was granted ${accessTypeLabel} to **${escapeMarkdown(accountName)}** by the auto-approval rule "${escapeMarkdown(ruleName)}".`,
- link: requestUrl
+ link: folderUrl
},
email: {
subjectLine: "PAM Access Auto-Approved",
@@ -852,9 +852,23 @@ export const pamAccessApprovalResourceFactory = ({
accessTypeLabel,
ruleName,
linkedRecords: linkedRecords || undefined,
- requestUrl
+ folderUrl
}
- }
+ },
+ chat: (await $chatDeliveries(PamNotificationEvent.AccessRequestApproved, inputs.folderId)).map((target) => ({
+ ...target,
+ notification: {
+ type: TriggerFeature.PAM_ACCESS_REQUEST_APPROVED,
+ payload: {
+ requesterFullName: requesterName,
+ requesterEmail,
+ accountName,
+ folderName,
+ autoApprovalRuleName: ruleName,
+ approvalUrl: folderUrl
+ }
+ }
+ }))
};
}
diff --git a/backend/src/lib/workflow-integrations/types.ts b/backend/src/lib/workflow-integrations/types.ts
index 598e2b7249..ea1b7a5e01 100644
--- a/backend/src/lib/workflow-integrations/types.ts
+++ b/backend/src/lib/workflow-integrations/types.ts
@@ -97,6 +97,7 @@ export type TNotification =
accountName: string;
folderName: string;
comment?: string;
+ autoApprovalRuleName?: string;
approvalUrl: string;
};
}
diff --git a/backend/src/services/app-connection/app-connection-service.ts b/backend/src/services/app-connection/app-connection-service.ts
index 72a65b274d..841cf529ae 100644
--- a/backend/src/services/app-connection/app-connection-service.ts
+++ b/backend/src/services/app-connection/app-connection-service.ts
@@ -1211,9 +1211,17 @@ export const appConnectionServiceFactory = ({
err instanceof DatabaseError &&
(err.error as { code: string })?.code === DatabaseErrorCode.ForeignKeyViolation
) {
+ const { constraint } = err.error as { constraint?: string };
if (
- (err.error as { constraint?: string }).constraint === "certificate_authority_secret_appconnectionid_foreign"
+ constraint === "approval_policy_auto_approval_inputs_connectionid_foreign" ||
+ constraint === "approval_policy_auto_approval_conditions_connectionid_foreign"
) {
+ throw new BadRequestError({
+ message:
+ "Cannot delete this App Connection because one or more approval policies use it in their auto-approval rules. Remove it from those rules first."
+ });
+ }
+ if (constraint === "certificate_authority_secret_appconnectionid_foreign") {
throw new BadRequestError({
message:
"Cannot delete this App Connection because a certificate authority signs with an AWS KMS key reached through it. Delete that certificate authority first."
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 3cdc18c033..80dd10c724 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
@@ -2,10 +2,8 @@ import { BadRequestError } from "@app/lib/errors";
import { removeTrailingSlash } from "@app/lib/fn";
import { AppConnection } from "@app/services/app-connection/app-connection-enums";
import {
- findJiraUsersByEmail,
getJiraErrorMessage,
getJiraIssue,
- isJiraCloud,
isJiraNotFoundError,
listJiraIssueApprovals,
listJiraIssueTypes,
@@ -13,8 +11,7 @@ import {
listJiraStatuses,
searchJiraLabels,
TJiraConnection,
- TJiraIssue,
- TJiraUser
+ TJiraIssue
} from "@app/services/app-connection/jira";
import {
@@ -127,51 +124,20 @@ export const parseJiraTicket = (userInput: string, conn: Pick<TJiraConnection, "
return key;
};
-const isSameJiraUser = (conn: TJiraConnection, a: TJiraUser, b: TJiraUser) => {
- if (isJiraCloud(conn)) return Boolean(a.accountId) && a.accountId === b.accountId;
- return (Boolean(a.key) && a.key === b.key) || (Boolean(a.name) && a.name === b.name);
-};
-
-const matchAssigneeToRequester = async (
- conn: TJiraConnection,
+// 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,
- deps: TAutoApprovalProviderDeps
-): Promise<NonNullable<TJiraTicketFacts["assignee"]>> => {
- const { key } = issue;
+ ctx: TAutoApprovalContext
+): NonNullable<TJiraTicketFacts["assignee"]> => {
const email = ctx.requester.email?.trim().toLowerCase();
- const assignee = issue.fields?.assignee;
- const notAssigned = { matchesRequester: false, reason: `${key} isn't assigned to the requester` };
-
- if (!email)
+ if (!email) {
return { matchesRequester: false, reason: "Requests from machine identities can't match a Jira assignee" };
- if (!assignee) return notAssigned;
-
- if (assignee.emailAddress) {
- return assignee.emailAddress.toLowerCase() === email ? { matchesRequester: true, reason: null } : notAssigned;
}
- // Jira hides this assignee's email, so find the requester's own Jira account by email instead
- try {
- const users = (await findJiraUsersByEmail(conn, email, deps)).filter((user) => user.active !== false);
- const exactMatches = users.filter((user) => user.emailAddress?.toLowerCase() === email);
- // A user search matches email prefixes, so a hidden email only counts when it is the only candidate
- const candidates = exactMatches.length ? exactMatches : users.filter((user) => !user.emailAddress);
-
- if (candidates.length === 0) {
- return { matchesRequester: false, reason: "No Jira user has the requester's email address" };
- }
- if (candidates.length > 1) {
- return { matchesRequester: false, reason: "The requester's email address matches more than one Jira user" };
- }
-
- return isSameJiraUser(conn, candidates[0], assignee) ? { matchesRequester: true, reason: null } : notAssigned;
- } catch (error) {
- return {
- matchesRequester: false,
- reason: `Couldn't look up the requester in Jira: ${getJiraErrorMessage(error)}`
- };
- }
+ const assigneeEmail = issue.fields?.assignee?.emailAddress?.trim().toLowerCase();
+ return assigneeEmail === email
+ ? { matchesRequester: true, reason: null }
+ : { matchesRequester: false, reason: `${issue.key} isn't assigned to the requester` };
};
const readLatestApproval = async (
@@ -222,7 +188,7 @@ export const JIRA_AUTO_APPROVAL_PROVIDER: TAutoApprovalProvider<TJiraConnection>
const key = issue.key || id;
const [assignee, approval] = await Promise.all([
constraintIds.includes(JiraTicketConstraint.AssignedToRequester)
- ? matchAssigneeToRequester(conn, { ...issue, key }, ctx, deps)
+ ? matchAssigneeToRequester({ ...issue, key }, ctx)
: null,
constraintIds.includes(JiraTicketConstraint.Approved) ? readLatestApproval(conn, key, deps) : null
]);
diff --git a/backend/src/services/slack/slack-fns.ts b/backend/src/services/slack/slack-fns.ts
index 7603389ef1..b399b7c446 100644
--- a/backend/src/services/slack/slack-fns.ts
+++ b/backend/src/services/slack/slack-fns.ts
@@ -331,10 +331,16 @@ const buildSlackPayload = (notification: TNotification) => {
const accountName = escapeSlackMrkdwn(payload.accountName);
const folderName = escapeSlackMrkdwn(payload.folderName);
const comment = payload.comment ? escapeSlackMrkdwn(payload.comment) : undefined;
+ const autoApprovalRuleName = payload.autoApprovalRuleName
+ ? escapeSlackMrkdwn(payload.autoApprovalRuleName)
+ : undefined;
- const messageBody = `The access request from ${requesterFullName} (${requesterEmail}) for ${accountName} in the ${folderName} folder has been ${decision}.${
- comment ? `\n\nReviewer comment: ${comment}` : ""
- }`;
+ let detail = "";
+ if (autoApprovalRuleName)
+ detail = `\n\nApproved automatically by the auto-approval rule "${autoApprovalRuleName}".`;
+ else if (comment) detail = `\n\nReviewer comment: ${comment}`;
+
+ const messageBody = `The access request from ${requesterFullName} (${requesterEmail}) for ${accountName} in the ${folderName} folder has been ${decision}.${detail}`;
const headerBlocks = [
{
diff --git a/backend/src/services/smtp/emails/AccessPamRequestAutoApprovedTemplate.tsx b/backend/src/services/smtp/emails/AccessPamRequestAutoApprovedTemplate.tsx
index 55da741936..0fbd8a5bd5 100644
--- a/backend/src/services/smtp/emails/AccessPamRequestAutoApprovedTemplate.tsx
+++ b/backend/src/services/smtp/emails/AccessPamRequestAutoApprovedTemplate.tsx
@@ -15,7 +15,7 @@ interface AccessPamRequestAutoApprovedTemplateProps
accessTypeLabel: string;
ruleName: string;
linkedRecords?: string;
- requestUrl: string;
+ folderUrl: string;
}
export const AccessPamRequestAutoApprovedTemplate = ({
@@ -28,7 +28,7 @@ export const AccessPamRequestAutoApprovedTemplate = ({
accessTypeLabel,
ruleName,
linkedRecords,
- requestUrl
+ folderUrl
}: AccessPamRequestAutoApprovedTemplateProps) => {
const target = [folderName, accountName].filter(Boolean).join(" / ");
@@ -54,7 +54,7 @@ export const AccessPamRequestAutoApprovedTemplate = ({
)}
</Section>
<Section className="text-center">
- <BaseButton href={requestUrl}>View Request</BaseButton>
+ <BaseButton href={folderUrl}>View Folder</BaseButton>
</Section>
</BaseEmailWrapper>
);
@@ -71,6 +71,6 @@ AccessPamRequestAutoApprovedTemplate.PreviewProps = {
accessTypeLabel: "access",
ruleName: "Approved change ticket",
linkedRecords: "Jira ticket PAY-123",
- requestUrl: "https://infisical.com",
+ folderUrl: "https://infisical.com",
siteUrl: "https://infisical.com"
} as AccessPamRequestAutoApprovedTemplateProps;
diff --git a/docs/documentation/platform/pam/access-requests/auto-approval.mdx b/docs/documentation/platform/pam/access-requests/auto-approval.mdx
index f7c6302cdd..4dea82b1f8 100644
--- a/docs/documentation/platform/pam/access-requests/auto-approval.mdx
+++ b/docs/documentation/platform/pam/access-requests/auto-approval.mdx
@@ -83,7 +83,7 @@ Each condition runs one check on a linked record, and the checks available depen
| 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 (a request from a [machine identity](/documentation/platform/identities/machine-identities) never passes, because a machine identity has no email address) |
+| **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, or for a request from a [machine identity](/documentation/platform/identities/machine-identities), which has no email address) |
| **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 |
diff --git a/docs/integrations/app-connections/jira.mdx b/docs/integrations/app-connections/jira.mdx
index 702ed593f4..1646ad234b 100644
--- a/docs/integrations/app-connections/jira.mdx
+++ b/docs/integrations/app-connections/jira.mdx
@@ -20,7 +20,6 @@ Infisical acts as the Jira user who owns the token, so Infisical can only read t
The token's user needs these permissions in Jira:
- **Browse spaces** in Jira Cloud, or **Browse projects** in Jira Data Center, on every project whose tickets you want Infisical to read
-- **Browse users and groups**, so Infisical can look up a ticket's assignee when Jira hides the assignee's email address
- Permission to view customer requests in your Jira Service Management projects, so Infisical can read a request's approvals
Then create the token as that user: