From 5f4735926cba8a49da575bfeb0c276dac5901a30 Mon Sep 17 00:00:00 2001 From: Sheen Capadngan Date: Fri, 3 Oct 2025 21:51:22 +0800 Subject: [PATCH] misc: fixed log clipping and added idempotency to session end --- .../src/ee/services/pam-session/pam-session-service.ts | 7 +++++++ .../components/PamAccessAccountModal.tsx | 7 +++++-- .../components/PamSessionLogsSection.tsx | 10 +++++++--- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/backend/src/ee/services/pam-session/pam-session-service.ts b/backend/src/ee/services/pam-session/pam-session-service.ts index 0b37422e5a..07185bec2a 100644 --- a/backend/src/ee/services/pam-session/pam-session-service.ts +++ b/backend/src/ee/services/pam-session/pam-session-service.ts @@ -152,6 +152,13 @@ export const pamSessionServiceFactory = ({ OrgPermissionSubjects.Gateway ); + if (session.status === PamSessionStatus.Ended) { + return { + session, + projectId: project.id + }; + } + if (session.status !== PamSessionStatus.Active) { throw new BadRequestError({ message: "Cannot end sessions that are not active" }); } diff --git a/frontend/src/pages/pam/PamAccountsPage/components/PamAccessAccountModal.tsx b/frontend/src/pages/pam/PamAccountsPage/components/PamAccessAccountModal.tsx index 8ef588e23a..be3d40001a 100644 --- a/frontend/src/pages/pam/PamAccountsPage/components/PamAccessAccountModal.tsx +++ b/frontend/src/pages/pam/PamAccountsPage/components/PamAccessAccountModal.tsx @@ -5,7 +5,7 @@ import ms from "ms"; import { createNotification } from "@app/components/notifications"; import { Button, FormLabel, Input, Modal, ModalClose, ModalContent } from "@app/components/v2"; -import { TPamAccount } from "@app/hooks/api/pam"; +import { PamResourceType, TPamAccount } from "@app/hooks/api/pam"; type Props = { account?: TPamAccount; @@ -19,7 +19,10 @@ export const PamAccessAccountModal = ({ isOpen, onOpenChange, account }: Props) const isDurationValid = useMemo(() => duration && ms(duration || "1s") > 0, [duration]); const command = useMemo( - () => (account ? `infisical pam access ${account.id} --duration ${duration}` : ""), + () => + account && account.resource.resourceType === PamResourceType.Postgres + ? `infisical pam db access-account ${account.id} --duration ${duration}` + : "", [account, duration] ); diff --git a/frontend/src/pages/pam/PamSessionsByIDPage/components/PamSessionLogsSection.tsx b/frontend/src/pages/pam/PamSessionsByIDPage/components/PamSessionLogsSection.tsx index 81a2471dd8..c07e0d1abd 100644 --- a/frontend/src/pages/pam/PamSessionsByIDPage/components/PamSessionLogsSection.tsx +++ b/frontend/src/pages/pam/PamSessionsByIDPage/components/PamSessionLogsSection.tsx @@ -13,7 +13,7 @@ export const PamSessionLogsSection = ({ session }: Props) => {

Session Logs

-
+
{session.commandLogs.length > 0 ? ( session.commandLogs.map((log) => (
@@ -22,8 +22,12 @@ export const PamSessionLogsSection = ({ session }: Props) => { {new Date(log.timestamp).toLocaleString()}
-
{log.input}
-
{log.output}
+
+ {log.input} +
+
+ {log.output} +
)) ) : (