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
Gateway Quality of Life Improvements
x032205a446eac6f15d
diff --git a/backend/src/ee/services/pam-account/pam-account-service.ts b/backend/src/ee/services/pam-account/pam-account-service.tsindex 9411d3acee..26f850aba6 100644--- a/backend/src/ee/services/pam-account/pam-account-service.ts+++ b/backend/src/ee/services/pam-account/pam-account-service.ts@@ -76,7 +76,7 @@ import { TSqlAccountCredentials, TSqlResourceConnectionDetails } from "../pam-reimport { TSSHAccountCredentials, TSSHResourceInternalMetadata } from "../pam-resource/ssh/ssh-resource-types";import { TPamSessionDALFactory } from "../pam-session/pam-session-dal";import { PamSessionStatus } from "../pam-session/pam-session-enums";-import { generateSessionRecordingSecrets } from "../pam-session/pam-session-recording-secrets";+import { decryptSessionKey, generateSessionRecordingSecrets } from "../pam-session/pam-session-recording-secrets";import { PamRecordingStorageBackend } from "../pam-session-recording-storage/pam-session-recording-storage-enums";import { OrgPermissionGatewayActions, OrgPermissionSubjects } from "../permission/org-permission";import { TPamAccountDALFactory } from "./pam-account-dal";@@ -1260,9 +1260,9 @@ export const pamAccountServiceFactory = ({let sessionStarted = false;- // Recording secrets are lazily generated on the first /credentials call- // Returned exactly once to the gateway; only the encrypted session key and the SHA-256 of the upload token are persisted- // After the first call, the gateway is responsible for keeping these in memory (and persisting the upload token to disk for reconciliation)+ // Recording secrets are lazily generated on the first /credentials call (status=Starting)+ // The upload token is returned exactly once; the gateway persists it to disk+ // On subsequent calls (status=Active), the session key and storage backend are re-derived so the gateway can resume chunk creation after a restartlet sessionRecordingSecrets: {sessionKeyBase64: string;uploadTokenBase64: string;@@ -1291,6 +1291,20 @@ export const pamAccountServiceFactory = ({storageBackend};}+ } else if (session.status === PamSessionStatus.Active && session.encryptedSessionKey) {+ const projectRecordingConfig = await pamProjectRecordingConfigService.resolveConfigForProject(session.projectId);+ const storageBackend = projectRecordingConfig?.backend ?? PamRecordingStorageBackend.Postgres;+ const sessionKey = await decryptSessionKey({+ projectId: session.projectId,+ sessionId,+ encryptedSessionKey: session.encryptedSessionKey,+ kmsService+ });+ sessionRecordingSecrets = {+ sessionKeyBase64: sessionKey.toString("base64"),+ uploadTokenBase64: "",+ storageBackend+ };}// Handle SSH certificate-based authenticationdiff --git a/backend/src/ee/services/pam-session/pam-session-chunk-service.ts b/backend/src/ee/services/pam-session/pam-session-chunk-service.tsindex 76cb6896eb..03bd742c62 100644--- a/backend/src/ee/services/pam-session/pam-session-chunk-service.ts+++ b/backend/src/ee/services/pam-session/pam-session-chunk-service.ts@@ -188,7 +188,7 @@ export const pamSessionChunkServiceFactory = ({: null;try {- await pamSessionEventChunkDAL.create({+ await pamSessionEventChunkDAL.insertIgnoreDuplicate({sessionId,chunkIndex,startElapsedMs,diff --git a/backend/src/ee/services/pam-session/pam-session-event-chunk-dal.ts b/backend/src/ee/services/pam-session/pam-session-event-chunk-dal.tsindex 2f5d5c052f..58e323a3bc 100644--- a/backend/src/ee/services/pam-session/pam-session-event-chunk-dal.ts+++ b/backend/src/ee/services/pam-session/pam-session-event-chunk-dal.ts@@ -1,7 +1,7 @@import { Knex } from "knex";import { TDbClient } from "@app/db";-import { TableName } from "@app/db/schemas";+import { TableName, TPamSessionEventChunksInsert } from "@app/db/schemas";import { ormify } from "@app/lib/knex";export type TPamSessionEventChunkDALFactory = ReturnType<typeof pamSessionEventChunkDALFactory>;@@ -20,5 +20,9 @@ export const pamSessionEventChunkDALFactory = (db: TDbClient) => {return (tx || db.replicaNode())(TableName.PamSessionEventChunk).where({ sessionId, chunkIndex }).first();};- return { ...orm, findAllBySessionId, findByChunkIndex };+ const insertIgnoreDuplicate = async (data: TPamSessionEventChunksInsert, tx?: Knex) => {+ await (tx || db)(TableName.PamSessionEventChunk).insert(data).onConflict(["sessionId", "chunkIndex"]).ignore();+ };++ return { ...orm, findAllBySessionId, findByChunkIndex, insertIgnoreDuplicate };};