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
fix(pam): cleanup review fixes
bernie-g1c3db7a7f45d
diff --git a/backend/src/ee/services/pam-web-access/rdp/pam-rdp-session-handler.ts b/backend/src/ee/services/pam-web-access/rdp/pam-rdp-session-handler.tsindex 5f22416d59..abccf65c58 100644--- a/backend/src/ee/services/pam-web-access/rdp/pam-rdp-session-handler.ts+++ b/backend/src/ee/services/pam-web-access/rdp/pam-rdp-session-handler.ts@@ -80,7 +80,8 @@ export const handleRdpSession = async (ctx: TSessionContext): Promise<TSessionHatcpSocket.on("close", () => {logger.info({ sessionId }, "rdp session: tcp socket closed");- onCleanup();+ if (!cleanedUp) onCleanup();+ teardown();try {socket.close();} catch (err) {@@ -90,9 +91,7 @@ export const handleRdpSession = async (ctx: TSessionContext): Promise<TSessionHatcpSocket.on("error", (err) => {logger.error(err, "rdp session: tcp socket error");- if (!cleanedUp) {- onCleanup();- }+ if (!cleanedUp) onCleanup();teardown();});diff --git a/frontend/src/pages/pam/PamAccountsPage/components/AccountDetailSheet.tsx b/frontend/src/pages/pam/PamAccountsPage/components/AccountDetailSheet.tsxindex f7c98268d4..2a42bdaeef 100644--- a/frontend/src/pages/pam/PamAccountsPage/components/AccountDetailSheet.tsx+++ b/frontend/src/pages/pam/PamAccountsPage/components/AccountDetailSheet.tsx@@ -582,7 +582,12 @@ const SettingsTab = ({{title: "Bucket CORS not configured",type: "warning",- text: "Session playback requires the bucket to allow GET requests from this origin. See the docs for CORS setup."+ text: "Session playback requires the bucket to allow GET requests from this origin.",+ callToAction: (+ <a href="https://infisical.com/docs/documentation/platform/pam/recording-storage" target="_blank" rel="noopener noreferrer" className="text-xs underline">+ CORS setup docs+ </a>+ )},{ autoClose: 10000 });diff --git a/frontend/src/pages/pam/PamTemplatesPage/components/TemplateDetailSheet.tsx b/frontend/src/pages/pam/PamTemplatesPage/components/TemplateDetailSheet.tsxindex 16536723ec..4d29663ba8 100644--- a/frontend/src/pages/pam/PamTemplatesPage/components/TemplateDetailSheet.tsx+++ b/frontend/src/pages/pam/PamTemplatesPage/components/TemplateDetailSheet.tsx@@ -33,7 +33,6 @@ import { Skeleton } from "@app/components/v3/generic/Skeleton";import { useProject } from "@app/context";import { AppConnection, useListAvailableAppConnections } from "@app/hooks/api/appConnections";import {- accountTypeRequiresRecording,PamAccountType,resolvePamAccountType,useGetPamAccountTemplate,@@ -47,12 +46,11 @@ import { PAM_TEMPLATE_TABS } from "../../components/pamResourceTabs";import { POLICY_EDITORS } from "../../components/policyEditors";import { SheetSaveBar } from "../../components/SheetSaveBar";import { AccountPlatformIcon } from "../../PamAccessPage/components/AccountPlatformIcon";-import { RecordingConnectionPicker } from "../../PamAccountsPage/components/RecordingConnectionPicker";+const configSchema = z.object({name: z.string().min(1, "Name is required").max(64),description: z.string().max(256).optional(),- recordingEnabled: z.boolean(),recordingStorageBackend: z.enum(["postgres", "aws-s3"]),recordingConnectionId: z.string().nullable(),s3Bucket: z.string().optional(),@@ -106,7 +104,7 @@ const ConfigurationTab = ({defaultValues: {name: "",description: "",- recordingEnabled: true,+recordingStorageBackend: "postgres",recordingConnectionId: null,s3Bucket: "",@@ -131,7 +129,7 @@ const ConfigurationTab = ({reset({name: template.name,description: template.description ?? "",- recordingEnabled: settings.recordingEnabled !== false,+recordingStorageBackend: isWin ? "aws-s3" : (savedBackend ?? "postgres"),recordingConnectionId: (template.recordingConnectionId as string) ?? null,s3Bucket: s3Config.bucket ?? "",@@ -144,7 +142,7 @@ const ConfigurationTab = ({const onSubmit = (data: ConfigForm) => {const settings: Record<string, unknown> = {...((template?.settings ?? {}) as Record<string, unknown>),- recordingEnabled: data.recordingEnabled,+recordingStorageBackend: data.recordingStorageBackend};@@ -179,7 +177,12 @@ const ConfigurationTab = ({{title: "Bucket CORS not configured",type: "warning",- text: "Session playback requires the bucket to allow GET requests from this origin. See the docs for CORS setup."+ text: "Session playback requires the bucket to allow GET requests from this origin.",+ callToAction: (+ <a href="https://infisical.com/docs/documentation/platform/pam/recording-storage" target="_blank" rel="noopener noreferrer" className="text-xs underline">+ CORS setup docs+ </a>+ )},{ autoClose: 10000 });@@ -245,20 +248,6 @@ const ConfigurationTab = ({<CardDescription>Configure how sessions are recorded and stored.</CardDescription></CardHeader><CardContent className="flex flex-col gap-6">- <Field orientation="horizontal" className="items-center!">- <FieldContent>- <FieldTitle>Enable recording</FieldTitle>- <FieldDescription>Record session activity for audit and playback.</FieldDescription>- </FieldContent>- <Controller- name="recordingEnabled"- control={control}- render={({ field }) => (- <Switch checked={field.value} variant="pam" onCheckedChange={field.onChange} />- )}- />- </Field>-<Controllername="recordingStorageBackend"control={control}@@ -271,14 +260,14 @@ const ConfigurationTab = ({<SelectValue /></SelectTrigger><SelectContent>- {!isWindows && <SelectItem value="postgres">PostgreSQL (default)</SelectItem>}+ {!isWindows && <SelectItem value="postgres">Internal Database (default)</SelectItem>}<SelectItem value="aws-s3">AWS S3</SelectItem></SelectContent></Select><FieldDescription>{isWindows? "RDP recordings require S3 storage."- : "PostgreSQL stores recordings in the database. S3 is recommended for large or long sessions."}+ : "Stores recordings in the database. S3 is recommended for large or long sessions."}</FieldDescription></FieldContent></Field>@@ -448,8 +437,7 @@ const SettingsTab = ({templateId,policies: data.policies,gatewayId: data.gatewayId,- gatewayPoolId: data.gatewayPoolId,- ...(showRecording ? { recordingConnectionId: data.recordingConnectionId } : {})+ gatewayPoolId: data.gatewayPoolId},{onSuccess: () => createNotification({ type: "success", text: "Template updated" })@@ -514,21 +502,7 @@ const SettingsTab = ({</FieldContent></Field>- {showRecording && (- <Field>- <FieldLabel>Recording Bucket</FieldLabel>- <FieldContent>- <RecordingConnectionPicker- value={recordingConnectionId}- includeNone- onChange={(value) =>- setValue("recordingConnectionId", value, { shouldDirty: true })- }- />- <FieldDescription>Where session recordings are stored.</FieldDescription>- </FieldContent>- </Field>- )}+</CardContent></Card>diff --git a/frontend/src/pages/pam/layout.tsx b/frontend/src/pages/pam/layout.tsxindex c26019d517..68c8ea317a 100644--- a/frontend/src/pages/pam/layout.tsx+++ b/frontend/src/pages/pam/layout.tsx@@ -1,49 +1,54 @@-import { createFileRoute, redirect } from "@tanstack/react-router";+import { createFileRoute, redirect } from '@tanstack/react-router'-import { BreadcrumbTypes } from "@app/components/v2";-import { projectKeys } from "@app/hooks/api";-import { organizationKeys } from "@app/hooks/api/organization/queries";-import { Organization } from "@app/hooks/api/organization/types";-import { fetchProjectById } from "@app/hooks/api/projects/queries";-import { fetchUserProjectPermissions, roleQueryKeys } from "@app/hooks/api/roles/queries";-import { PamLayout } from "@app/layouts/PamLayout";-import { ProjectSelect } from "@app/layouts/ProjectLayout/components/ProjectSelect";+import { BreadcrumbTypes } from '@app/components/v2'+import { projectKeys } from '@app/hooks/api'+import { organizationKeys } from '@app/hooks/api/organization/queries'+import { Organization } from '@app/hooks/api/organization/types'+import { fetchProjectById } from '@app/hooks/api/projects/queries'+import {+ fetchUserProjectPermissions,+ roleQueryKeys,+} from '@app/hooks/api/roles/queries'+import { PamLayout } from '@app/layouts/PamLayout'+import { ProjectSelect } from '@app/layouts/ProjectLayout/components/ProjectSelect'export const Route = createFileRoute(- "/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/pam/_pam-layout"+ '/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/pam/_pam-layout',)({component: PamLayout,beforeLoad: async ({ params, context }) => {const org = context.queryClient.getQueryData<Organization>(- organizationKeys.getOrgById(params.orgId)- );+ organizationKeys.getOrgById(params.orgId),+ )- const pamProjectId = org?.pamProjectId;+ const pamProjectId = org?.pamProjectIdif (!pamProjectId) {throw redirect({- to: "/organizations/$orgId/projects",- params: { orgId: params.orgId }- });+ to: '/organizations/$orgId/projects',+ params: { orgId: params.orgId },+ })}await Promise.all([context.queryClient.ensureQueryData({queryKey: projectKeys.getProjectById(pamProjectId),- queryFn: () => fetchProjectById(pamProjectId)+ queryFn: () => fetchProjectById(pamProjectId),}),context.queryClient.ensureQueryData({- queryKey: roleQueryKeys.getUserProjectPermissions({ projectId: pamProjectId }),- queryFn: () => fetchUserProjectPermissions({ projectId: pamProjectId })- })- ]);+ queryKey: roleQueryKeys.getUserProjectPermissions({+ projectId: pamProjectId,+ }),+ queryFn: () => fetchUserProjectPermissions({ projectId: pamProjectId }),+ }),+ ])return {breadcrumbs: [{type: BreadcrumbTypes.Component,- component: ProjectSelect- }- ]- };- }-});+ component: ProjectSelect,+ },+ ],+ }+ },+})