Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
refactor: update PAM session status handling and improve enum definitions
Victor Santosd09849d9dc73
diff --git a/backend/src/ee/services/pam-session/pam-session-dal.ts b/backend/src/ee/services/pam-session/pam-session-dal.tsindex ad14f4976a..094614859c 100644--- a/backend/src/ee/services/pam-session/pam-session-dal.ts+++ b/backend/src/ee/services/pam-session/pam-session-dal.ts@@ -31,7 +31,7 @@ export const pamSessionDALFactory = (db: TDbClient) => {.where("id", sessionId).whereIn("status", [PamSessionStatus.Active, PamSessionStatus.Starting]).update({- status: PamSessionStatus.Expired,+ status: PamSessionStatus.Ended,endedAt: now});diff --git a/backend/src/ee/services/pam-session/pam-session-enums.ts b/backend/src/ee/services/pam-session/pam-session-enums.tsindex 299f2c29aa..33afe95e4a 100644--- a/backend/src/ee/services/pam-session/pam-session-enums.ts+++ b/backend/src/ee/services/pam-session/pam-session-enums.ts@@ -1,7 +1,6 @@export enum PamSessionStatus {Starting = "starting", // Starting, user connecting to resourceActive = "active", // Active, user is connected to resource- Ended = "ended", // Ended by user- Terminated = "terminated", // Terminated by an admin- Expired = "expired" // Automatically expired after expiresAt timestamp+ Ended = "ended", // Ended by user or automatically expired after expiresAt timestamp+ Terminated = "terminated" // Terminated by an admin}diff --git a/backend/src/ee/services/pam-session/pam-session-service.ts b/backend/src/ee/services/pam-session/pam-session-service.tsindex d984517e4f..bdb82e6502 100644--- a/backend/src/ee/services/pam-session/pam-session-service.ts+++ b/backend/src/ee/services/pam-session/pam-session-service.ts@@ -53,7 +53,7 @@ export const pamSessionServiceFactory = ({if (isActive && isExpired) {// eslint-disable-next-line @typescript-eslint/no-unsafe-assignmentconst updatedSession = await pamSessionDAL.updateById(session.id, {- status: PamSessionStatus.Expired,+ status: PamSessionStatus.Ended,endedAt: new Date()});// eslint-disable-next-line @typescript-eslint/no-unsafe-argument@@ -200,7 +200,7 @@ export const pamSessionServiceFactory = ({throw new ForbiddenRequestError({ message: "Only identities and users can perform this action" });}- if (session.status === PamSessionStatus.Ended || session.status === PamSessionStatus.Expired) {+ if (session.status === PamSessionStatus.Ended) {return {session,projectId: project.iddiff --git a/frontend/src/hooks/api/pam/enums.ts b/frontend/src/hooks/api/pam/enums.tsindex 9da4e74b8a..c6dfcd70c1 100644--- a/frontend/src/hooks/api/pam/enums.ts+++ b/frontend/src/hooks/api/pam/enums.ts@@ -29,8 +29,7 @@ export enum PamSessionStatus {Starting = "starting",Active = "active",Ended = "ended",- Terminated = "terminated",- Expired = "expired"+ Terminated = "terminated"}// Accountsdiff --git a/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/AwsIamAccountForm.tsx b/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/AwsIamAccountForm.tsxindex 904bee1cf2..87763b851b 100644--- a/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/AwsIamAccountForm.tsx+++ b/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/AwsIamAccountForm.tsx@@ -148,10 +148,10 @@ export const AwsIamAccountForm = ({ account, onSubmit }: Props) => {</AccordionTrigger><AccordionContent className="px-4 pb-2.5"><p className="mb-3 text-sm text-mineshaft-300">- The target role must have a trust policy that allows the Infisical PAM role you- created and used in the "Resources" tab to assume it. If you used the{" "}- <code className="rounded bg-mineshaft-700 px-1 text-xs">infisical-pam-*</code>{" "}- naming convention, no additional changes are needed to the PAM role.+ The target role must have a trust policy that allows the PAM role (created in the+ "Resources" tab) to assume it. If your target role name follows the+ wildcard pattern you defined in the PAM role's permissions policy, no+ additional changes are needed.</p><p className="mb-2 text-sm font-medium text-mineshaft-200">@@ -170,13 +170,12 @@ export const AwsIamAccountForm = ({ account, onSubmit }: Props) => {<code className="rounded bg-mineshaft-700 px-1"><YOUR_ACCOUNT_ID></code> withyour AWS account ID and{" "}<code className="rounded bg-mineshaft-700 px-1"><YOUR_PAM_ROLE_NAME></code>{" "}- with the name of the PAM role you created and used in the "Resources" tab- (e.g., <code className="rounded bg-mineshaft-700 px-1">InfisicalPAMRole</code>). The+ with the name of the PAM role you created in the "Resources" tab. TheExternal ID{" "}<code className="rounded bg-mineshaft-700 px-1 font-bold">{projectId}</code> is your- current project ID. If your target role name doesn't follow the{" "}- <code className="rounded bg-mineshaft-700 px-1">infisical-pam-*</code> pattern, you- must update the PAM role's permissions policy to include the target role ARN.+ current project ID. If this target role name doesn't match the wildcard pattern+ in your PAM role's permissions policy, you'll need to update that policy+ to include this role's ARN.</p></AccordionContent></AccordionItem>diff --git a/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/AwsIamResourceForm.tsx b/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/AwsIamResourceForm.tsxindex 515619449a..ec97d0a6fd 100644--- a/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/AwsIamResourceForm.tsx+++ b/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/AwsIamResourceForm.tsx@@ -57,7 +57,7 @@ export const AwsIamResourceForm = ({ resource, onSubmit }: Props) => {"Statement": [{"Effect": "Allow","Action": "sts:AssumeRole",- "Resource": "arn:aws:iam::<YOUR_ACCOUNT_ID>:role/infisical-pam-*"+ "Resource": "arn:aws:iam::<YOUR_ACCOUNT_ID>:role/<YOUR_PREFIX>-*"}]}`;@@ -148,9 +148,12 @@ export const AwsIamResourceForm = ({ resource, onSubmit }: Props) => {Step 1: Create a permissions policy for assuming target roles</p><p className="mb-3 text-sm text-mineshaft-300">- This policy allows the PAM role to assume target roles. We recommend using the{" "}- <code className="rounded bg-mineshaft-700 px-1 text-xs">infisical-pam-*</code>{" "}- naming convention for target roles.+ This policy allows the PAM role to assume target roles. We recommend using a+ wildcard pattern (e.g.,{" "}+ <code className="rounded bg-mineshaft-700 px-1 text-xs">pam-*</code> or{" "}+ <code className="rounded bg-mineshaft-700 px-1 text-xs">privileged-*</code>) so you+ can add new accounts without updating this policy. Choose a prefix that fits your+ naming conventions.</p><div className="relative mb-4"><div className="absolute top-1 right-1">diff --git a/frontend/src/pages/pam/PamSessionsPage/components/PamSessionStatusBadge.tsx b/frontend/src/pages/pam/PamSessionsPage/components/PamSessionStatusBadge.tsxindex d701d3e233..1b347210e8 100644--- a/frontend/src/pages/pam/PamSessionsPage/components/PamSessionStatusBadge.tsx+++ b/frontend/src/pages/pam/PamSessionsPage/components/PamSessionStatusBadge.tsx@@ -2,7 +2,6 @@ import {ActivityIcon,BanIcon,ChevronsLeftRightEllipsisIcon,- ClockIcon,GavelIcon,LucideIcon} from "lucide-react";@@ -34,10 +33,6 @@ const PAM_SESSION_STATUS_CONFIG: Record<PamSessionStatus, StatusConfig> = {[PamSessionStatus.Ended]: {variant: "neutral",icon: BanIcon- },- [PamSessionStatus.Expired]: {- variant: "warning",- icon: ClockIcon}};