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
default template settings, unusable account states, template overrides
x03220592783290fbe2
diff --git a/backend/src/db/migrations/20260619013459_pam-account-credential-configured.ts b/backend/src/db/migrations/20260619013459_pam-account-credential-configured.tsnew file mode 100644index 0000000000..a9208aa7f2--- /dev/null+++ b/backend/src/db/migrations/20260619013459_pam-account-credential-configured.ts@@ -0,0 +1,21 @@+import { Knex } from "knex";++import { TableName } from "../schemas";++export async function up(knex: Knex): Promise<void> {+ if (!(await knex.schema.hasColumn(TableName.PamAccount, "credentialConfigured"))) {+ await knex.schema.alterTable(TableName.PamAccount, (t) => {+ t.boolean("credentialConfigured").notNullable().defaultTo(false);+ });++ await knex(TableName.PamAccount).update({ credentialConfigured: true });+ }+}++export async function down(knex: Knex): Promise<void> {+ if (await knex.schema.hasColumn(TableName.PamAccount, "credentialConfigured")) {+ await knex.schema.alterTable(TableName.PamAccount, (t) => {+ t.dropColumn("credentialConfigured");+ });+ }+}diff --git a/backend/src/db/schemas/pam-accounts.ts b/backend/src/db/schemas/pam-accounts.tsindex 1a8ae71a19..3a32b9f59b 100644--- a/backend/src/db/schemas/pam-accounts.ts+++ b/backend/src/db/schemas/pam-accounts.ts@@ -32,7 +32,8 @@ export const PamAccountsSchema = z.object({encryptedInternalMetadata: zodBuffer.nullable().optional(),gatewayId: z.string().uuid().nullable().optional(),gatewayPoolId: z.string().uuid().nullable().optional(),- recordingConnectionId: z.string().uuid().nullable().optional()+ recordingConnectionId: z.string().uuid().nullable().optional(),+ credentialConfigured: z.boolean().default(false)});export type TPamAccounts = z.infer<typeof PamAccountsSchema>;diff --git a/backend/src/ee/routes/v1/pam-routers/pam-account-router.ts b/backend/src/ee/routes/v1/pam-routers/pam-account-router.tsindex dbf373008e..da8f694d91 100644--- a/backend/src/ee/routes/v1/pam-routers/pam-account-router.ts+++ b/backend/src/ee/routes/v1/pam-routers/pam-account-router.ts@@ -6,6 +6,7 @@ import { PamAccountType } from "@app/ee/services/pam/pam-enums";import {ACCOUNT_TYPE_CONFIGS,buildPamAccountTypeMetadata,+ PamAccountAccessibilityIssue,PamAccountTypeMetadataSchema} from "@app/ee/services/pam-account/pam-account-schemas";import {@@ -44,6 +45,14 @@ const SanitizedAccountListItemSchema = BaseAccountFields.extend({accountType: z.string()});+// The admin list surfaces accessibility so unusable accounts can be flagged in the UI+const AdminAccountListItemSchema = SanitizedAccountListItemSchema.extend({+ isAccessible: z.boolean().describe("Whether the account is fully provisioned to launch a session"),+ accessibilityIssues: z+ .array(z.nativeEnum(PamAccountAccessibilityIssue))+ .describe("Reasons the account cannot launch a session, if any")+});+const accountDetailVariants = Object.entries(ACCOUNT_TYPE_CONFIGS).map(([accountType, config]) =>SanitizedAccountListItemSchema.extend({accountType: z.literal(accountType as TSupportedAccountType),@@ -300,7 +309,7 @@ export const registerPamAccountRouter = async (server: FastifyZodProvider) => {search: z.string().optional().describe("Filter accounts by name")}),response: {- 200: z.object({ accounts: z.array(SanitizedAccountListItemSchema) })+ 200: z.object({ accounts: z.array(AdminAccountListItemSchema) })}},config: { rateLimit: readLimit },diff --git a/backend/src/ee/routes/v1/pam-routers/pam-folder-router.ts b/backend/src/ee/routes/v1/pam-routers/pam-folder-router.tsindex 54308f8927..649d512322 100644--- a/backend/src/ee/routes/v1/pam-routers/pam-folder-router.ts+++ b/backend/src/ee/routes/v1/pam-routers/pam-folder-router.ts@@ -27,7 +27,12 @@ export const registerPamFolderRouter = async (server: FastifyZodProvider) => {description: "List all PAM folders in the project",tags: [ApiDocsTags.PamFolders],querystring: z.object({- search: z.string().optional().describe("Filter folders by name")+ search: z.string().optional().describe("Filter folders by name"),+ onlyAccessible: z+ .enum(["true", "false"])+ .optional()+ .transform((v) => v === "true")+ .describe("Count only accounts that can launch a session toward each folder's accountCount")}),response: {200: z.object({@@ -45,6 +50,7 @@ export const registerPamFolderRouter = async (server: FastifyZodProvider) => {const folders = await server.services.pamFolder.list({projectId: req.internalPamProjectId,search: req.query.search,+ onlyAccessible: req.query.onlyAccessible,actorId: req.permission.id,actor: req.permission.type,actorOrgId: req.permission.orgId,diff --git a/backend/src/ee/services/pam-account/pam-account-dal.ts b/backend/src/ee/services/pam-account/pam-account-dal.tsindex 71c7df9b54..677ad73eb0 100644--- a/backend/src/ee/services/pam-account/pam-account-dal.ts+++ b/backend/src/ee/services/pam-account/pam-account-dal.ts@@ -5,6 +5,25 @@ import { TableName, TPamAccounts } from "@app/db/schemas";import { sanitizeSqlLikeString } from "@app/lib/fn";import { ormify } from "@app/lib/knex";+import { PamAccountType } from "../pam/pam-enums";++export const accountAccessibilitySql = (accountTable: string, templateTable: string): string =>+ `(+ ("${accountTable}"."gatewayId" is not null or "${accountTable}"."gatewayPoolId" is not null+ or "${templateTable}"."gatewayId" is not null or "${templateTable}"."gatewayPoolId" is not null)+ and "${accountTable}"."credentialConfigured" = true+ and ("${templateTable}"."type" != '${PamAccountType.Windows}'+ or "${accountTable}"."recordingConnectionId" is not null+ or "${templateTable}"."recordingConnectionId" is not null)+ )`;++type TPamAccountTemplateInheritedFields = {+ credentialConfigured: boolean;+ templateGatewayId: string | null;+ templateGatewayPoolId: string | null;+ templateRecordingConnectionId: string | null;+};+export type TPamAccountListItem = Pick<TPamAccounts,| "id"@@ -18,19 +37,21 @@ export type TPamAccountListItem = Pick<| "recordingConnectionId"| "createdAt"| "updatedAt"-> & {- accountType: string;- templateName: string;- folderName: string | null;-};+> &+ TPamAccountTemplateInheritedFields & {+ accountType: string;+ templateName: string;+ folderName: string | null;+ };-export type TPamAccountDetail = TPamAccounts & {- accountType: string;- templateName: string;- templateAccessPolicy: unknown;- templateSettings: unknown;- folderName: string | null;-};+export type TPamAccountDetail = TPamAccounts &+ TPamAccountTemplateInheritedFields & {+ accountType: string;+ templateName: string;+ templateAccessPolicy: unknown;+ templateSettings: unknown;+ folderName: string | null;+ };export type TPamAccountDALFactory = ReturnType<typeof pamAccountDALFactory>;@@ -46,6 +67,7 @@ export const pamAccountDALFactory = (db: TDbClient) => {templateId?: string;accountType?: string;search?: string;+ onlyAccessible?: boolean;offset?: number;limit?: number;},@@ -77,6 +99,9 @@ export const pamAccountDALFactory = (db: TDbClient) => {const pattern = `%${sanitizeSqlLikeString(filters.search)}%`;void baseQuery.whereILike(`${TableName.PamAccount}.name`, pattern);}+ if (filters?.onlyAccessible) {+ void baseQuery.whereRaw(accountAccessibilitySql(TableName.PamAccount, TableName.PamAccountTemplate));+ }const countQuery = baseQuery.clone()@@ -96,10 +121,14 @@ export const pamAccountDALFactory = (db: TDbClient) => {`${TableName.PamAccount}.gatewayId`,`${TableName.PamAccount}.gatewayPoolId`,`${TableName.PamAccount}.recordingConnectionId`,+ `${TableName.PamAccount}.credentialConfigured`,`${TableName.PamAccount}.createdAt`,`${TableName.PamAccount}.updatedAt`,`${TableName.PamAccountTemplate}.type as accountType`,`${TableName.PamAccountTemplate}.name as templateName`,+ `${TableName.PamAccountTemplate}.gatewayId as templateGatewayId`,+ `${TableName.PamAccountTemplate}.gatewayPoolId as templateGatewayPoolId`,+ `${TableName.PamAccountTemplate}.recordingConnectionId as templateRecordingConnectionId`,`${TableName.PamFolder}.name as folderName`).orderBy(`${TableName.PamFolder}.name`, "asc")@@ -127,6 +156,9 @@ export const pamAccountDALFactory = (db: TDbClient) => {`${TableName.PamAccountTemplate}.name as templateName`,`${TableName.PamAccountTemplate}.accessPolicy as templateAccessPolicy`,`${TableName.PamAccountTemplate}.settings as templateSettings`,+ `${TableName.PamAccountTemplate}.gatewayId as templateGatewayId`,+ `${TableName.PamAccountTemplate}.gatewayPoolId as templateGatewayPoolId`,+ `${TableName.PamAccountTemplate}.recordingConnectionId as templateRecordingConnectionId`,`${TableName.PamFolder}.name as folderName`)) as unknown as TPamAccountDetail[];diff --git a/backend/src/ee/services/pam-account/pam-account-schemas.test.ts b/backend/src/ee/services/pam-account/pam-account-schemas.test.tsindex a02767ceaf..24a3cf0762 100644--- a/backend/src/ee/services/pam-account/pam-account-schemas.test.ts+++ b/backend/src/ee/services/pam-account/pam-account-schemas.test.ts@@ -2,7 +2,11 @@ import { describe, expect, test } from "vitest";import { PamAccountType } from "../pam/pam-enums";import {+ accountTypeRequiresRecording,buildPamAccountTypeMetadata,+ getAccountAccessibilityIssues,+ isCredentialConfigured,+ PamAccountAccessibilityIssue,PamAccountTypeMetadataSchema,PamFieldDescriptorSchema} from "./pam-account-schemas";@@ -120,3 +124,60 @@ describe("buildPamAccountTypeMetadata", () => {});});});++describe("isCredentialConfigured", () => {+ test("Postgres/MySQL require a non-empty password", () => {+ expect(isCredentialConfigured(PamAccountType.Postgres, { username: "u", password: "p" })).toBe(true);+ expect(isCredentialConfigured(PamAccountType.Postgres, { username: "u", password: " " })).toBe(false);+ expect(isCredentialConfigured(PamAccountType.MySQL, { username: "u" })).toBe(false);+ });++ test("SSH credential depends on the auth method", () => {+ expect(isCredentialConfigured(PamAccountType.SSH, { authMethod: "password", password: "p" })).toBe(true);+ expect(isCredentialConfigured(PamAccountType.SSH, { authMethod: "password" })).toBe(false);+ expect(isCredentialConfigured(PamAccountType.SSH, { authMethod: "public-key", privateKey: "k" })).toBe(true);+ expect(isCredentialConfigured(PamAccountType.SSH, { authMethod: "public-key" })).toBe(false);++ expect(isCredentialConfigured(PamAccountType.SSH, { authMethod: "certificate" })).toBe(true);+ });+});++describe("getAccountAccessibilityIssues", () => {+ test("recording is only required for account types that stream to a bucket", () => {+ expect(accountTypeRequiresRecording(PamAccountType.Windows)).toBe(true);+ expect(accountTypeRequiresRecording(PamAccountType.Postgres)).toBe(false);+ });++ test("a fully provisioned non-Windows account has no issues", () => {+ expect(+ getAccountAccessibilityIssues({+ accountType: PamAccountType.Postgres,+ hasGateway: true,+ hasRecordingConfig: false,+ credentialConfigured: true+ })+ ).toEqual([]);+ });++ test("flags missing gateway and credential", () => {+ expect(+ getAccountAccessibilityIssues({+ accountType: PamAccountType.Postgres,+ hasGateway: false,+ hasRecordingConfig: false,+ credentialConfigured: false+ })+ ).toEqual([PamAccountAccessibilityIssue.NoGateway, PamAccountAccessibilityIssue.NoCredential]);+ });++ test("flags missing recording only for Windows", () => {+ expect(+ getAccountAccessibilityIssues({+ accountType: PamAccountType.Windows,+ hasGateway: true,+ hasRecordingConfig: false,+ credentialConfigured: true+ })+ ).toEqual([PamAccountAccessibilityIssue.NoRecordingConfig]);+ });+});diff --git a/backend/src/ee/services/pam-account/pam-account-schemas.ts b/backend/src/ee/services/pam-account/pam-account-schemas.tsindex 65363b0634..e220a8fd06 100644--- a/backend/src/ee/services/pam-account/pam-account-schemas.ts+++ b/backend/src/ee/services/pam-account/pam-account-schemas.ts@@ -211,6 +211,37 @@ export const extractGatewayTarget = (}};+// -- Account accessibility++export enum PamAccountAccessibilityIssue {+ NoGateway = "no-gateway",+ NoRecordingConfig = "no-recording-config",+ NoCredential = "no-credential"+}++export const accountTypeRequiresRecording = (accountType: PamAccountType): boolean =>+ accountType === PamAccountType.Windows;++export const getAccountAccessibilityIssues = ({+ accountType,+ hasGateway,+ hasRecordingConfig,+ credentialConfigured+}: {+ accountType: PamAccountType;+ hasGateway: boolean;+ hasRecordingConfig: boolean;+ credentialConfigured: boolean;+}): PamAccountAccessibilityIssue[] => {+ const issues: PamAccountAccessibilityIssue[] = [];+ if (!hasGateway) issues.push(PamAccountAccessibilityIssue.NoGateway);+ if (accountTypeRequiresRecording(accountType) && !hasRecordingConfig) {+ issues.push(PamAccountAccessibilityIssue.NoRecordingConfig);+ }+ if (!credentialConfigured) issues.push(PamAccountAccessibilityIssue.NoCredential);+ return issues;+};+export type TSshInternalMetadata = z.infer<(typeof ACCOUNT_TYPE_CONFIGS)[PamAccountType.SSH]["internalMetadata"]>;export const parseInternalMetadata = (accountType: PamAccountType, data: unknown): TSshInternalMetadata | null => {@@ -383,3 +414,18 @@ export const buildPamAccountTypeMetadata = (): PamAccountTypeMetadata[] =>connectionFields: fieldsFromSchema(config.connectionDetails, config.ui),credentialFields: fieldsFromSchema(config.credentials, config.ui)}));++export const isCredentialConfigured = (accountType: PamAccountType, credentials: Record<string, unknown>): boolean => {+ const config = ACCOUNT_TYPE_CONFIGS[accountType as TSupportedAccountType];+ if (!config) return false;++ const applicableSecretFields = fieldsFromSchema(config.credentials, config.ui).filter(+ (field) => field.secret && (!field.showWhen || credentials[field.showWhen.field] === field.showWhen.equals)+ );+ if (applicableSecretFields.length === 0) return true;++ return applicableSecretFields.some((field) => {+ const value = credentials[field.key];+ return typeof value === "string" && value.trim().length > 0;+ });+};diff --git a/backend/src/ee/services/pam-account/pam-account-service.ts b/backend/src/ee/services/pam-account/pam-account-service.tsindex 4ebd5768ad..9288c117e2 100644--- a/backend/src/ee/services/pam-account/pam-account-service.ts+++ b/backend/src/ee/services/pam-account/pam-account-service.ts@@ -34,6 +34,8 @@ import { TPamAccountTemplateDALFactory } from "../pam-account-template/pam-accouimport { TPamFolderDALFactory } from "../pam-folder/pam-folder-dal";import { TPamAccountDALFactory } from "./pam-account-dal";import {+ getAccountAccessibilityIssues,+ isCredentialConfigured,parseInternalMetadata,sanitizeCredentials,type TSshInternalMetadata,@@ -91,6 +93,25 @@ export const pamAccountServiceFactory = (deps: TPamAccountServiceFactoryDep) =>return JSON.parse(decryptor({ cipherTextBlob: blob }).toString("utf-8")) as Record<string, unknown>;};+ const computeAccessibility = (a: {+ accountType: string;+ gatewayId?: string | null;+ gatewayPoolId?: string | null;+ recordingConnectionId?: string | null;+ templateGatewayId: string | null;+ templateGatewayPoolId: string | null;+ templateRecordingConnectionId: string | null;+ credentialConfigured: boolean;+ }) => {+ const accessibilityIssues = getAccountAccessibilityIssues({+ accountType: a.accountType as PamAccountType,+ hasGateway: Boolean(a.gatewayId || a.gatewayPoolId || a.templateGatewayId || a.templateGatewayPoolId),+ hasRecordingConfig: Boolean(a.recordingConnectionId || a.templateRecordingConnectionId),+ credentialConfigured: a.credentialConfigured+ });+ return { isAccessible: accessibilityIssues.length === 0, accessibilityIssues };+ };+const verifyMembership = (projectId: string, ctx: TActorContext) =>verifyProductMembership(permissionService, projectId, ctx);@@ -128,6 +149,7 @@ export const pamAccountServiceFactory = (deps: TPamAccountServiceFactoryDep) =>gatewayId: a.gatewayId,gatewayPoolId: a.gatewayPoolId,recordingConnectionId: a.recordingConnectionId,+ ...computeAccessibility(a),createdAt: a.createdAt,updatedAt: a.updatedAt}));@@ -230,6 +252,7 @@ export const pamAccountServiceFactory = (deps: TPamAccountServiceFactoryDep) =>templateId,encryptedConnectionDetails,encryptedCredentials,+ credentialConfigured: isCredentialConfigured(accountType, validatedCredentials),gatewayId,gatewayPoolId,recordingConnectionId@@ -336,6 +359,7 @@ export const pamAccountServiceFactory = (deps: TPamAccountServiceFactoryDep) =>const existingCredentials = await decrypt(projectId, existing.encryptedCredentials);const validated = validateCredentials(accountType, { ...existingCredentials, ...credentials });updateData.encryptedCredentials = await encrypt(projectId, validated);+ updateData.credentialConfigured = isCredentialConfigured(accountType, validated);}try {@@ -425,7 +449,8 @@ export const pamAccountServiceFactory = (deps: TPamAccountServiceFactoryDep) =>limit,search,folderId,- accountType+ accountType,+ onlyAccessible: true});return {diff --git a/backend/src/ee/services/pam-folder/pam-folder-dal.ts b/backend/src/ee/services/pam-folder/pam-folder-dal.tsindex 33f3992979..32971c8786 100644--- a/backend/src/ee/services/pam-folder/pam-folder-dal.ts+++ b/backend/src/ee/services/pam-folder/pam-folder-dal.ts@@ -5,6 +5,8 @@ import { TableName, TPamFolders } from "@app/db/schemas";import { sanitizeSqlLikeString } from "@app/lib/fn";import { ormify } from "@app/lib/knex";+import { accountAccessibilitySql } from "../pam-account/pam-account-dal";+export type TPamFolderWithCount = TPamFolders & { accountCount: number };export type TPamFolderDALFactory = ReturnType<typeof pamFolderDALFactory>;@@ -15,11 +17,16 @@ export const pamFolderDALFactory = (db: TDbClient) => {const findByProjectIdFiltered = async (projectId: string,folderIds: string[],- filters?: { search?: string; accountIds?: string[] },+ filters?: { search?: string; accountIds?: string[]; onlyAccessible?: boolean },tx?: Knex): Promise<TPamFolderWithCount[]> => {const qb = (tx || db.replicaNode())(TableName.PamFolder).leftJoin(TableName.PamAccount, `${TableName.PamAccount}.folderId`, `${TableName.PamFolder}.id`)+ .leftJoin(+ TableName.PamAccountTemplate,+ `${TableName.PamAccount}.templateId`,+ `${TableName.PamAccountTemplate}.id`+ ).where(`${TableName.PamFolder}.projectId`, projectId).where((builder) => {if (folderIds.length > 0) {@@ -34,9 +41,16 @@ export const pamFolderDALFactory = (db: TDbClient) => {void qb.whereILike(`${TableName.PamFolder}.name`, `%${sanitizeSqlLikeString(filters.search)}%`);}+ const countExpr = filters?.onlyAccessible+ ? `COUNT(${TableName.PamAccount}.id) FILTER (WHERE ${accountAccessibilitySql(+ TableName.PamAccount,+ TableName.PamAccountTemplate+ )})::int as "accountCount"`+ : `COUNT(${TableName.PamAccount}.id)::int as "accountCount"`;+return qb.groupBy(`${TableName.PamFolder}.id`)- .select(`${TableName.PamFolder}.*`, db.raw(`COUNT(${TableName.PamAccount}.id)::int as "accountCount"`))+ .select(`${TableName.PamFolder}.*`, db.raw(countExpr)).orderBy(`${TableName.PamFolder}.name`, "asc") as unknown as Promise<TPamFolderWithCount[]>;};diff --git a/backend/src/ee/services/pam-folder/pam-folder-service.ts b/backend/src/ee/services/pam-folder/pam-folder-service.tsindex 9b0ab4c554..133121cab0 100644--- a/backend/src/ee/services/pam-folder/pam-folder-service.ts+++ b/backend/src/ee/services/pam-folder/pam-folder-service.ts@@ -70,7 +70,7 @@ export const pamFolderServiceFactory = ({ForbiddenError.from(permission).throwUnlessCan(action, ResourcePermissionSub.PamResource);};- const list = async ({ projectId, search, ...ctx }: TListPamFoldersDTO & TActorContext) => {+ const list = async ({ projectId, search, onlyAccessible, ...ctx }: TListPamFoldersDTO & TActorContext) => {await verifyMembership(projectId, ctx);const { folderIds, accountIds } = await getResourceIdsWithActions(@@ -82,7 +82,7 @@ export const pamFolderServiceFactory = ({);if (folderIds.length === 0 && accountIds.length === 0) return [];- return pamFolderDAL.findByProjectIdFiltered(projectId, folderIds, { search, accountIds });+ return pamFolderDAL.findByProjectIdFiltered(projectId, folderIds, { search, accountIds, onlyAccessible });};const getById = async ({ folderId, projectId, ...ctx }: TGetPamFolderDTO & TActorContext) => {diff --git a/backend/src/ee/services/pam-folder/pam-folder-types.ts b/backend/src/ee/services/pam-folder/pam-folder-types.tsindex a30dde1a78..76239572a9 100644--- a/backend/src/ee/services/pam-folder/pam-folder-types.ts+++ b/backend/src/ee/services/pam-folder/pam-folder-types.ts@@ -24,4 +24,5 @@ export type TGetPamFolderDTO = {export type TListPamFoldersDTO = {projectId: string;search?: string;+ onlyAccessible?: boolean;};diff --git a/backend/src/ee/services/pam-session/pam-session-service.ts b/backend/src/ee/services/pam-session/pam-session-service.tsindex 0061ff4268..c9f6cc3c5d 100644--- a/backend/src/ee/services/pam-session/pam-session-service.ts+++ b/backend/src/ee/services/pam-session/pam-session-service.ts@@ -324,8 +324,8 @@ export const pamSessionServiceFactory = ({);const effectiveGatewayId = await gatewayPoolService.resolveEffectiveGatewayId({- gatewayId: account.gatewayId,- gatewayPoolId: account.gatewayPoolId+ gatewayId: account.gatewayId ?? account.templateGatewayId,+ gatewayPoolId: account.gatewayPoolId ?? account.templateGatewayPoolId});if (!effectiveGatewayId) {throw new BadRequestError({ message: "Gateway not configured for this account" });diff --git a/backend/src/ee/services/pam-web-access/pam-web-access-service.ts b/backend/src/ee/services/pam-web-access/pam-web-access-service.tsindex 6eea09d671..01667c3594 100644--- a/backend/src/ee/services/pam-web-access/pam-web-access-service.ts+++ b/backend/src/ee/services/pam-web-access/pam-web-access-service.ts@@ -344,8 +344,8 @@ export const pamWebAccessServiceFactory = ({}const effectiveGatewayId = await gatewayPoolService.resolveEffectiveGatewayId({- gatewayId: account.gatewayId,- gatewayPoolId: account.gatewayPoolId+ gatewayId: account.gatewayId ?? account.templateGatewayId,+ gatewayPoolId: account.gatewayPoolId ?? account.templateGatewayPoolId});if (!effectiveGatewayId) {throw new BadRequestError({ message: "Gateway not configured for this account" });diff --git a/frontend/src/hooks/api/pam/queries.tsx b/frontend/src/hooks/api/pam/queries.tsxindex 2c5480d210..6ec8bae6c5 100644--- a/frontend/src/hooks/api/pam/queries.tsx+++ b/frontend/src/hooks/api/pam/queries.tsx@@ -14,6 +14,7 @@ import {import { PamAccountType, PamResourcePermissionActions, PamResourcePermissionSub } from "./enums";import {+ PamAccountAccessibilityIssue,PamFolderPermissionSet,TAccessiblePamAccount,TListAccessiblePamAccountsDTO,@@ -150,7 +151,8 @@ export const useListAccessiblePamFolders = () => {queryKey: pamKeys.accessibleFolders(),queryFn: async () => {const { data } = await apiRequest.get<{ folders: TAccessiblePamFolder[] }>(- "/api/v1/pam/folders"+ "/api/v1/pam/folders",+ { params: { onlyAccessible: "true" } });return data.folders;}@@ -175,6 +177,8 @@ type TAdminAccountListItem = {gatewayId: string | null;gatewayPoolId: string | null;recordingConnectionId: string | null;+ isAccessible: boolean;+ accessibilityIssues: PamAccountAccessibilityIssue[];createdAt: string;updatedAt: string;};diff --git a/frontend/src/hooks/api/pam/types/index.ts b/frontend/src/hooks/api/pam/types/index.tsindex 82c254a3d9..84b1df1af0 100644--- a/frontend/src/hooks/api/pam/types/index.ts+++ b/frontend/src/hooks/api/pam/types/index.ts@@ -43,6 +43,15 @@ export type TPamAccountTypeMetadata = {// New model types+export enum PamAccountAccessibilityIssue {+ NoGateway = "no-gateway",+ NoRecordingConfig = "no-recording-config",+ NoCredential = "no-credential"+}++export const accountTypeRequiresRecording = (type: PamAccountType): boolean =>+ type === PamAccountType.Windows;+export type TPamAccount = {id: string;name: string;@@ -219,6 +228,7 @@ export type TCreatePamAccountDTO = {credentials: Record<string, unknown>;gatewayId?: string;gatewayPoolId?: string;+ recordingConnectionId?: string;};export type TUpdatePamAccountDTO = {@@ -263,6 +273,9 @@ export type TUpdatePamAccountTemplateDTO = {description?: string | null;accessPolicy?: Record<string, unknown>;settings?: Record<string, unknown>;+ gatewayId?: string | null;+ gatewayPoolId?: string | null;+ recordingConnectionId?: string | null;};export type TDeletePamAccountTemplateDTO = {diff --git a/frontend/src/hooks/usePamSheetState.ts b/frontend/src/hooks/usePamSheetState.tsindex 0354744dfd..a53269ac63 100644--- a/frontend/src/hooks/usePamSheetState.ts+++ b/frontend/src/hooks/usePamSheetState.ts@@ -5,8 +5,7 @@ export enum PamSheetTab {Launch = "launch",Permissions = "permissions",Configuration = "configuration",- Overrides = "overrides",- AccessPolicy = "access-policy"+ Advanced = "advanced"}export const pamSheetSearchParams = z.object({diff --git a/frontend/src/pages/pam/PamAccessPage/PamAccessPage.tsx b/frontend/src/pages/pam/PamAccessPage/PamAccessPage.tsxindex 7dbedeff40..4c2af16e4a 100644--- a/frontend/src/pages/pam/PamAccessPage/PamAccessPage.tsx+++ b/frontend/src/pages/pam/PamAccessPage/PamAccessPage.tsx@@ -72,9 +72,10 @@ export const PamAccessPage = () => {setResultCounts((prev) => (prev[folderId] === count ? prev : { ...prev, [folderId]: count }));}, []);+ const nonEmptyFolders = folders.filter((folder) => folder.accountCount > 0);const visibleFolders = selectedFolderId- ? folders.filter((folder) => folder.id === selectedFolderId)- : folders;+ ? nonEmptyFolders.filter((folder) => folder.id === selectedFolderId)+ : nonEmptyFolders;const isFolderOpen = (folderId: string) =>filterActive || folderId === selectedFolderId || expandedFolders.has(folderId);diff --git a/frontend/src/pages/pam/PamAccountsPage/components/AccountDetailSheet.tsx b/frontend/src/pages/pam/PamAccountsPage/components/AccountDetailSheet.tsxindex 72da88b071..a911535bc7 100644--- a/frontend/src/pages/pam/PamAccountsPage/components/AccountDetailSheet.tsx+++ b/frontend/src/pages/pam/PamAccountsPage/components/AccountDetailSheet.tsx@@ -4,11 +4,11 @@ import { useQuery } from "@tanstack/react-query";import { Link, useNavigate } from "@tanstack/react-router";import {FolderOpen,- Layers2,MoreHorizontal,Network,Pencil,Settings,+ Settings2,SquarePen,Trash2,UserPlus,@@ -736,9 +736,9 @@ export const AccountDetailSheet = ({ isOpen, accountId, onOpenChange }: Props) =) : null},canEdit && {- value: PamSheetTab.Overrides,- label: "Overrides",- icon: <Layers2 className="mr-1.5 size-4" />,+ value: PamSheetTab.Advanced,+ label: "Advanced",+ icon: <Settings2 className="mr-1.5 size-4" />,content: accountId ? (<SettingsTab accountId={accountId} onDirtyChange={setIsFormDirty} />) : nulldiff --git a/frontend/src/pages/pam/PamAccountsPage/components/CreateAccountSheet.tsx b/frontend/src/pages/pam/PamAccountsPage/components/CreateAccountSheet.tsxindex aaba7dfd11..05d1f9877c 100644--- a/frontend/src/pages/pam/PamAccountsPage/components/CreateAccountSheet.tsx+++ b/frontend/src/pages/pam/PamAccountsPage/components/CreateAccountSheet.tsx@@ -15,6 +15,7 @@ import {AlertDialogHeader,AlertDialogMedia,AlertDialogTitle,+ GatewayPicker,InputGroup,InputGroupAddon,InputGroupInput,@@ -40,6 +41,7 @@ import {} from "@app/components/v3/generic/Sheet";import { TextArea } from "@app/components/v3/generic/TextArea";import {+ accountTypeRequiresRecording,PamAccountType,useCreatePamAccount,useListPamAccountTemplates,@@ -58,6 +60,7 @@ import {} from "./accountFormSchema";import { ConnectionDetailsForm } from "./ConnectionDetailsForm";import { CredentialsForm } from "./CredentialsForm";+import { RecordingConnectionPicker } from "./RecordingConnectionPicker";type Props = {isOpen: boolean;@@ -72,6 +75,15 @@ export const CreateAccountSheet = ({ isOpen, onOpenChange, defaultFolderId }: Prconst [templateSearch, setTemplateSearch] = useState("");const [confirmDiscardOpen, setConfirmDiscardOpen] = useState(false);+ // Gateway/recording are collected inline only when the chosen template doesn't already provide them+ const [gateway, setGateway] = useState<{+ gatewayId: string | null;+ gatewayPoolId: string | null;+ }>({ gatewayId: null, gatewayPoolId: null });+ const [recordingConnectionId, setRecordingConnectionId] = useState<string | null>(null);+ const [gatewayError, setGatewayError] = useState(false);+ const [recordingError, setRecordingError] = useState(false);+const {control,handleSubmit,@@ -105,6 +117,15 @@ export const CreateAccountSheet = ({ isOpen, onOpenChange, defaultFolderId }: Prconst selectedTemplate = templates.find((t) => t.id === selectedTemplateId);const selectedMetadata = accountTypes.find((t) => t.type === selectedTemplate?.type);+ const needsGateway = Boolean(+ selectedTemplate && !selectedTemplate.gatewayId && !selectedTemplate.gatewayPoolId+ );+ const needsRecording = Boolean(+ selectedTemplate &&+ accountTypeRequiresRecording(selectedTemplate.type) &&+ !selectedTemplate.recordingConnectionId+ );+const templateQuery = templateSearch.trim().toLowerCase();const filteredTemplates = templates.filter((tpl) => {if (!templateQuery) return true;@@ -128,6 +149,10 @@ export const CreateAccountSheet = ({ isOpen, onOpenChange, defaultFolderId }: Pr});setStep(1);setTemplateSearch("");+ setGateway({ gatewayId: null, gatewayPoolId: null });+ setRecordingConnectionId(null);+ setGatewayError(false);+ setRecordingError(false);}}, [isOpen, defaultFolderId, reset]);@@ -137,7 +162,11 @@ export const CreateAccountSheet = ({ isOpen, onOpenChange, defaultFolderId }: PrsetValue("accountType", selectedMetadata.type);setValue("connectionDetails", buildDefaultFieldValues(selectedMetadata.connectionFields));setValue("credentials", buildDefaultFieldValues(selectedMetadata.credentialFields));- }, [selectedMetadata?.type, setValue]);+ setGateway({ gatewayId: null, gatewayPoolId: null });+ setRecordingConnectionId(null);+ setGatewayError(false);+ setRecordingError(false);+ }, [selectedMetadata?.type, selectedTemplateId, setValue]);const canProceed = Boolean(selectedFolderId && selectedTemplateId);@@ -153,7 +182,17 @@ export const CreateAccountSheet = ({ isOpen, onOpenChange, defaultFolderId }: PrselectedMetadata.credentialFields,values.credentials);- if (missingConnection.length || missingCredentials.length) {+ const gatewayMissing = needsGateway && !gateway.gatewayId && !gateway.gatewayPoolId;+ const recordingMissing = needsRecording && !recordingConnectionId;+ setGatewayError(gatewayMissing);+ setRecordingError(recordingMissing);++ if (+ missingConnection.length ||+ missingCredentials.length ||+ gatewayMissing ||+ recordingMissing+ ) {missingConnection.forEach((key) =>setError(`connectionDetails.${key}`, {type: "required",@@ -183,7 +222,10 @@ export const CreateAccountSheet = ({ isOpen, onOpenChange, defaultFolderId }: PrfolderId: values.folderId,templateId: values.templateId,connectionDetails: values.connectionDetails,- credentials: values.credentials+ credentials: values.credentials,+ ...(gateway.gatewayId ? { gatewayId: gateway.gatewayId } : {}),+ ...(gateway.gatewayPoolId ? { gatewayPoolId: gateway.gatewayPoolId } : {}),+ ...(recordingConnectionId ? { recordingConnectionId } : {})},{onSuccess: () => {@@ -381,7 +423,48 @@ export const CreateAccountSheet = ({ isOpen, onOpenChange, defaultFolderId }: Pr<div className="mt-2"><h3 className="mb-3 text-sm font-medium text-foreground">Connection Details</h3>- <ConnectionDetailsForm control={control} />+ <div className="flex flex-col gap-4">+ <ConnectionDetailsForm control={control} />+ {needsGateway && (+ <Field>+ <FieldLabel>+ Gateway<span className="text-product-pam">*</span>+ </FieldLabel>+ <FieldContent>+ <GatewayPicker+ value={gateway}+ onChange={(value) => {+ setGateway(value);+ setGatewayError(false);+ }}+ isRequired+ isError={gatewayError}+ />+ {gatewayError && <FieldError>A gateway is required</FieldError>}+ </FieldContent>+ </Field>+ )}+ {needsRecording && (+ <Field>+ <FieldLabel>+ Recording Bucket<span className="text-product-pam">*</span>+ </FieldLabel>+ <FieldContent>+ <RecordingConnectionPicker+ value={recordingConnectionId}+ onChange={(value) => {+ setRecordingConnectionId(value);+ setRecordingError(false);+ }}+ isError={recordingError}+ />+ {recordingError && (+ <FieldError>A recording bucket is required</FieldError>+ )}+ </FieldContent>+ </Field>+ )}+ </div></div><div className="mt-2">diff --git a/frontend/src/pages/pam/PamAccountsPage/components/FolderAccountRows.tsx b/frontend/src/pages/pam/PamAccountsPage/components/FolderAccountRows.tsxindex d9886d6179..93b03d85b1 100644--- a/frontend/src/pages/pam/PamAccountsPage/components/FolderAccountRows.tsx+++ b/frontend/src/pages/pam/PamAccountsPage/components/FolderAccountRows.tsx@@ -11,6 +11,7 @@ import {usePamAccountTypeMap} from "@app/hooks/api/pam";+import { AccountAccessibilityBadge } from "../../components/AccountAccessibilityBadge";import { AccountPlatformIcon } from "../../PamAccessPage/components/AccountPlatformIcon";import { AccountActionsMenu } from "./AccountActionsMenu";import { FolderActionsMenu } from "./FolderActionsMenu";@@ -77,6 +78,9 @@ export const FolderAccountRows = ({return null;}+ let count = folder.accountCount;+ if (isOpen && !isLoading) count = filterActive ? accountsToShow.length : accounts.length;+return (<><TableRow className="cursor-pointer select-none" onClick={onToggle}>@@ -91,6 +95,7 @@ export const FolderAccountRows = ({<Folder className="size-5 shrink-0 text-product-pam" />)}<span className="shrink-0 font-medium text-foreground">{folder.name}</span>+ <span className="shrink-0 text-xs text-muted">({count})</span>{folder.description && (<span className="max-w-md truncate text-muted">{folder.description}</span>)}@@ -138,6 +143,7 @@ export const FolderAccountRows = ({<HighlightText text={account.name} highlight={search} /></span><Badge variant="neutral">{map[accountType]?.name ?? account.accountType}</Badge>+ <AccountAccessibilityBadge issues={account.accessibilityIssues} /></div></TableCell><TableCell className="w-20">diff --git a/frontend/src/pages/pam/PamAccountsPage/components/RecordingConnectionPicker.tsx b/frontend/src/pages/pam/PamAccountsPage/components/RecordingConnectionPicker.tsxnew file mode 100644index 0000000000..a2d15236e5--- /dev/null+++ b/frontend/src/pages/pam/PamAccountsPage/components/RecordingConnectionPicker.tsx@@ -0,0 +1,42 @@+import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@app/components/v3";+import { AppConnection } from "@app/hooks/api/appConnections/enums";+import { useListAppConnections } from "@app/hooks/api/appConnections/queries";++const NONE_VALUE = "__none__";++type Props = {+ value: string | null;+ onChange: (value: string | null) => void;+ isError?: boolean;+ includeNone?: boolean;+};++export const RecordingConnectionPicker = ({ value, onChange, isError, includeNone }: Props) => {+ const { data: connections = [], isPending } = useListAppConnections();+ const awsConnections = connections.filter((connection) => connection.app === AppConnection.AWS);++ return (+ <Select+ value={value ?? ""}+ onValueChange={(next) => onChange(next === NONE_VALUE ? null : next)}+ disabled={isPending}+ >+ <SelectTrigger className="w-full" isError={isError}>+ <SelectValue placeholder="Select an S3 connection..." />+ </SelectTrigger>+ <SelectContent position="popper" className="z-[70]">+ {includeNone && <SelectItem value={NONE_VALUE}>None</SelectItem>}+ {awsConnections.length === 0 && (+ <div className="px-2 py-3 text-center text-xs text-muted">+ No AWS connections found. Create one from the App Connections page.+ </div>+ )}+ {awsConnections.map((connection) => (+ <SelectItem key={connection.id} value={connection.id}>+ {connection.name}+ </SelectItem>+ ))}+ </SelectContent>+ </Select>+ );+};diff --git a/frontend/src/pages/pam/PamTemplatesPage/components/TemplateDetailSheet.tsx b/frontend/src/pages/pam/PamTemplatesPage/components/TemplateDetailSheet.tsxindex fe479c4bd2..2ebebbe521 100644--- a/frontend/src/pages/pam/PamTemplatesPage/components/TemplateDetailSheet.tsx+++ b/frontend/src/pages/pam/PamTemplatesPage/components/TemplateDetailSheet.tsx@@ -1,7 +1,7 @@import { useEffect, useState } from "react";import { Controller, useForm } from "react-hook-form";import { zodResolver } from "@hookform/resolvers/zod";-import { MoreHorizontal, Settings, ShieldCheck, Trash2 } from "lucide-react";+import { MoreHorizontal, Settings, Settings2, Trash2 } from "lucide-react";import { z } from "zod";import { createNotification } from "@app/components/notifications";@@ -22,6 +22,7 @@ import {FieldError,FieldLabel,FieldTitle,+ GatewayPicker,IconButton,Input,Switch,@@ -29,6 +30,7 @@ import {} from "@app/components/v3";import { Skeleton } from "@app/components/v3/generic/Skeleton";import {+ accountTypeRequiresRecording,PamAccountType,useDeletePamAccountTemplate,useGetPamAccountTemplate,@@ -40,6 +42,7 @@ import { PamSheetTab, usePamSheetState } from "@app/hooks/usePamSheetState";import { formatDetailDate, PamDetailSheet } from "../../components/PamDetailSheet";import { SheetSaveBar } from "../../components/SheetSaveBar";import { AccountPlatformIcon } from "../../PamAccessPage/components/AccountPlatformIcon";+import { RecordingConnectionPicker } from "../../PamAccountsPage/components/RecordingConnectionPicker";import { DeleteTemplateModal } from "./DeleteTemplateModal";const configSchema = z.object({@@ -49,7 +52,7 @@ const configSchema = z.object({type ConfigForm = z.infer<typeof configSchema>;-const accessPolicySchema = z.object({+const settingsSchema = z.object({requireReason: z.boolean(),requireMfa: z.boolean(),maxSessionDurationSeconds: z@@ -58,10 +61,13 @@ const accessPolicySchema = z.object({.min(60, "Minimum 60 seconds").max(86400, "Maximum 24 hours").optional()- .nullable()+ .nullable(),+ gatewayId: z.string().nullable(),+ gatewayPoolId: z.string().nullable(),+ recordingConnectionId: z.string().nullable()});-type AccessPolicyForm = z.infer<typeof accessPolicySchema>;+type SettingsForm = z.infer<typeof settingsSchema>;type Props = {isOpen: boolean;@@ -164,7 +170,7 @@ const ConfigurationTab = ({);};-const AccessPolicyTab = ({+const SettingsTab = ({templateId,onDirtyChange}: {@@ -179,13 +185,18 @@ const AccessPolicyTab = ({control,handleSubmit,reset,+ setValue,+ watch,formState: { errors, isDirty }- } = useForm<AccessPolicyForm>({- resolver: zodResolver(accessPolicySchema),+ } = useForm<SettingsForm>({+ resolver: zodResolver(settingsSchema),defaultValues: {requireReason: false,requireMfa: false,- maxSessionDurationSeconds: null+ maxSessionDurationSeconds: null,+ gatewayId: null,+ gatewayPoolId: null,+ recordingConnectionId: null}});@@ -203,12 +214,32 @@ const AccessPolicyTab = ({maxSessionDurationSeconds:typeof policy.maxSessionDurationSeconds === "number"? policy.maxSessionDurationSeconds- : null+ : null,+ gatewayId: template.gatewayId ?? null,+ gatewayPoolId: template.gatewayPoolId ?? null,+ recordingConnectionId: template.recordingConnectionId ?? null});}}, [template, reset]);- const onSubmit = (data: AccessPolicyForm) => {+ if (isLoading) {+ return (+ <div className="flex flex-col gap-4 p-4">+ <Skeleton className="h-8 w-48" />+ <Skeleton className="h-16 w-full" />+ <Skeleton className="h-10 w-full" />+ </div>+ );+ }++ if (!template) return null;++ const gatewayId = watch("gatewayId");+ const gatewayPoolId = watch("gatewayPoolId");+ const recordingConnectionId = watch("recordingConnectionId");+ const showRecording = accountTypeRequiresRecording(template.type);++ const onSubmit = (data: SettingsForm) => {updateTemplate.mutate({templateId,@@ -216,7 +247,10 @@ const AccessPolicyTab = ({requireReason: data.requireReason,requireMfa: data.requireMfa,maxSessionDurationSeconds: data.maxSessionDurationSeconds ?? undefined- }+ },+ gatewayId: data.gatewayId,+ gatewayPoolId: data.gatewayPoolId,+ ...(showRecording ? { recordingConnectionId: data.recordingConnectionId } : {})},{onSuccess: () => createNotification({ type: "success", text: "Template updated" })@@ -224,16 +258,6 @@ const AccessPolicyTab = ({);};- if (isLoading) {- return (- <div className="flex flex-col gap-4 p-4">- <Skeleton className="h-8 w-48" />- <Skeleton className="h-16 w-full" />- <Skeleton className="h-10 w-full" />- </div>- );- }-return (<form onSubmit={handleSubmit(onSubmit)} className="flex flex-1 flex-col gap-4 p-4"><Card>@@ -296,6 +320,46 @@ const AccessPolicyTab = ({</CardContent></Card>+ <Card>+ <CardHeader className="border-b">+ <CardTitle className="text-base">System Settings</CardTitle>+ <CardDescription>System-level defaults for accounts using this template.</CardDescription>+ </CardHeader>+ <CardContent className="flex flex-col gap-4">+ <Field>+ <FieldLabel>Gateway</FieldLabel>+ <FieldContent>+ <GatewayPicker+ value={{ gatewayId, gatewayPoolId }}+ onChange={(value) => {+ setValue("gatewayId", value.gatewayId, { shouldDirty: true });+ setValue("gatewayPoolId", value.gatewayPoolId, { shouldDirty: true });+ }}+ />+ <FieldDescription>+ Used to reach accounts unless overridden on the account.+ </FieldDescription>+ </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>+<div aria-hidden className="h-8 shrink-0" />{isDirty && <SheetSaveBar isPending={updateTemplate.isPending} onDiscard={() => reset()} />}</form>@@ -380,11 +444,11 @@ export const TemplateDetailSheet = ({ isOpen, templateId, onOpenChange }: Props)metadata={metadata}tabs={[{- value: PamSheetTab.AccessPolicy,- label: "Access Policy",- icon: <ShieldCheck className="mr-1.5 size-4" />,+ value: PamSheetTab.Advanced,+ label: "General",+ icon: <Settings2 className="mr-1.5 size-4" />,content: templateId ? (- <AccessPolicyTab templateId={templateId} onDirtyChange={setIsFormDirty} />+ <SettingsTab templateId={templateId} onDirtyChange={setIsFormDirty} />) : null},{diff --git a/frontend/src/pages/pam/components/AccountAccessibilityBadge.tsx b/frontend/src/pages/pam/components/AccountAccessibilityBadge.tsxnew file mode 100644index 0000000000..7719e08b40--- /dev/null+++ b/frontend/src/pages/pam/components/AccountAccessibilityBadge.tsx@@ -0,0 +1,37 @@+import { AlertTriangle } from "lucide-react";++import { Badge, Tooltip, TooltipContent, TooltipTrigger } from "@app/components/v3";+import { PamAccountAccessibilityIssue } from "@app/hooks/api/pam";++const ISSUE_LABELS: Record<PamAccountAccessibilityIssue, string> = {+ [PamAccountAccessibilityIssue.NoGateway]: "No gateway is configured",+ [PamAccountAccessibilityIssue.NoRecordingConfig]: "No recording bucket is configured",+ [PamAccountAccessibilityIssue.NoCredential]: "No password is set"+};++type Props = {+ issues: PamAccountAccessibilityIssue[];+};++export const AccountAccessibilityBadge = ({ issues }: Props) => {+ if (!issues.length) return null;++ return (+ <Tooltip>+ <TooltipTrigger asChild>+ <Badge variant="warning">+ <AlertTriangle className="size-3" />+ Unavailable+ </Badge>+ </TooltipTrigger>+ <TooltipContent>+ <p className="mb-1 font-medium">This account can't be used yet</p>+ <ul className="list-inside list-disc">+ {issues.map((issue) => (+ <li key={issue}>{ISSUE_LABELS[issue]}</li>+ ))}+ </ul>+ </TooltipContent>+ </Tooltip>+ );+};