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
feat(pam): registry-driven template policies
x032205b535d7180084
diff --git a/backend/src/db/migrations/20260603030053_pam-revamp.ts b/backend/src/db/migrations/20260603030053_pam-revamp.tsindex 159449dcd9..95f070ac35 100644--- a/backend/src/db/migrations/20260603030053_pam-revamp.ts+++ b/backend/src/db/migrations/20260603030053_pam-revamp.ts@@ -32,7 +32,6 @@ const seedDefaultTemplates = async (knex: Knex, projectId: string) => {projectId,name: template.name,type: template.type,- accessPolicy: template.accessPolicy,settings: template.settings}).onConflict(["projectId", "name"])@@ -85,7 +84,7 @@ export async function up(knex: Knex): Promise<void> {t.string("type").notNullable();t.index("type");- t.jsonb("accessPolicy").nullable();+ t.jsonb("policies").nullable();t.jsonb("settings").nullable();t.uuid("gatewayId").nullable();diff --git a/backend/src/db/schemas/pam-account-templates.ts b/backend/src/db/schemas/pam-account-templates.tsindex 59146aca09..dcae5b7563 100644--- a/backend/src/db/schemas/pam-account-templates.ts+++ b/backend/src/db/schemas/pam-account-templates.ts@@ -13,7 +13,7 @@ export const PamAccountTemplatesSchema = z.object({name: z.string(),description: z.string().nullable().optional(),type: z.string(),- accessPolicy: z.unknown().nullable().optional(),+ policies: z.unknown().nullable().optional(),settings: z.unknown().nullable().optional(),gatewayId: z.string().uuid().nullable().optional(),gatewayPoolId: z.string().uuid().nullable().optional(),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 9c42bed798..13bfea9ee5 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@@ -9,10 +9,7 @@ import {PamAccountAccessibilityIssue,PamAccountTypeMetadataSchema} from "@app/ee/services/pam-account/pam-account-schemas";-import {- PamTemplateAccessPolicySchema,- PamTemplateSettingsSchema-} from "@app/ee/services/pam-account-template/pam-account-template-schemas";+import { PamTemplateSettingsSchema } from "@app/ee/services/pam-account-template/pam-account-template-schemas";import { SESSION_HANDLERS } from "@app/ee/services/pam-web-access/pam-session-handlers";import { ApiDocsTags } from "@app/lib/api-docs/constants";import { readLimit, writeLimit } from "@app/server/config/rateLimiter";@@ -58,7 +55,7 @@ const accountDetailVariants = Object.entries(ACCOUNT_TYPE_CONFIGS).map(([accountSanitizedAccountListItemSchema.extend({accountType: z.literal(accountType as TSupportedAccountType),connectionDetails: config.connectionDetails,- templateAccessPolicy: PamTemplateAccessPolicySchema.nullable().optional(),+ templatePolicies: z.record(z.unknown()).nullable().optional(),templateSettings: PamTemplateSettingsSchema.nullable().optional(),credentials: config.sanitizedCredentials,isAccessible: z.boolean().describe("Whether the account is fully provisioned to launch a session"),diff --git a/backend/src/ee/routes/v1/pam-routers/pam-account-template-router.ts b/backend/src/ee/routes/v1/pam-routers/pam-account-template-router.tsindex fc6cef0f1b..56bf2484f1 100644--- a/backend/src/ee/routes/v1/pam-routers/pam-account-template-router.ts+++ b/backend/src/ee/routes/v1/pam-routers/pam-account-template-router.ts@@ -3,10 +3,7 @@ import z from "zod";import { PamAccountTemplatesSchema } from "@app/db/schemas";import { EventType } from "@app/ee/services/audit-log/audit-log-types";import { PamAccountType } from "@app/ee/services/pam/pam-enums";-import {- PamTemplateAccessPolicySchema,- PamTemplateSettingsSchema-} from "@app/ee/services/pam-account-template/pam-account-template-schemas";+import { PamTemplateSettingsSchema } from "@app/ee/services/pam-account-template/pam-account-template-schemas";import { ApiDocsTags } from "@app/lib/api-docs/constants";import { readLimit, writeLimit } from "@app/server/config/rateLimiter";import { slugSchema } from "@app/server/lib/schemas";@@ -20,7 +17,7 @@ const SanitizedTemplateSchema = PamAccountTemplatesSchema.pick({name: true,description: true,type: true,- accessPolicy: true,+ policies: true,settings: true,gatewayId: true,gatewayPoolId: true,@@ -107,7 +104,7 @@ export const registerPamAccountTemplateRouter = async (server: FastifyZodProvidename: slugSchema({ field: "Name" }).describe("Name for the template"),description: z.string().trim().max(256).optional().describe("Optional description"),type: z.nativeEnum(PamAccountType).describe("The account type this template applies to"),- accessPolicy: PamTemplateAccessPolicySchema.optional().describe("Access policy configuration"),+ policies: z.record(z.unknown()).optional().describe("Policy values keyed by policy type"),settings: PamTemplateSettingsSchema.optional().describe("Template settings"),gatewayId: z.string().uuid().optional().describe("Default gateway ID for accounts using this template"),gatewayPoolId: z.string().uuid().optional().describe("Default gateway pool ID"),@@ -172,7 +169,7 @@ export const registerPamAccountTemplateRouter = async (server: FastifyZodProvidebody: z.object({name: slugSchema({ field: "Name" }).optional().describe("New name"),description: z.string().trim().max(256).nullable().optional().describe("New description"),- accessPolicy: PamTemplateAccessPolicySchema.optional().describe("Updated access policy"),+ policies: z.record(z.unknown()).optional().describe("Policy values keyed by policy type"),settings: PamTemplateSettingsSchema.optional().describe("Updated settings"),gatewayId: z.string().uuid().nullable().optional().describe("New gateway ID"),gatewayPoolId: z.string().uuid().nullable().optional().describe("New gateway pool ID"),diff --git a/backend/src/ee/services/pam-account-template/pam-account-template-schemas.ts b/backend/src/ee/services/pam-account-template/pam-account-template-schemas.tsindex 7e4dc4253f..158aac0e1a 100644--- a/backend/src/ee/services/pam-account-template/pam-account-template-schemas.ts+++ b/backend/src/ee/services/pam-account-template/pam-account-template-schemas.ts@@ -25,12 +25,5 @@ export const PamTemplateSettingsSchema = z.object({sessionLogMaskingPatterns: z.array(z.string().min(1).max(500)).max(20).optional()});-export const PamTemplateAccessPolicySchema = z.object({- maxSessionDurationSeconds: z.number().int().min(60).max(86400).optional(),- requireReason: z.boolean().default(false),- requireMfa: z.boolean().default(false)-});-export type TPamTemplateSettings = z.infer<typeof PamTemplateSettingsSchema>;-export type TPamTemplateAccessPolicy = z.infer<typeof PamTemplateAccessPolicySchema>;export type TPamPasswordConstraints = z.infer<typeof PamPasswordConstraintsSchema>;diff --git a/backend/src/ee/services/pam-account-template/pam-account-template-service.ts b/backend/src/ee/services/pam-account-template/pam-account-template-service.tsindex 18cd169145..8989e638e4 100644--- a/backend/src/ee/services/pam-account-template/pam-account-template-service.ts+++ b/backend/src/ee/services/pam-account-template/pam-account-template-service.ts@@ -2,8 +2,9 @@ import { TPermissionServiceFactory } from "@app/ee/services/permission/permissioimport { DatabaseErrorCode } from "@app/lib/error-codes";import { BadRequestError, DatabaseError, ForbiddenRequestError, NotFoundError } from "@app/lib/errors";-import { PamProductRole } from "../pam/pam-enums";+import { PamAccountType, PamProductRole } from "../pam/pam-enums";import { TActorContext, verifyProductMembership } from "../pam/pam-permission";+import { validatePolicyValues } from "../pam/pam-policies";import { TPamValidatorDeps, validateGatewayAttachment, validateRecordingConnection } from "../pam/pam-validators";import { ACCOUNT_TYPE_CONFIGS } from "../pam-account/pam-account-schemas";import { TPamAccountTemplateDALFactory } from "./pam-account-template-dal";@@ -30,6 +31,12 @@ export const pamAccountTemplateServiceFactory = (deps: TPamAccountTemplateServicconst verifyMembership = (projectId: string, ctx: TActorContext) =>verifyProductMembership(permissionService, projectId, ctx);+ const validateTemplatePolicies = (accountType: string, policies: unknown) => {+ if (!policies || typeof policies !== "object") return;+ const result = validatePolicyValues(accountType as PamAccountType, policies as Record<string, unknown>);+ if (!result.ok) throw new BadRequestError({ message: result.message });+ };+const verifyProductAdmin = async (projectId: string, ctx: TActorContext) => {const { hasRole } = await verifyMembership(projectId, ctx);if (!hasRole(PamProductRole.Admin)) {@@ -60,7 +67,7 @@ export const pamAccountTemplateServiceFactory = (deps: TPamAccountTemplateServicname,description,type,- accessPolicy,+ policies,settings,gatewayId,gatewayPoolId,@@ -70,6 +77,7 @@ export const pamAccountTemplateServiceFactory = (deps: TPamAccountTemplateServicawait verifyProductAdmin(projectId, ctx);await validateGatewayAttachment(deps, gatewayId, gatewayPoolId, ctx);await validateRecordingConnection(deps, recordingConnectionId, ctx);+ validateTemplatePolicies(type, policies);try {return await pamAccountTemplateDAL.create({@@ -77,7 +85,7 @@ export const pamAccountTemplateServiceFactory = (deps: TPamAccountTemplateServicname,description,type,- accessPolicy: accessPolicy ?? undefined,+ policies: policies ?? undefined,settings: settings ?? undefined,gatewayId,gatewayPoolId,@@ -99,7 +107,7 @@ export const pamAccountTemplateServiceFactory = (deps: TPamAccountTemplateServicprojectId,name,description,- accessPolicy,+ policies,settings,gatewayId,gatewayPoolId,@@ -115,10 +123,12 @@ export const pamAccountTemplateServiceFactory = (deps: TPamAccountTemplateServicthrow new NotFoundError({ message: `Account template with ID '${templateId}' not found` });}+ validateTemplatePolicies(existing.type, policies);+const updateData: Record<string, unknown> = {};if (name !== undefined) updateData.name = name;if (description !== undefined) updateData.description = description;- if (accessPolicy !== undefined) updateData.accessPolicy = accessPolicy;+ if (policies !== undefined) updateData.policies = policies;if (settings !== undefined) updateData.settings = settings;if (gatewayId !== undefined) updateData.gatewayId = gatewayId;if (gatewayPoolId !== undefined) updateData.gatewayPoolId = gatewayPoolId;diff --git a/backend/src/ee/services/pam-account-template/pam-account-template-types.ts b/backend/src/ee/services/pam-account-template/pam-account-template-types.tsindex 20823b0e35..76ea19d9d8 100644--- a/backend/src/ee/services/pam-account-template/pam-account-template-types.ts+++ b/backend/src/ee/services/pam-account-template/pam-account-template-types.ts@@ -1,12 +1,12 @@import { PamAccountType } from "../pam/pam-enums";-import { TPamTemplateAccessPolicy, TPamTemplateSettings } from "./pam-account-template-schemas";+import { TPamTemplateSettings } from "./pam-account-template-schemas";export type TCreatePamAccountTemplateDTO = {projectId: string;name: string;description?: string;type: PamAccountType;- accessPolicy?: TPamTemplateAccessPolicy;+ policies?: Record<string, unknown>;settings?: TPamTemplateSettings;gatewayId?: string;gatewayPoolId?: string;@@ -18,7 +18,7 @@ export type TUpdatePamAccountTemplateDTO = {projectId: string;name?: string;description?: string | null;- accessPolicy?: TPamTemplateAccessPolicy;+ policies?: Record<string, unknown>;settings?: TPamTemplateSettings;gatewayId?: string | null;gatewayPoolId?: string | null;diff --git a/backend/src/ee/services/pam-account/pam-account-dal.ts b/backend/src/ee/services/pam-account/pam-account-dal.tsindex 677ad73eb0..2574c5dbb9 100644--- a/backend/src/ee/services/pam-account/pam-account-dal.ts+++ b/backend/src/ee/services/pam-account/pam-account-dal.ts@@ -48,7 +48,7 @@ export type TPamAccountDetail = TPamAccounts &TPamAccountTemplateInheritedFields & {accountType: string;templateName: string;- templateAccessPolicy: unknown;+ templatePolicies: unknown;templateSettings: unknown;folderName: string | null;};@@ -154,7 +154,7 @@ export const pamAccountDALFactory = (db: TDbClient) => {`${TableName.PamAccount}.*`,`${TableName.PamAccountTemplate}.type as accountType`,`${TableName.PamAccountTemplate}.name as templateName`,- `${TableName.PamAccountTemplate}.accessPolicy as templateAccessPolicy`,+ `${TableName.PamAccountTemplate}.policies as templatePolicies`,`${TableName.PamAccountTemplate}.settings as templateSettings`,`${TableName.PamAccountTemplate}.gatewayId as templateGatewayId`,`${TableName.PamAccountTemplate}.gatewayPoolId as templateGatewayPoolId`,diff --git a/backend/src/ee/services/pam-account/pam-account-schemas.ts b/backend/src/ee/services/pam-account/pam-account-schemas.tsindex 410702086b..587465f21d 100644--- a/backend/src/ee/services/pam-account/pam-account-schemas.ts+++ b/backend/src/ee/services/pam-account/pam-account-schemas.ts@@ -3,6 +3,7 @@ import RE2 from "re2";import { z } from "zod";import { PamAccountType } from "../pam/pam-enums";+import { getApplicablePolicies, PamPolicyDescriptorSchema } from "../pam/pam-policies";enum PamFieldWidget {Text = "text",@@ -281,7 +282,8 @@ export const PamAccountTypeMetadataSchema = z.object({icon: z.string(),supportsWebAccess: z.boolean(),connectionFields: z.array(PamFieldDescriptorSchema),- credentialFields: z.array(PamFieldDescriptorSchema)+ credentialFields: z.array(PamFieldDescriptorSchema),+ applicablePolicies: z.array(PamPolicyDescriptorSchema)});type PamAccountTypeMetadata = z.infer<typeof PamAccountTypeMetadataSchema>;@@ -423,7 +425,8 @@ export const buildPamAccountTypeMetadata = (webAccessSupportedTypes: Set<PamAccoicon: config.icon,supportsWebAccess: webAccessSupportedTypes.has(type),connectionFields: fieldsFromSchema(config.connectionDetails, config.ui),- credentialFields: fieldsFromSchema(config.credentials, config.ui)+ credentialFields: fieldsFromSchema(config.credentials, config.ui),+ applicablePolicies: getApplicablePolicies(type)}));export const isCredentialConfigured = (accountType: PamAccountType, credentials: Record<string, unknown>): boolean => {diff --git a/backend/src/ee/services/pam-account/pam-account-service.ts b/backend/src/ee/services/pam-account/pam-account-service.tsindex 3d754ef477..5031b54b8f 100644--- a/backend/src/ee/services/pam-account/pam-account-service.ts+++ b/backend/src/ee/services/pam-account/pam-account-service.ts@@ -185,7 +185,7 @@ export const pamAccountServiceFactory = (deps: TPamAccountServiceFactoryDep) =>folderName: account.folderName,templateId: account.templateId,templateName: account.templateName,- templateAccessPolicy: account.templateAccessPolicy,+ templatePolicies: account.templatePolicies,templateSettings: account.templateSettings,accountType: account.accountType,projectId: account.projectId,diff --git a/backend/src/ee/services/pam-project/pam-project-bootstrap.ts b/backend/src/ee/services/pam-project/pam-project-bootstrap.tsindex dc0460e230..28a11b51b6 100644--- a/backend/src/ee/services/pam-project/pam-project-bootstrap.ts+++ b/backend/src/ee/services/pam-project/pam-project-bootstrap.ts@@ -8,7 +8,7 @@ import { TMembershipRoleDALFactory } from "@app/services/membership/membership-rimport { TProjectDALFactory } from "@app/services/project/project-dal";import { PamAccountType } from "../pam/pam-enums";-import { TPamTemplateAccessPolicy, TPamTemplateSettings } from "../pam-account-template/pam-account-template-schemas";+import { TPamTemplateSettings } from "../pam-account-template/pam-account-template-schemas";import { PamRecordingStorageBackend } from "../pam-session-recording/pam-recording-enums";type TBootstrapDeps = {@@ -25,21 +25,13 @@ type TBootstrapInput = {export type TDefaultTemplate = {name: string;type: PamAccountType;- accessPolicy: TPamTemplateAccessPolicy;settings: TPamTemplateSettings;};-const DEFAULT_ACCESS_POLICY: TPamTemplateAccessPolicy = {- maxSessionDurationSeconds: 3600,- requireReason: false,- requireMfa: false-};-export const DEFAULT_ACCOUNT_TEMPLATES: TDefaultTemplate[] = [{name: "ssh",type: PamAccountType.SSH,- accessPolicy: DEFAULT_ACCESS_POLICY,settings: {recordingEnabled: true,recordingStorageBackend: PamRecordingStorageBackend.Postgres@@ -48,7 +40,6 @@ export const DEFAULT_ACCOUNT_TEMPLATES: TDefaultTemplate[] = [{name: "postgres",type: PamAccountType.Postgres,- accessPolicy: DEFAULT_ACCESS_POLICY,settings: {recordingEnabled: true,recordingStorageBackend: PamRecordingStorageBackend.Postgres,@@ -65,7 +56,6 @@ export const DEFAULT_ACCOUNT_TEMPLATES: TDefaultTemplate[] = [{name: "mysql",type: PamAccountType.MySQL,- accessPolicy: DEFAULT_ACCESS_POLICY,settings: {recordingEnabled: true,recordingStorageBackend: PamRecordingStorageBackend.Postgres,@@ -82,7 +72,6 @@ export const DEFAULT_ACCOUNT_TEMPLATES: TDefaultTemplate[] = [{name: "mssql",type: PamAccountType.MsSQL,- accessPolicy: DEFAULT_ACCESS_POLICY,settings: {recordingEnabled: true,recordingStorageBackend: PamRecordingStorageBackend.Postgres,@@ -99,7 +88,6 @@ export const DEFAULT_ACCOUNT_TEMPLATES: TDefaultTemplate[] = [{name: "oracledb",type: PamAccountType.OracleDB,- accessPolicy: DEFAULT_ACCESS_POLICY,settings: {recordingEnabled: true,recordingStorageBackend: PamRecordingStorageBackend.Postgres,@@ -116,7 +104,6 @@ export const DEFAULT_ACCOUNT_TEMPLATES: TDefaultTemplate[] = [{name: "mongodb",type: PamAccountType.MongoDB,- accessPolicy: DEFAULT_ACCESS_POLICY,settings: {recordingEnabled: true,recordingStorageBackend: PamRecordingStorageBackend.Postgres,@@ -133,7 +120,6 @@ export const DEFAULT_ACCOUNT_TEMPLATES: TDefaultTemplate[] = [{name: "redis",type: PamAccountType.Redis,- accessPolicy: DEFAULT_ACCESS_POLICY,settings: {recordingEnabled: true,recordingStorageBackend: PamRecordingStorageBackend.Postgres,@@ -150,7 +136,6 @@ export const DEFAULT_ACCOUNT_TEMPLATES: TDefaultTemplate[] = [{name: "kubernetes",type: PamAccountType.Kubernetes,- accessPolicy: DEFAULT_ACCESS_POLICY,settings: {recordingEnabled: true,recordingStorageBackend: PamRecordingStorageBackend.Postgres@@ -159,7 +144,6 @@ export const DEFAULT_ACCOUNT_TEMPLATES: TDefaultTemplate[] = [{name: "aws-iam",type: PamAccountType.AwsIam,- accessPolicy: DEFAULT_ACCESS_POLICY,settings: {recordingEnabled: true,recordingStorageBackend: PamRecordingStorageBackend.Postgres@@ -168,7 +152,6 @@ export const DEFAULT_ACCOUNT_TEMPLATES: TDefaultTemplate[] = [{name: "windows",type: PamAccountType.Windows,- accessPolicy: DEFAULT_ACCESS_POLICY,settings: {recordingEnabled: true,recordingStorageBackend: PamRecordingStorageBackend.AwsS3,@@ -185,7 +168,6 @@ export const DEFAULT_ACCOUNT_TEMPLATES: TDefaultTemplate[] = [{name: "active-directory",type: PamAccountType.ActiveDirectory,- accessPolicy: DEFAULT_ACCESS_POLICY,settings: {recordingEnabled: true,recordingStorageBackend: PamRecordingStorageBackend.AwsS3,@@ -254,7 +236,6 @@ export const bootstrapPamProject = async (projectId: project.id,name: template.name,type: template.type,- accessPolicy: template.accessPolicy,settings: template.settings});}diff --git a/backend/src/ee/services/pam-session/pam-session-service.ts b/backend/src/ee/services/pam-session/pam-session-service.tsindex 3c58f247c2..832d145820 100644--- a/backend/src/ee/services/pam-session/pam-session-service.ts+++ b/backend/src/ee/services/pam-session/pam-session-service.ts@@ -25,9 +25,9 @@ import {TActorContext,verifyProductMembership} from "../pam/pam-permission";+import { resolveAccessControls } from "../pam/pam-policies";import { TPamAccountDALFactory } from "../pam-account/pam-account-dal";import { extractGatewayTarget, parseInternalMetadata } from "../pam-account/pam-account-schemas";-import { PamTemplateAccessPolicySchema } from "../pam-account-template/pam-account-template-schemas";import { TPamFolderDALFactory } from "../pam-folder/pam-folder-dal";import { PamRecordingStorageBackend } from "../pam-session-recording/pam-recording-enums";import { generateSessionRecordingSecrets } from "../pam-session-recording/pam-recording-secrets";@@ -165,7 +165,7 @@ export const pamSessionServiceFactory = ({clientPublicKey,keyId: `pam-session-${session.id}`,principals: [username],- requestedTtl: `${PamTemplateAccessPolicySchema.safeParse(account.templateAccessPolicy).data?.maxSessionDurationSeconds ?? DEFAULT_SESSION_DURATION_MS / 1000}s`,+ requestedTtl: `${resolveAccessControls(account.templatePolicies).maxSessionDurationSeconds ?? DEFAULT_SESSION_DURATION_MS / 1000}s`,certType: SshCertType.USER});@@ -293,20 +293,17 @@ export const pamSessionServiceFactory = ({const trimmedReason = reason?.trim() || null;- const accessPolicy = account.templateAccessPolicy- ? PamTemplateAccessPolicySchema.safeParse(account.templateAccessPolicy)- : null;- const policy = accessPolicy?.success ? accessPolicy.data : null;+ const policy = resolveAccessControls(account.templatePolicies);- if (policy?.requireReason && !trimmedReason) {+ if (policy.requireReason && !trimmedReason) {throw new BadRequestError({ message: "A reason is required to access this account" });}- if (policy?.requireMfa) {+ if (policy.requireMfa) {throw new BadRequestError({ message: "MFA verification is required to access this account" });}- const maxDurationMs = policy?.maxSessionDurationSeconds+ const maxDurationMs = policy.maxSessionDurationSeconds? policy.maxSessionDurationSeconds * 1000: DEFAULT_SESSION_DURATION_MS;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 96f4b27e8a..8dbde92d0c 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@@ -6,7 +6,7 @@ import { AuditLogInfo, EventType, TAuditLogServiceFactory } from "@app/ee/servicimport { TGatewayPoolServiceFactory } from "@app/ee/services/gateway-pool/gateway-pool-service";import { TGatewayV2ServiceFactory } from "@app/ee/services/gateway-v2/gateway-v2-service";import { PamAccountType } from "@app/ee/services/pam/pam-enums";-import { PamTemplateAccessPolicySchema } from "@app/ee/services/pam-account-template/pam-account-template-schemas";+import { resolveAccessControls } from "@app/ee/services/pam/pam-policies";import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service-types";import { ResourcePermissionPamResourceActions } from "@app/ee/services/permission/resource-permission";import { BadRequestError, NotFoundError } from "@app/lib/errors";@@ -139,20 +139,17 @@ export const pamWebAccessServiceFactory = ({const trimmedReason = reason?.trim() || null;- const accessPolicy = account.templateAccessPolicy- ? PamTemplateAccessPolicySchema.safeParse(account.templateAccessPolicy)- : null;- const policy = accessPolicy?.success ? accessPolicy.data : null;+ const policy = resolveAccessControls(account.templatePolicies);- if (policy?.requireReason && !trimmedReason) {+ if (policy.requireReason && !trimmedReason) {throw new BadRequestError({ message: "A reason is required to access this account" });}- if (policy?.requireMfa) {+ if (policy.requireMfa) {throw new BadRequestError({ message: "MFA verification is required to access this account" });}- const maxSessionDurationMs = policy?.maxSessionDurationSeconds+ const maxSessionDurationMs = policy.maxSessionDurationSeconds? policy.maxSessionDurationSeconds * 1000: DEFAULT_WEB_SESSION_DURATION_MS;diff --git a/backend/src/ee/services/pam/CLAUDE.md b/backend/src/ee/services/pam/CLAUDE.mdindex 2548709553..072706f08d 100644--- a/backend/src/ee/services/pam/CLAUDE.md+++ b/backend/src/ee/services/pam/CLAUDE.md@@ -8,10 +8,10 @@ All PAM services live under `backend/src/ee/services/pam-*/`:| Directory | Purpose ||---|---|-| `pam/` | Shared enums (`PamAccountType`, `PamResourceRole`, `PamProductRole`, `PamSessionStatus`, `PamAccessMethod`), shared permission helpers (`pam-permission.ts`), validators (`pam-validators.ts`), and this CLAUDE.md |+| `pam/` | Shared enums (`PamAccountType`, `PamResourceRole`, `PamProductRole`, `PamSessionStatus`, `PamAccessMethod`), permission helpers (`pam-permission.ts`), validators (`pam-validators.ts`), the policy registry (`pam-policies.ts`), and this CLAUDE.md || `pam-folder/` | Folder CRUD, folder-level permission checks || `pam-account/` | Account CRUD, credential encryption, gateway attachment, SSH CA management |-| `pam-account-template/` | Account templates (type + access policy + settings), template config schemas (`pam-account-template-schemas.ts`) |+| `pam-account-template/` | Account templates (type + policies + settings), template config schemas (`pam-account-template-schemas.ts`); policy values live in the `policies` column, see [Policies](#policies) || `pam-session/` | Session lifecycle (DAL, service, types) || `pam-session-recording/` | Recording chunk storage, retrieval, secrets, and storage providers (`aws-s3/`, `postgres/`) || `pam-membership/` | Product + resource membership management |@@ -122,6 +122,28 @@ Most types need only backend changes -- the frontend auto-renders from metadata.No changes to the account form components, router schemas, or field renderers are needed. The per-type route bodies use `config.connectionDetails`/`config.credentials` directly, the detail response (`SanitizedAccountDetailSchema`) is a discriminated union auto-derived from `ACCOUNT_TYPE_CONFIGS` (each variant pulls `connectionDetails` and `sanitizedCredentials` from the config), and the frontend forms render from `GET /pam/accounts/types`.+## Policies++Policies are the governance controls applied to a template (require MFA, require reason, max session duration). They are registry-driven, defined once in `PAM_POLICY_DEFINITIONS` in `pam/pam-policies.ts`, keyed by `PamPolicyType`. Each entry is `{ label, description, appliesTo, schema }` where `appliesTo` is an account-type list or `"all"`, and `schema` is the Zod schema for that policy's value (a primitive or object).++"Access policy" is the category, not a type: MFA, reason, and duration are individual peer policies that each `appliesTo: "all"`. `appliesTo` can also be a list to scope a policy to specific account types. This is distinct from **settings** (recording, password constraints), which are NOT policies, they live in the template's separate `settings` column with their own schema and bespoke UI.++Storage: a template's `policies` jsonb column is a flat map keyed by `PamPolicyType`, e.g. `{ "require-mfa": true, "max-session-duration": 3600 }`. No DB defaults and no per-policy migration: absence resolves to the policy's natural default in the resolver (a missing boolean is `false`, a missing duration falls back to `DEFAULT_SESSION_DURATION_MS`).++A registry entry flows automatically to:+- **`GET /pam/accounts/types`** (`applicablePolicies`), so the frontend renders the right editors per account type with no per-type wiring.+- **`validatePolicyValues`**, used by template create/update to reject policies that don't apply to the type or fail their schema (returns a result object; the caller maps `ok: false` to a `BadRequestError`).++Every current policy is server-enforced: `resolveAccessControls` reads the reason/MFA/duration gates and they're applied in `pam-session`/`pam-web-access`. A gateway-enforced policy would instead pass its value to the gateway in `getSessionCredentials` (not currently wired, no policy needs it yet).++### Adding a New Policy++1. Add the value to `PamPolicyType` and an entry to `PAM_POLICY_DEFINITIONS` in `pam/pam-policies.ts` (`label`, `description`, `appliesTo`, `schema`). Mirror the enum value in `frontend/src/hooks/api/pam/enums.ts`.+2. Register the policy in `POLICY_EDITORS` (`frontend/src/pages/pam/components/policyEditors/`), keyed by the new `PamPolicyType`. Reuse an existing editor when the value shape matches (`BooleanPolicyEditor` for a `z.boolean()`, `DurationPolicyEditor` for a number); only write a new editor component for a novel value shape. Each editor receives `{ label, description, value, onChange }` and owns its own layout, booleans render inline, others vertical.+3. Enforcement: read it where it's enforced. A server-enforced policy extends `resolveAccessControls` and is applied in `pam-session`/`pam-web-access`. A gateway-enforced policy passes its value to the gateway in `getSessionCredentials`.++No migration, no router or response-schema change, and no DB default.+## Session Lifecycle- Sessions reference accounts via nullable `accountId` (SET NULL on delete) so session history survives account deletiondiff --git a/backend/src/ee/services/pam/pam-policies.test.ts b/backend/src/ee/services/pam/pam-policies.test.tsnew file mode 100644index 0000000000..78a73a2058--- /dev/null+++ b/backend/src/ee/services/pam/pam-policies.test.ts@@ -0,0 +1,41 @@+import { describe, expect, test } from "vitest";++import { PamAccountType } from "./pam-enums";+import { getApplicablePolicies, PamPolicyType, validatePolicyValues } from "./pam-policies";++describe("getApplicablePolicies", () => {+ test("returns the universal policies for any account type", () => {+ const keys = getApplicablePolicies(PamAccountType.Postgres).map((p) => p.key);+ expect(keys).toContain(PamPolicyType.RequireMfa);+ expect(keys).toContain(PamPolicyType.RequireReason);+ expect(keys).toContain(PamPolicyType.MaxSessionDuration);+ });+});++describe("validatePolicyValues", () => {+ test("returns empty data for null/undefined", () => {+ expect(validatePolicyValues(PamAccountType.SSH, null)).toEqual({ ok: true, data: {} });+ expect(validatePolicyValues(PamAccountType.SSH, undefined)).toEqual({ ok: true, data: {} });+ });++ test("accepts valid policy values", () => {+ expect(+ validatePolicyValues(PamAccountType.SSH, {+ [PamPolicyType.RequireMfa]: true,+ [PamPolicyType.MaxSessionDuration]: 3600+ })+ ).toEqual({+ ok: true,+ data: { [PamPolicyType.RequireMfa]: true, [PamPolicyType.MaxSessionDuration]: 3600 }+ });+ });++ test("rejects an unknown policy", () => {+ expect(validatePolicyValues(PamAccountType.SSH, { "not-a-policy": true }).ok).toBe(false);+ });++ test("rejects an invalid value shape", () => {+ expect(validatePolicyValues(PamAccountType.SSH, { [PamPolicyType.RequireMfa]: "nope" }).ok).toBe(false);+ expect(validatePolicyValues(PamAccountType.SSH, { [PamPolicyType.MaxSessionDuration]: 10 }).ok).toBe(false);+ });+});diff --git a/backend/src/ee/services/pam/pam-policies.ts b/backend/src/ee/services/pam/pam-policies.tsnew file mode 100644index 0000000000..f20d542a7b--- /dev/null+++ b/backend/src/ee/services/pam/pam-policies.ts@@ -0,0 +1,103 @@+import { z } from "zod";++import { PamAccountType } from "./pam-enums";++export enum PamPolicyType {+ RequireMfa = "require-mfa",+ RequireReason = "require-reason",+ MaxSessionDuration = "max-session-duration"+}++type TPamPolicyDefinition = {+ label: string;+ description: string;+ appliesTo: PamAccountType[] | "all";+ schema: z.ZodTypeAny;+};++export const PAM_POLICY_DEFINITIONS: Record<PamPolicyType, TPamPolicyDefinition> = {+ [PamPolicyType.RequireMfa]: {+ label: "Require MFA",+ description: "Users must re-authenticate with MFA before accessing.",+ appliesTo: "all",+ schema: z.boolean()+ },+ [PamPolicyType.RequireReason]: {+ label: "Require Reason",+ description: "Users must provide a reason before accessing.",+ appliesTo: "all",+ schema: z.boolean()+ },+ [PamPolicyType.MaxSessionDuration]: {+ label: "Max Session Duration",+ description: "Maximum session length in seconds (60 to 86400).",+ appliesTo: "all",+ schema: z.number().int().min(60).max(86400)+ }+};++export const PamPolicyDescriptorSchema = z.object({+ key: z.nativeEnum(PamPolicyType),+ label: z.string(),+ description: z.string()+});++export const policyAppliesTo = (policy: PamPolicyType, accountType: PamAccountType): boolean => {+ const { appliesTo } = PAM_POLICY_DEFINITIONS[policy];+ return appliesTo === "all" || appliesTo.includes(accountType);+};++export const getApplicablePolicies = (accountType: PamAccountType) =>+ (Object.entries(PAM_POLICY_DEFINITIONS) as [PamPolicyType, TPamPolicyDefinition][])+ .filter(([key]) => policyAppliesTo(key, accountType))+ .map(([key, def]) => ({ key, label: def.label, description: def.description }));++export type TValidatePolicyValuesResult = { ok: true; data: Record<string, unknown> } | { ok: false; message: string };++export const validatePolicyValues = (+ accountType: PamAccountType,+ policies: Record<string, unknown> | null | undefined+): TValidatePolicyValuesResult => {+ if (!policies) return { ok: true, data: {} };++ const data: Record<string, unknown> = {};+ for (const [key, value] of Object.entries(policies)) {+ if (!(key in PAM_POLICY_DEFINITIONS)) {+ return { ok: false, message: `Unknown PAM policy '${key}'` };+ }++ const policy = key as PamPolicyType;+ if (!policyAppliesTo(policy, accountType)) {+ return { ok: false, message: `Policy '${key}' does not apply to account type '${accountType}'` };+ }++ const parsed = PAM_POLICY_DEFINITIONS[policy].schema.safeParse(value);+ if (!parsed.success) {+ return { ok: false, message: `Invalid configuration for policy '${key}'` };+ }+ data[key] = parsed.data;+ }++ return { ok: true, data };+};++const resolvePolicy = (policyMap: unknown, policy: PamPolicyType): unknown => {+ if (!policyMap || typeof policyMap !== "object") return null;+ const parsed = PAM_POLICY_DEFINITIONS[policy].schema.safeParse((policyMap as Record<string, unknown>)[policy]);+ return parsed.success ? parsed.data : null;+};++export type TPamAccessControls = {+ requireReason: boolean;+ requireMfa: boolean;+ maxSessionDurationSeconds: number | null;+};++export const resolveAccessControls = (policyMap: unknown): TPamAccessControls => {+ const duration = resolvePolicy(policyMap, PamPolicyType.MaxSessionDuration);+ return {+ requireReason: resolvePolicy(policyMap, PamPolicyType.RequireReason) === true,+ requireMfa: resolvePolicy(policyMap, PamPolicyType.RequireMfa) === true,+ maxSessionDurationSeconds: typeof duration === "number" ? duration : null+ };+};diff --git a/frontend/src/hooks/api/pam/enums.ts b/frontend/src/hooks/api/pam/enums.tsindex a3714963f5..60013bf213 100644--- a/frontend/src/hooks/api/pam/enums.ts+++ b/frontend/src/hooks/api/pam/enums.ts@@ -12,6 +12,12 @@ export enum PamAccountType {ActiveDirectory = "active-directory"}+export enum PamPolicyType {+ RequireMfa = "require-mfa",+ RequireReason = "require-reason",+ MaxSessionDuration = "max-session-duration"+}+export enum SessionChannelType {Terminal = "terminal",Exec = "exec",diff --git a/frontend/src/hooks/api/pam/types/index.ts b/frontend/src/hooks/api/pam/types/index.tsindex 24e085decf..fb251a9a42 100644--- a/frontend/src/hooks/api/pam/types/index.ts+++ b/frontend/src/hooks/api/pam/types/index.ts@@ -34,6 +34,12 @@ export type TPamFieldDescriptor = {showWhen?: { field: string; equals: string | boolean };};+export type TPamPolicyDescriptor = {+ key: string;+ label: string;+ description: string;+};+export type TPamAccountTypeMetadata = {type: PamAccountType;name: string;@@ -41,6 +47,7 @@ export type TPamAccountTypeMetadata = {supportsWebAccess: boolean;connectionFields: TPamFieldDescriptor[];credentialFields: TPamFieldDescriptor[];+ applicablePolicies: TPamPolicyDescriptor[];};// New model types@@ -62,7 +69,7 @@ export type TPamAccount = {folderName: string | null;templateId: string;templateName: string;- templateAccessPolicy: unknown;+ templatePolicies: unknown;templateSettings: unknown;accountType: PamAccountType;gatewayId: string | null;@@ -91,7 +98,7 @@ export type TPamAccountTemplate = {name: string;description?: string | null;type: PamAccountType;- accessPolicy: unknown;+ policies: unknown;settings: unknown;gatewayId?: string | null;gatewayPoolId?: string | null;@@ -267,7 +274,7 @@ export type TCreatePamAccountTemplateDTO = {name: string;description?: string;type: PamAccountType;- accessPolicy?: Record<string, unknown>;+ policies?: Record<string, unknown>;settings?: Record<string, unknown>;};@@ -275,7 +282,7 @@ export type TUpdatePamAccountTemplateDTO = {templateId: string;name?: string;description?: string | null;- accessPolicy?: Record<string, unknown>;+ policies?: Record<string, unknown>;settings?: Record<string, unknown>;gatewayId?: string | null;gatewayPoolId?: string | null;diff --git a/frontend/src/pages/pam/PamAccountAccessPage/ReasonGate.tsx b/frontend/src/pages/pam/PamAccountAccessPage/ReasonGate.tsxindex c67af323a7..686b8ae4c0 100644--- a/frontend/src/pages/pam/PamAccountAccessPage/ReasonGate.tsx+++ b/frontend/src/pages/pam/PamAccountAccessPage/ReasonGate.tsx@@ -9,7 +9,7 @@ import {CardTitle,TextArea} from "@app/components/v3";-import { TPamAccount } from "@app/hooks/api/pam";+import { PamPolicyType, TPamAccount } from "@app/hooks/api/pam";type TAccessPolicy = {requireReason: boolean;@@ -17,15 +17,14 @@ type TAccessPolicy = {requireMfa: boolean;};-const DEFAULT_ACCESS_POLICY: TAccessPolicy = {- requireReason: false,- maxSessionDurationSeconds: 3600,- requireMfa: false-};-export const resolveAccessPolicy = (account: TPamAccount): TAccessPolicy => {- const templatePolicy = account.templateAccessPolicy as Partial<TAccessPolicy> | null;- return { ...DEFAULT_ACCESS_POLICY, ...templatePolicy };+ const policies = (account.templatePolicies ?? {}) as Record<string, unknown>;+ const duration = policies[PamPolicyType.MaxSessionDuration];+ return {+ requireReason: policies[PamPolicyType.RequireReason] === true,+ requireMfa: policies[PamPolicyType.RequireMfa] === true,+ maxSessionDurationSeconds: typeof duration === "number" ? duration : 3600+ };};type TSessionAccessGateResult = {diff --git a/frontend/src/pages/pam/PamTemplatesPage/components/TemplateDetailSheet.tsx b/frontend/src/pages/pam/PamTemplatesPage/components/TemplateDetailSheet.tsxindex 290e551083..c1412dedef 100644--- a/frontend/src/pages/pam/PamTemplatesPage/components/TemplateDetailSheet.tsx+++ b/frontend/src/pages/pam/PamTemplatesPage/components/TemplateDetailSheet.tsx@@ -16,10 +16,8 @@ import {FieldDescription,FieldError,FieldLabel,- FieldTitle,GatewayPicker,Input,- Switch,TextArea} from "@app/components/v3";import { Skeleton } from "@app/components/v3/generic/Skeleton";@@ -34,6 +32,7 @@ import { PamSheetTab, usePamSheetState } from "@app/hooks/usePamSheetState";import { formatDetailDate, PamDetailSheet } from "../../components/PamDetailSheet";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";@@ -46,18 +45,10 @@ const configSchema = z.object({type ConfigForm = z.infer<typeof configSchema>;const settingsSchema = z.object({- requireReason: z.boolean(),- requireMfa: z.boolean(),- maxSessionDurationSeconds: z- .number({ invalid_type_error: "Must be a number" })- .int()- .min(60, "Minimum 60 seconds")- .max(86400, "Maximum 24 hours")- .optional()- .nullable(),gatewayId: z.string().nullable(),gatewayPoolId: z.string().nullable(),- recordingConnectionId: z.string().nullable()+ recordingConnectionId: z.string().nullable(),+ policies: z.record(z.unknown())});type SettingsForm = z.infer<typeof settingsSchema>;@@ -174,25 +165,23 @@ const SettingsTab = ({const updateTemplate = useUpdatePamAccountTemplate();const {- register,- control,handleSubmit,reset,setValue,watch,- formState: { errors, isDirty }+ formState: { isDirty }} = useForm<SettingsForm>({resolver: zodResolver(settingsSchema),defaultValues: {- requireReason: false,- requireMfa: false,- maxSessionDurationSeconds: null,gatewayId: null,gatewayPoolId: null,- recordingConnectionId: null+ recordingConnectionId: null,+ policies: {}}});+ const { map: accountTypeMap } = usePamAccountTypeMap();+useEffect(() => {onDirtyChange?.(isDirty);return () => onDirtyChange?.(false);@@ -200,17 +189,11 @@ const SettingsTab = ({useEffect(() => {if (template) {- const policy = (template.accessPolicy ?? {}) as Record<string, unknown>;reset({- requireReason: Boolean(policy.requireReason),- requireMfa: Boolean(policy.requireMfa),- maxSessionDurationSeconds:- typeof policy.maxSessionDurationSeconds === "number"- ? policy.maxSessionDurationSeconds- : null,gatewayId: template.gatewayId ?? null,gatewayPoolId: template.gatewayPoolId ?? null,- recordingConnectionId: template.recordingConnectionId ?? null+ recordingConnectionId: template.recordingConnectionId ?? null,+ policies: (template.policies as Record<string, unknown>) ?? {}});}}, [template, reset]);@@ -230,17 +213,17 @@ const SettingsTab = ({const gatewayId = watch("gatewayId");const gatewayPoolId = watch("gatewayPoolId");const recordingConnectionId = watch("recordingConnectionId");+ const policies = watch("policies");const showRecording = accountTypeRequiresRecording(template.type);+ const applicablePolicies = (accountTypeMap[template.type]?.applicablePolicies ?? []).filter(+ (p) => POLICY_EDITORS[p.key]+ );const onSubmit = (data: SettingsForm) => {updateTemplate.mutate({templateId,- accessPolicy: {- requireReason: data.requireReason,- requireMfa: data.requireMfa,- maxSessionDurationSeconds: data.maxSessionDurationSeconds ?? undefined- },+ policies: data.policies,gatewayId: data.gatewayId,gatewayPoolId: data.gatewayPoolId,...(showRecording ? { recordingConnectionId: data.recordingConnectionId } : {})@@ -253,65 +236,36 @@ const SettingsTab = ({return (<form onSubmit={handleSubmit(onSubmit)} className="flex flex-1 flex-col gap-4 p-4">- <Card>- <CardHeader className="border-b">- <CardTitle className="text-base">Access Policy</CardTitle>- <CardDescription>- Governance rules applied to all accounts using this template.- </CardDescription>- </CardHeader>- <CardContent className="flex flex-col gap-6">- <Field>- <FieldLabel>Max session duration (seconds)</FieldLabel>- <FieldContent>- <Input- type="number"- placeholder="e.g. 3600"- isError={!!errors.maxSessionDurationSeconds}- {...register("maxSessionDurationSeconds", {- setValueAs: (v: string) => {- if (v === "" || v === null || v === undefined) return null;- const n = Number(v);- return Number.isNaN(n) ? null : n;- }- })}- />- <FieldDescription>Between 60 and 86400. Leave empty for no limit.</FieldDescription>- <FieldError>{errors.maxSessionDurationSeconds?.message}</FieldError>- </FieldContent>- </Field>-- <Field orientation="horizontal" className="items-center!">- <FieldContent>- <FieldTitle>Require reason</FieldTitle>- <FieldDescription>Users must provide a reason before accessing.</FieldDescription>- </FieldContent>- <Controller- name="requireReason"- control={control}- render={({ field }) => (- <Switch checked={field.value} variant="pam" onCheckedChange={field.onChange} />- )}- />- </Field>-- <Field orientation="horizontal" className="items-center!">- <FieldContent>- <FieldTitle>Require MFA</FieldTitle>- <FieldDescription>- Users must re-authenticate with MFA before accessing.- </FieldDescription>- </FieldContent>- <Controller- name="requireMfa"- control={control}- render={({ field }) => (- <Switch checked={field.value} variant="pam" onCheckedChange={field.onChange} />- )}- />- </Field>- </CardContent>- </Card>+ {applicablePolicies.length > 0 && (+ <Card>+ <CardHeader className="border-b">+ <CardTitle className="text-base">Policies</CardTitle>+ <CardDescription>+ Policies available for {accountTypeMap[template.type]?.name ?? template.type} accounts+ using this template.+ </CardDescription>+ </CardHeader>+ <CardContent className="flex flex-col gap-6">+ {applicablePolicies.map((p) => {+ const Editor = POLICY_EDITORS[p.key]!;+ return (+ <Editor+ key={p.key}+ label={p.label}+ description={p.description}+ value={policies[p.key]}+ onChange={(value) => {+ const next = { ...policies };+ if (value === null || value === undefined) delete next[p.key];+ else next[p.key] = value;+ setValue("policies", next, { shouldDirty: true });+ }}+ />+ );+ })}+ </CardContent>+ </Card>+ )}<Card><CardHeader className="border-b">diff --git a/frontend/src/pages/pam/components/policyEditors/BooleanPolicyEditor.tsx b/frontend/src/pages/pam/components/policyEditors/BooleanPolicyEditor.tsxnew file mode 100644index 0000000000..56e1ee03a5--- /dev/null+++ b/frontend/src/pages/pam/components/policyEditors/BooleanPolicyEditor.tsx@@ -0,0 +1,17 @@+import { Field, FieldContent, FieldDescription, FieldTitle, Switch } from "@app/components/v3";++import { PolicyEditorProps } from "./types";++export const BooleanPolicyEditor = ({ label, description, value, onChange }: PolicyEditorProps) => (+ <Field orientation="horizontal" className="items-center!">+ <FieldContent>+ <FieldTitle>{label}</FieldTitle>+ <FieldDescription>{description}</FieldDescription>+ </FieldContent>+ <Switch+ checked={value === true}+ variant="pam"+ onCheckedChange={(checked) => onChange(checked)}+ />+ </Field>+);diff --git a/frontend/src/pages/pam/components/policyEditors/DurationPolicyEditor.tsx b/frontend/src/pages/pam/components/policyEditors/DurationPolicyEditor.tsxnew file mode 100644index 0000000000..a0d093f61c--- /dev/null+++ b/frontend/src/pages/pam/components/policyEditors/DurationPolicyEditor.tsx@@ -0,0 +1,26 @@+import { Field, FieldContent, FieldDescription, FieldLabel, Input } from "@app/components/v3";++import { PolicyEditorProps } from "./types";++export const DurationPolicyEditor = ({+ label,+ description,+ value,+ onChange+}: PolicyEditorProps) => (+ <Field>+ <FieldLabel>{label}</FieldLabel>+ <FieldContent>+ <Input+ type="number"+ placeholder="e.g. 3600 (leave empty for no limit)"+ value={typeof value === "number" ? value : ""}+ onChange={(e) => {+ const v = e.target.value;+ onChange(v === "" ? null : Number(v));+ }}+ />+ <FieldDescription>{description}</FieldDescription>+ </FieldContent>+ </Field>+);diff --git a/frontend/src/pages/pam/components/policyEditors/index.tsx b/frontend/src/pages/pam/components/policyEditors/index.tsxnew file mode 100644index 0000000000..d4ff5efa98--- /dev/null+++ b/frontend/src/pages/pam/components/policyEditors/index.tsx@@ -0,0 +1,15 @@+import { ComponentType } from "react";++import { PamPolicyType } from "@app/hooks/api/pam";++import { BooleanPolicyEditor } from "./BooleanPolicyEditor";+import { DurationPolicyEditor } from "./DurationPolicyEditor";+import { PolicyEditorProps } from "./types";++export const POLICY_EDITORS: Partial<Record<string, ComponentType<PolicyEditorProps>>> = {+ [PamPolicyType.RequireMfa]: BooleanPolicyEditor,+ [PamPolicyType.RequireReason]: BooleanPolicyEditor,+ [PamPolicyType.MaxSessionDuration]: DurationPolicyEditor+};++export type { PolicyEditorProps } from "./types";diff --git a/frontend/src/pages/pam/components/policyEditors/types.ts b/frontend/src/pages/pam/components/policyEditors/types.tsnew file mode 100644index 0000000000..031d3b277a--- /dev/null+++ b/frontend/src/pages/pam/components/policyEditors/types.ts@@ -0,0 +1,6 @@+export type PolicyEditorProps = {+ label: string;+ description: string;+ value: unknown;+ onChange: (value: unknown) => void;+};