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
Merge branch 'main' into PAM-164
x032205169661e94b1d
diff --cc backend/src/@types/fastify.d.tsindex 02fa5e3e36,5d47ec9c5f..5416da6942--- a/backend/src/@types/fastify.d.ts+++ b/backend/src/@types/fastify.d.ts@@@ -29,8 -31,8 +31,9 @@@ import { TLdapConfigServiceFactory } frimport { TLicenseServiceFactory } from "@app/ee/services/license/license-service";import { TOidcConfigServiceFactory } from "@app/ee/services/oidc/oidc-config-service";import { TPamAccountServiceFactory } from "@app/ee/services/pam-account/pam-account-service";+ import { TPamAccountPolicyServiceFactory } from "@app/ee/services/pam-account-policy/pam-account-policy-service";import { TPamDiscoverySourceServiceFactory } from "@app/ee/services/pam-discovery/pam-discovery-source-service";+import { TPamDomainServiceFactory } from "@app/ee/services/pam-domain/pam-domain-service";import { TPamFolderServiceFactory } from "@app/ee/services/pam-folder/pam-folder-service";import { TPamResourceRotationRulesServiceFactory } from "@app/ee/services/pam-resource/pam-resource-rotation-rules-service";import { TPamResourceServiceFactory } from "@app/ee/services/pam-resource/pam-resource-service";@@@ -381,9 -384,9 +385,10 @@@ declare module "fastify"offlineUsageReport: TOfflineUsageReportServiceFactory;pamFolder: TPamFolderServiceFactory;pamResource: TPamResourceServiceFactory;+ pamDomain: TPamDomainServiceFactory;pamResourceRotationRules: TPamResourceRotationRulesServiceFactory;pamAccount: TPamAccountServiceFactory;+ pamAccountPolicy: TPamAccountPolicyServiceFactory;pamSession: TPamSessionServiceFactory;pamWebAccess: TPamWebAccessServiceFactory;pamDiscoverySource: TPamDiscoverySourceServiceFactory;diff --cc backend/src/@types/knex.d.tsindex 5027da9c3d,44508037c2..64d5fd93f2--- a/backend/src/@types/knex.d.ts+++ b/backend/src/@types/knex.d.ts@@@ -1596,8 -1621,12 +1622,13 @@@ declare module "knex/types/tables"TPamResourceFavoritesInsert,TPamResourceFavoritesUpdate>;+ [TableName.PamDomain]: KnexOriginal.CompositeTableType<TPamDomains, TPamDomainsInsert, TPamDomainsUpdate>;[TableName.PamAccount]: KnexOriginal.CompositeTableType<TPamAccounts, TPamAccountsInsert, TPamAccountsUpdate>;+ [TableName.PamAccountPolicy]: KnexOriginal.CompositeTableType<+ TPamAccountPolicies,+ TPamAccountPoliciesInsert,+ TPamAccountPoliciesUpdate+ >;[TableName.PamSession]: KnexOriginal.CompositeTableType<TPamSessions, TPamSessionsInsert, TPamSessionsUpdate>;[TableName.PamSessionEventBatch]: KnexOriginal.CompositeTableType<TPamSessionEventBatches,diff --cc backend/src/db/schemas/models.tsindex 92d40ac1d2,b3615c22d3..61d4515394--- a/backend/src/db/schemas/models.ts+++ b/backend/src/db/schemas/models.ts@@@ -236,7 -239,7 +239,8 @@@ export enum TableNamePamAccountDependency = "pam_account_dependencies",PamResourceRotationRule = "pam_resource_rotation_rules",PamResourceFavorite = "pam_resource_favorites",+ PamDomain = "pam_domains",+ PamAccountPolicy = "pam_account_policies",VaultExternalMigrationConfig = "vault_external_migration_configs",diff --cc backend/src/db/schemas/pam-accounts.tsindex 4c2e8ce690,b84f31743b..a88164041e--- a/backend/src/db/schemas/pam-accounts.ts+++ b/backend/src/db/schemas/pam-accounts.ts@@@ -25,7 -25,7 +25,8 @@@ export const PamAccountsSchema = z.objerequireMfa: z.boolean().default(false).nullable().optional(),internalMetadata: z.unknown().nullable().optional(),discoveryFingerprint: z.string().nullable().optional(),- domainId: z.string().uuid().nullable().optional()++ domainId: z.string().uuid().nullable().optional(),+ policyId: z.string().uuid().nullable().optional()});export type TPamAccounts = z.infer<typeof PamAccountsSchema>;diff --cc backend/src/db/schemas/pam-resources.tsindex 7ca08df545,78a7c16027..0e03fcc83f--- a/backend/src/db/schemas/pam-resources.ts+++ b/backend/src/db/schemas/pam-resources.ts@@@ -20,8 -20,9 +20,9 @@@ export const PamResourcesSchema = z.objupdatedAt: z.date(),encryptedRotationAccountCredentials: zodBuffer.nullable().optional(),encryptedResourceMetadata: zodBuffer.nullable().optional(),- adServerResourceId: z.string().uuid().nullable().optional(),discoveryFingerprint: z.string().nullable().optional(),- domainId: z.string().uuid().nullable().optional()++ domainId: z.string().uuid().nullable().optional(),+ encryptedSessionSummaryConfig: zodBuffer.nullable().optional()});export type TPamResources = z.infer<typeof PamResourcesSchema>;diff --cc backend/src/ee/routes/v1/index.tsindex 3349f6e78f,46882a1ac7..683af44219--- a/backend/src/ee/routes/v1/index.ts+++ b/backend/src/ee/routes/v1/index.ts@@@ -207,19 -208,7 +213,20 @@@ export const registerV1EERoutes = asynasync (pamRouter) => {await pamRouter.register(registerPamFolderRouter, { prefix: "/folders" });await pamRouter.register(registerPamSessionRouter, { prefix: "/sessions" });+ await pamRouter.register(registerPamAccountPolicyRouter, { prefix: "/account-policies" });+ await pamRouter.register(+ async (pamDomainRouter) => {+ await pamDomainRouter.register(registerPamDomainRouter);++ // Domain-type-specific endpoints+ await Promise.all(+ Object.entries(PAM_DOMAIN_REGISTER_ROUTER_MAP).map(([provider, router]) =>+ pamDomainRouter.register(router, { prefix: `/${provider}` })+ )+ );+ },+ { prefix: "/domains" }+ );await pamRouter.register(async (pamDiscoveryRouter) => {await pamDiscoveryRouter.register(registerPamDiscoveryRouter);diff --cc backend/src/ee/services/audit-log/audit-log-types.tsindex 2cf44f746b,41d5206eb2..523b03ab13--- a/backend/src/ee/services/audit-log/audit-log-types.ts+++ b/backend/src/ee/services/audit-log/audit-log-types.ts@@@ -1,5 -1,5 +1,6 @@@import { ProjectType } from "@app/db/schemas";+import { PamParentType } from "@app/ee/services/pam-account/pam-account-enums";+ import { ScepChallengeType } from "@app/ee/services/pki-scep/challenge";import {TCreateProjectTemplateDTO,TUpdateProjectTemplateDTOdiff --cc backend/src/ee/services/pam-account/pam-account-dal.tsindex 03b5fe3ec0,71c11d7cec..4a43ca4785--- a/backend/src/ee/services/pam-account/pam-account-dal.ts+++ b/backend/src/ee/services/pam-account/pam-account-dal.ts@@@ -47,7 -45,7 +47,8 @@@ export const pamAccountDALFactory = (dbconst dbInstance = tx || db.replicaNode();const query = dbInstance(TableName.PamAccount).leftJoin(TableName.PamResource, `${TableName.PamAccount}.resourceId`, `${TableName.PamResource}.id`)+ .leftJoin(TableName.PamDomain, `${TableName.PamAccount}.domainId`, `${TableName.PamDomain}.id`)+ .leftJoin(TableName.PamAccountPolicy, `${TableName.PamAccount}.policyId`, `${TableName.PamAccountPolicy}.id`).where(`${TableName.PamAccount}.projectId`, projectId);if (accountView === PamAccountView.Nested) {@@@ -96,16 -82,12 +97,18 @@@const countQuery = query.clone().count("*", { as: "count" }).first();void query.select(selectAllTableCols(TableName.PamAccount)).select(- // resource+ // resource (may be null for domain accounts)db.ref("name").withSchema(TableName.PamResource).as("resourceName"),db.ref("resourceType").withSchema(TableName.PamResource),- db.ref("encryptedRotationAccountCredentials").withSchema(TableName.PamResource),+ db+ .ref("encryptedRotationAccountCredentials")+ .withSchema(TableName.PamResource)+ .as("resourceEncryptedRotationAccountCredentials"),+ // domain (may be null for resource accounts)+ db.ref("name").withSchema(TableName.PamDomain).as("domainName"),- db.ref("domainType").withSchema(TableName.PamDomain)++ db.ref("domainType").withSchema(TableName.PamDomain),+ // policy+ db.ref("name").withSchema(TableName.PamAccountPolicy).as("policyName"));const direction = orderDirection === OrderByDirection.ASC ? "ASC" : "DESC";@@@ -119,36 -101,23 +122,37 @@@const [results, countResult] = await Promise.all([query, countQuery]);const totalCount = Number(countResult?.count || 0);- const accounts = results.map(- // @ts-expect-error resourceName, resourceType, encryptedRotationAccountCredentials, policyName are from joined tables- ({ resourceId, resourceName, resourceType, encryptedRotationAccountCredentials, policyName, ...account }) => ({- ...account,- resourceId,- policyName: (policyName as string) || null,- resource: {- id: resourceId,- name: resourceName as string,- resourceType,- encryptedRotationAccountCredentials- }- })- );+ const accounts = results.map((row) => {+ const r = row as Record<string, unknown>;+ const rId = row.resourceId as string | null;+ const dId = row.domainId as string | null;++ return {+ ...row,+ resourceId: rId,+ domainId: dId,++ policyName: (r.policyName as string) || null,+ resource: rId+ ? {+ id: rId,+ name: r.resourceName as string,+ resourceType: r.resourceType as string,+ encryptedRotationAccountCredentials: r.resourceEncryptedRotationAccountCredentials as Buffer | null+ }+ : null,+ domain: dId+ ? {+ id: dId,+ name: r.domainName as string,+ domainType: r.domainType as string+ }+ : null+ };+ });+return { accounts, totalCount };} catch (error) {- throw new DatabaseError({ error, name: "Find PAM accounts with resource details" });+ throw new DatabaseError({ error, name: "Find PAM accounts with parent details" });}};@@@ -157,58 -126,41 +161,71 @@@const dbInstance = tx || db.replicaNode();const result = await dbInstance(TableName.PamAccount).leftJoin(TableName.PamResource, `${TableName.PamAccount}.resourceId`, `${TableName.PamResource}.id`)+ .leftJoin(TableName.PamDomain, `${TableName.PamAccount}.domainId`, `${TableName.PamDomain}.id`)+ .leftJoin(TableName.PamAccountPolicy, `${TableName.PamAccount}.policyId`, `${TableName.PamAccountPolicy}.id`).where(`${TableName.PamAccount}.id`, accountId).select(selectAllTableCols(TableName.PamAccount)).select(+ // resource (may be null for domain accounts)db.ref("name").withSchema(TableName.PamResource).as("resourceName"),db.ref("resourceType").withSchema(TableName.PamResource),- db.ref("encryptedRotationAccountCredentials").withSchema(TableName.PamResource),+ db+ .ref("encryptedRotationAccountCredentials")+ .withSchema(TableName.PamResource)+ .as("resourceEncryptedRotationAccountCredentials"),+ // domain (may be null for resource accounts)+ db.ref("name").withSchema(TableName.PamDomain).as("domainName"),- db.ref("domainType").withSchema(TableName.PamDomain)++ db.ref("domainType").withSchema(TableName.PamDomain),+ db.ref("name").withSchema(TableName.PamAccountPolicy).as("policyName")).first();if (!result) return null;- const { resourceId, resourceName, resourceType, encryptedRotationAccountCredentials, policyName, ...account } =- result as {- resourceId: string;- resourceName: string;- resourceType: string;- encryptedRotationAccountCredentials: Buffer | null;- policyName: string | null;- } & typeof result;+ const {+ resourceId,+ domainId,+ resourceName,+ resourceType,+ resourceEncryptedRotationAccountCredentials,+ domainName,+ domainType,++ policyName,+ ...account- } = result;++ } = result as {++ resourceId: string | null;++ domainId: string | null;++ resourceName: string | null;++ resourceType: string | null;++ resourceEncryptedRotationAccountCredentials: Buffer | null;++ domainName: string | null;++ domainType: string | null;++ policyName: string | null;++ } & typeof result;return {...account,resourceId,+ domainId,+ policyName: policyName || null,- resource: {- id: resourceId,- name: resourceName,- resourceType,- encryptedRotationAccountCredentials- }+ resource: resourceId+ ? {+ id: resourceId,+ name: resourceName,+ resourceType,+ encryptedRotationAccountCredentials: resourceEncryptedRotationAccountCredentials+ }+ : null,+ domain: domainId+ ? {+ id: domainId,+ name: domainName,+ domainType+ }+ : null};} catch (error) {- throw new DatabaseError({ error, name: "Find PAM account by ID with resource details" });+ throw new DatabaseError({ error, name: "Find PAM account by ID with parent details" });}};diff --cc backend/src/ee/services/pam-account/pam-account-service.tsindex d2107c023b,cb658ef7a5..5b798267d7--- a/backend/src/ee/services/pam-account/pam-account-service.ts+++ b/backend/src/ee/services/pam-account/pam-account-service.ts@@@ -53,10 -52,11 +53,14 @@@ import { TUserDALFactory } from "@app/simport { EventType, TAuditLogServiceFactory } from "../audit-log/audit-log-types";import { TGatewayV2ServiceFactory } from "../gateway-v2/gateway-v2-service";+ import { PAM_ACCOUNT_POLICY_RULE_SUPPORTED_RESOURCES } from "../pam-account-policy/pam-account-policy-constants";+ import { TPamAccountPolicyDALFactory } from "../pam-account-policy/pam-account-policy-dal";+ import { PamAccountPolicyRuleType } from "../pam-account-policy/pam-account-policy-enums";+ import { TPolicyRules } from "../pam-account-policy/pam-account-policy-types";import { TPamAccountDependenciesDALFactory } from "../pam-discovery/pam-account-dependencies-dal";+import { TPamDomainDALFactory } from "../pam-domain/pam-domain-dal";+import { PamDomainType } from "../pam-domain/pam-domain-enums";+import { PAM_DOMAIN_FACTORY_MAP } from "../pam-domain/pam-domain-factory";import { TPamResourceDALFactory } from "../pam-resource/pam-resource-dal";import { PamResource } from "../pam-resource/pam-resource-enums";import { TPamResourceRotationRulesDALFactory } from "../pam-resource/pam-resource-rotation-rules-dal";@@@ -86,9 -86,9 +90,10 @@@ importtype TPamAccountServiceFactoryDep = {pamResourceDAL: TPamResourceDALFactory;+ pamDomainDAL: TPamDomainDALFactory;pamSessionDAL: TPamSessionDALFactory;pamAccountDAL: TPamAccountDALFactory;+ pamAccountPolicyDAL: Pick<TPamAccountPolicyDALFactory, "findById">;pamResourceRotationRulesDAL: Pick<TPamResourceRotationRulesDALFactory, "findByResourceIds">;mfaSessionService: TMfaSessionServiceFactory;projectDAL: TProjectDALFactory;@@@ -119,9 -119,9 +124,10 @@@ const ROTATION_CONCURRENCY_LIMIT = 10export const pamAccountServiceFactory = ({pamResourceDAL,+ pamDomainDAL,pamSessionDAL,pamAccountDAL,+ pamAccountPolicyDAL,pamResourceRotationRulesDAL,mfaSessionService,projectDAL,@@@ -257,6 -204,13 +264,13 @@@kmsService});+ if (policyId) {+ const policy = await pamAccountPolicyDAL.findById(policyId);- if (!policy || policy.projectId !== resource.projectId) {++ if (!policy || policy.projectId !== parent.projectId) {+ throw new NotFoundError({ message: "Policy not found" });+ }+ }+try {const { account, insertedMetadata } = await pamAccountDAL.transaction(async (tx) => {const newAccount = await pamAccountDAL.create(@@@ -385,43 -330,40 +400,53 @@@updateDoc.internalMetadata = internalMetadata;}+ if (policyId !== undefined) {+ if (policyId) {+ const policy = await pamAccountPolicyDAL.findById(policyId);+ if (!policy || policy.projectId !== account.projectId) {+ throw new NotFoundError({ message: "Policy not found" });+ }+ }+ updateDoc.policyId = policyId;+ }+if (credentials !== undefined) {- const connectionDetails = await decryptResourceConnectionDetails({- projectId: account.projectId,- encryptedConnectionDetails: resource.encryptedConnectionDetails,- kmsService- });-- // Decrypt resource metadata if available- const resourceInternalMetadata = resource.encryptedResourceMetadata- ? await decryptResourceMetadata({- encryptedMetadata: resource.encryptedResourceMetadata,- projectId: account.projectId,- kmsService- })- : undefined;-- const factory = PAM_RESOURCE_FACTORY_MAP[resource.resourceType as PamResource](- resource.resourceType as PamResource,- connectionDetails,- resource.gatewayId,- gatewayV2Service,- account.projectId,- resourceInternalMetadata- );+ let factory;+ if (parent.isResource) {+ const connectionDetails = await decryptResourceConnectionDetails({+ projectId: account.projectId,+ encryptedConnectionDetails: parent.encryptedConnectionDetails,+ kmsService+ });+ const resourceInternalMetadata = parent.encryptedResourceMetadata+ ? await decryptResourceMetadata({+ encryptedMetadata: parent.encryptedResourceMetadata,+ projectId: account.projectId,+ kmsService+ })+ : undefined;+ factory = PAM_RESOURCE_FACTORY_MAP[parent.resourceType as PamResource](+ parent.resourceType as PamResource,+ connectionDetails,+ parent.gatewayId,+ gatewayV2Service,+ account.projectId,+ resourceInternalMetadata+ );+ } else {+ const connectionDetails = await decryptDomainConnectionDetails({+ projectId: account.projectId,+ encryptedConnectionDetails: parent.encryptedConnectionDetails,+ kmsService+ });+ factory = PAM_DOMAIN_FACTORY_MAP[parent.domainType as PamDomainType](+ parent.domainType as PamDomainType,+ connectionDetails,+ parent.gatewayId,+ gatewayV2Service,+ account.projectId+ );+ }const decryptedCredentials = await decryptAccountCredentials({encryptedCredentials: account.encryptedCredentials,@@@ -1126,13 -1022,17 +1159,17 @@@const account = await pamAccountDAL.findById(session.accountId);if (!account) throw new NotFoundError({ message: `Account with ID '${session.accountId}' not found` });- const resource = await pamResourceDAL.findById(account.resourceId);+ const resource = await pamResourceDAL.findById(account.resourceId!);if (!resource) throw new NotFoundError({ message: `Resource with ID '${account.resourceId}' not found` });- if (resource.gatewayId && resource.gatewayIdentityId !== actor.id) {- throw new ForbiddenRequestError({- message: "Identity does not have access to fetch the PAM session credentials"- });+ if (resource.gatewayId) {+ const authorized =+ actor.type === ActorType.GATEWAY ? resource.gatewayId === actor.id : resource.gatewayIdentityId === actor.id;+ if (!authorized) {+ throw new ForbiddenRequestError({+ message: "Gateway does not have access to fetch the PAM session credentials"+ });+ }}const decryptedAccount = await decryptAccount(account, session.projectId, kmsService);diff --cc backend/src/ee/services/pam-account/pam-account-types.tsindex 94e82c1f83,7ef9273614..1d8e34d1ed--- a/backend/src/ee/services/pam-account/pam-account-types.ts+++ b/backend/src/ee/services/pam-account/pam-account-types.ts@@@ -9,12 -9,11 +9,13 @@@ import { PamAccountOrderBy, PamAccountV// DTOsexport type TCreateAccountDTO = Pick<TPamAccount,- "name" | "description" | "credentials" | "folderId" | "resourceId" | "requireMfa"+ "name" | "description" | "credentials" | "folderId" | "requireMfa"> & {+ resourceId?: string;+ domainId?: string;internalMetadata?: Record<string, unknown>;metadata?: z.input<typeof ResourceMetadataNonEncryptionSchema>;+ policyId?: string | null;};export type TUpdateAccountDTO = Partial<Omit<TCreateAccountDTO, "folderId" | "resourceId">> & {diff --cc backend/src/ee/services/pam-discovery/pam-discovery-schemas.tsindex ce8a9cc98c,a814f76b9b..541b6609a3--- a/backend/src/ee/services/pam-discovery/pam-discovery-schemas.ts+++ b/backend/src/ee/services/pam-discovery/pam-discovery-schemas.ts@@@ -8,13 -8,12 +8,13 @@@ import} from "@app/db/schemas";import { slugSchema } from "@app/server/lib/schemas";-import { ActiveDirectoryAccountMetadataSchema } from "../pam-resource/active-directory/active-directory-resource-schemas";+import { ActiveDirectoryAccountMetadataSchema } from "../pam-domain/active-directory/active-directory-domain-schemas";+import { PamDomainType } from "../pam-domain/pam-domain-enums";import { PamResource } from "../pam-resource/pam-resource-enums";- import { SSHResourceInternalMetadataSchema } from "../pam-resource/ssh/ssh-resource-schemas";+ import { SanitizedSSHResourceInternalMetadataSchema } from "../pam-resource/ssh/ssh-resource-schemas";import {- WindowsAccountMetadataSchema,- WindowsResourceInternalMetadataSchema+ SanitizedWindowsResourceInternalMetadataSchema,+ WindowsAccountMetadataSchema} from "../pam-resource/windows-server/windows-server-resource-schemas";import {PamDiscoverySchedule,diff --cc backend/src/ee/services/pam-resource/pam-resource-fns.tsindex 93c0bdce9b,1402523737..72256ac623--- a/backend/src/ee/services/pam-resource/pam-resource-fns.ts+++ b/backend/src/ee/services/pam-resource/pam-resource-fns.ts@@@ -119,13 -122,33 +120,39 @@@ export const decryptResource = asyncprojectId: string,kmsService: Pick<TKmsServiceFactory, "createCipherPairWithDataKey">) => {- const { encryptedConnectionDetails, encryptedRotationAccountCredentials, encryptedResourceMetadata, ...rest } =- resource;- let sessionSummaryConfig: { aiInsightsEnabled: boolean; connectionId: string; model: string } | null = null;++ const {++ encryptedConnectionDetails,++ encryptedRotationAccountCredentials,++ encryptedResourceMetadata,++ encryptedSessionSummaryConfig,++ ...rest++ } = resource;+- const { encryptedSessionSummaryConfig } = resource;++ let sessionSummaryConfig: { aiInsightsEnabled: boolean; connectionId: string; model: string } | null = null;++ if (encryptedSessionSummaryConfig) {+ try {+ const { decryptor } = await kmsService.createCipherPairWithDataKey({+ type: KmsDataKey.SecretManager,+ projectId+ });+ sessionSummaryConfig = JSON.parse(decryptor({ cipherTextBlob: encryptedSessionSummaryConfig }).toString()) as {+ aiInsightsEnabled: boolean;+ connectionId: string;+ model: string;+ };+ } catch (err) {+ logger.warn(+ { err, resourceId: resource.id },+ "decryptResource: failed to decrypt sessionSummaryConfig, falling back to null"+ );+ }+ }return {- ...resource,+ ...rest,connectionDetails: await decryptResourceConnectionDetails({- encryptedConnectionDetails: resource.encryptedConnectionDetails,+ encryptedConnectionDetails,projectId,kmsService}),diff --cc backend/src/ee/services/pam-resource/pam-resource-schemas.tsindex 83c7dc689e,f41d0b7599..46eeca5366--- a/backend/src/ee/services/pam-resource/pam-resource-schemas.ts+++ b/backend/src/ee/services/pam-resource/pam-resource-schemas.ts@@@ -22,10 -36,11 +38,12 @@@ export const SessionSummaryConfigSchemexport const BasePamResourceSchema = PamResourcesSchema.omit({encryptedConnectionDetails: true,encryptedRotationAccountCredentials: true,+ encryptedResourceMetadata: true,+ encryptedSessionSummaryConfig: true,resourceType: true}).extend({- metadata: ResourceMetadataSchema.pick({ id: true, key: true, value: true }).array().optional()+ metadata: ResourceMetadataSchema.pick({ id: true, key: true, value: true }).array().optional(),+ sessionSummaryConfig: SessionSummaryConfigSchema});const CoreCreatePamResourceSchema = z.object({@@@ -64,13 -79,10 +83,14 @@@ export const BasePamAccountSchemaWithReid: true,name: true,resourceType: true- }).extend({- rotationCredentialsConfigured: z.boolean()- }),+ })+ .extend({+ rotationCredentialsConfigured: z.boolean()+ })+ .nullable()+ .optional(),+ domain: PamDomainsSchema.pick({ id: true, name: true, domainType: true }).nullable().optional(),+ policyName: z.string().nullable().optional(),lastRotationMessage: z.string().nullable().optional(),rotationStatus: z.string().nullable().optional()});diff --cc backend/src/ee/services/pam-resource/pam-resource-service.tsindex f0220dde51,ed040baf2c..9364faa6dd--- a/backend/src/ee/services/pam-resource/pam-resource-service.ts+++ b/backend/src/ee/services/pam-resource/pam-resource-service.ts@@@ -34,7 -39,14 +39,13 @@@ import} from "./pam-resource-fns";import { TCreateResourceDTO, TListResourcesDTO, TUpdateResourceDTO } from "./pam-resource-types";import { TSSHResourceInternalMetadata } from "./ssh/ssh-resource-types";-import { TWindowsResource } from "./windows-server/windows-server-resource-types";+ // Extend this set as more LLM providers are added (e.g. AppConnection.OpenAI)+ const LLM_APP_CONNECTIONS = new Set<AppConnection>([AppConnection.Anthropic]);++ // Resource types that have AI session summary prompts defined in pam-session-summary-fns.ts+ const AI_SUMMARY_SUPPORTED_RESOURCE_TYPES = new Set<PamResource>([PamResource.Postgres, PamResource.SSH]);+type TPamResourceServiceFactoryDep = {pamResourceDAL: TPamResourceDALFactory;pamResourceFavoriteDAL: TPamResourceFavoriteDALFactory;@@@ -240,8 -263,9 +253,9 @@@ export const pamResourceServiceFactoryname,rotationAccountCredentials,gatewayId,- adServerResourceId,+ domainId,- metadata+ metadata,+ sessionSummaryConfig}: TUpdateResourceDTO,actor: OrgServiceActor) => {diff --cc backend/src/ee/services/permission/default-roles.tsindex 605958d3b6,32f09b6f8b..d0004d7a46--- a/backend/src/ee/services/permission/default-roles.ts+++ b/backend/src/ee/services/permission/default-roles.ts@@@ -772,10 -796,10 +799,12 @@@ const buildViewerPermissionRules = () =can([ProjectPermissionActions.Read], ProjectPermissionSub.PamResources);+ can([ProjectPermissionActions.Read], ProjectPermissionSub.PamDomains);+can([ProjectPermissionPamAccountActions.Read], ProjectPermissionSub.PamAccounts);+ can([ProjectPermissionPamAccountPolicyActions.Read], ProjectPermissionSub.PamAccountPolicies);+can([ProjectPermissionPamDiscoveryActions.Read], ProjectPermissionSub.PamDiscovery);can([ProjectPermissionMcpEndpointActions.Read], ProjectPermissionSub.McpEndpoints);diff --cc backend/src/ee/services/permission/project-permission.tsindex c759b612cd,480dc0b56f..e16b338d76--- a/backend/src/ee/services/permission/project-permission.ts+++ b/backend/src/ee/services/permission/project-permission.ts@@@ -345,9 -357,9 +357,10 @@@ export enum ProjectPermissionSubAppConnections = "app-connections",PamFolders = "pam-folders",PamResources = "pam-resources",+ PamDomains = "pam-domains",PamAccounts = "pam-accounts",PamSessions = "pam-sessions",+ PamAccountPolicies = "pam-account-policies",PamDiscovery = "pam-discovery",CertificateProfiles = "certificate-profiles",CertificatePolicies = "certificate-policies",diff --cc backend/src/server/routes/index.tsindex 104934e052,de8a5cf558..5380c864a4--- a/backend/src/server/routes/index.ts+++ b/backend/src/server/routes/index.ts@@@ -2792,9 -2845,9 +2847,10 @@@ export const registerRoutes = async});const pamFolderDAL = pamFolderDALFactory(db);+ const pamDomainDAL = pamDomainDALFactory(db);const pamResourceFavoriteDAL = pamResourceFavoriteDALFactory(db);const pamAccountDAL = pamAccountDALFactory(db);+ const pamAccountPolicyDAL = pamAccountPolicyDALFactory(db);const pamSessionDAL = pamSessionDALFactory(db);const pamSessionEventBatchDAL = pamSessionEventBatchDALFactory(db);const pamDiscoveryRunDAL = pamDiscoveryRunDALFactory(db);@@@ -2823,18 -2876,10 +2879,19 @@@permissionService,kmsService,gatewayV2Service,- resourceMetadataDAL+ resourceMetadataDAL,+ appConnectionDAL});+ const pamDomainService = pamDomainServiceFactory({+ pamDomainDAL,+ pamResourceDAL,+ permissionService,+ kmsService,+ gatewayV2Service,+ resourceMetadataDAL+ });+const pamResourceRotationRulesService = pamResourceRotationRulesServiceFactory({pamResourceRotationRulesDAL,pamResourceDAL,@@@ -2855,7 -2915,7 +2927,8 @@@const pamAccountService = pamAccountServiceFactory({pamAccountDAL,+ pamDomainDAL,+ pamAccountPolicyDAL,pamResourceRotationRulesDAL,gatewayV2Service,kmsService,@@@ -3171,9 -3235,9 +3249,10 @@@notification: notificationService,pamFolder: pamFolderService,pamResource: pamResourceService,+ pamDomain: pamDomainService,pamResourceRotationRules: pamResourceRotationRulesService,pamAccount: pamAccountService,+ pamAccountPolicy: pamAccountPolicyService,pamSession: pamSessionService,pamWebAccess: pamWebAccessService,pamDiscoverySource: pamDiscoverySourceService,diff --cc frontend/src/context/ProjectPermissionContext/types.tsindex 8711e8637b,1ab4d19aad..bb1f7a23c1--- a/frontend/src/context/ProjectPermissionContext/types.ts+++ b/frontend/src/context/ProjectPermissionContext/types.ts@@@ -426,9 -438,9 +438,10 @@@ export enum ProjectPermissionSubAppConnections = "app-connections",PamFolders = "pam-folders",PamResources = "pam-resources",+ PamDomains = "pam-domains",PamAccounts = "pam-accounts",PamSessions = "pam-sessions",+ PamAccountPolicies = "pam-account-policies",PamDiscovery = "pam-discovery",McpEndpoints = "mcp-endpoints",McpServers = "mcp-servers",diff --cc frontend/src/hooks/api/pam/types/base-resource.tsindex fe3c784e08,c6eb0352fc..95fac67553--- a/frontend/src/hooks/api/pam/types/base-resource.ts+++ b/frontend/src/hooks/api/pam/types/base-resource.ts@@@ -3,9 -9,10 +9,10 @@@ export interface TBasePamResourceprojectId: string;name: string;gatewayId: string;- adServerResourceId?: string | null;+ domainId?: string | null;metadata?: { key: string; value: string }[];isFavorite?: boolean;+ sessionSummaryConfig?: TSessionSummaryConfig;createdAt: string;updatedAt: string;}diff --cc frontend/src/hooks/api/pam/types/index.tsindex 2e6f07691c,d226e06e3a..c2518b0174--- a/frontend/src/hooks/api/pam/types/index.ts+++ b/frontend/src/hooks/api/pam/types/index.ts@@@ -7,7 -7,9 +7,8 @@@ importPamSessionStatus,TerminalChannelType} from "../enums";-import { TActiveDirectoryAccount, TActiveDirectoryResource } from "./active-directory-resource";import { TAwsIamAccount, TAwsIamResource } from "./aws-iam-resource";+ import { TSessionSummaryConfig } from "./base-resource";import { TKubernetesAccount, TKubernetesResource } from "./kubernetes-resource";import { TMongoDBAccount, TMongoDBResource } from "./mongodb-resource";import { TMsSQLAccount, TMsSQLResource } from "./mssql-resource";@@@ -144,9 -161,10 +157,10 @@@ export type TUpdatePamResourceDTO = Par> & {resourceId: string;resourceType: PamResourceType;- adServerResourceId?: string | null;+ domainId?: string | null;metadata?: { key: string; value: string }[];rotationAccountCredentials?: { username: string; password: string } | null;+ sessionSummaryConfig?: TSessionSummaryConfig;};export type TDeletePamResourceDTO = {@@@ -172,19 -189,20 +186,21 @@@ export type TCreatePamAccountDTO = PickTPamAccount,"name" | "description" | "credentials" | "projectId" | "resourceId" | "folderId" | "requireMfa"> & {- resourceType: PamResourceType;+ parentType: string;+ domainId?: string;internalMetadata?: Record<string, unknown>;metadata?: { key: string; value: string }[];+ policyId?: string | null;};export type TUpdatePamAccountDTO = Partial<Pick<TPamAccount, "name" | "description" | "credentials" | "requireMfa">> & {accountId: string;- resourceType: PamResourceType;+ parentType: string;internalMetadata?: Record<string, unknown>;metadata?: { key: string; value: string }[];+ policyId?: string | null;};export type TDeletePamAccountDTO = {diff --cc frontend/src/layouts/OrganizationLayout/components/OrgSidebar/PamNav.tsxindex 1019d2b5bb,0b1eebbfbb..2c43ce3110--- a/frontend/src/layouts/OrganizationLayout/components/OrgSidebar/PamNav.tsx+++ b/frontend/src/layouts/OrganizationLayout/components/OrgSidebar/PamNav.tsx@@@ -2,7 -2,7 +2,8 @@@ importBookCheck,Database,FileText,+ Globe,+ ScrollText,Search,Settings,Shield,@@@ -16,9 -16,9 +17,10 @@@ import type { NavItem, Submenu } from "export const PamNav = ({ onSubmenuOpen }: { onSubmenuOpen: (submenu: Submenu) => void }) => {const items: NavItem[] = [{ label: "Resources", icon: Database, pathSuffix: "resources" },- { label: "Sessions", icon: Video, pathSuffix: "sessions" },{ label: "Discovery", icon: Search, pathSuffix: "discovery", activeMatch: /\/discovery\// },+ { label: "Sessions", icon: Video, pathSuffix: "sessions" },+ { label: "Domains", icon: Globe, pathSuffix: "domains" },+ { label: "Account Policies", icon: ScrollText, pathSuffix: "account-policies" },{label: "Approvals",icon: BookCheck,diff --cc frontend/src/pages/pam/PamAccountByIDPage/components/PamAccountDetailsSection.tsxindex fe68cc5531,475d3ed995..6955459540--- a/frontend/src/pages/pam/PamAccountByIDPage/components/PamAccountDetailsSection.tsx+++ b/frontend/src/pages/pam/PamAccountByIDPage/components/PamAccountDetailsSection.tsx@@@ -85,25 -83,27 +85,29 @@@ export const PamAccountDetailsSection<DetailLabel>Description</DetailLabel><DetailValue>{account.description || "-"}</DetailValue></Detail>- <Detail>- <DetailLabel>Type</DetailLabel>- <DetailValue>- <div className="flex items-center gap-2">- <img- alt={resourceTypeInfo.name}- src={`/images/integrations/${resourceTypeInfo.image}`}- className="size-4"- />- {resourceTypeInfo.name} Account- </div>- </DetailValue>- </Detail>+ {resourceTypeInfo && (+ <Detail>+ <DetailLabel>Type</DetailLabel>+ <DetailValue>+ <div className="flex items-center gap-2">+ <img+ alt={resourceTypeInfo.name}+ src={`/images/integrations/${resourceTypeInfo.image}`}+ className="size-4"+ />+ {resourceTypeInfo.name} Account+ </div>+ </DetailValue>+ </Detail>+ )}<Detail><DetailLabel>Parent Resource</DetailLabel>- <DetailValue>{account.resource.name}</DetailValue>+ <DetailValue>{account.resource?.name ?? "—"}</DetailValue></Detail>+ <Detail>+ <DetailLabel>Account Policy</DetailLabel>+ <DetailValue>{account.policyName ?? "None"}</DetailValue>+ </Detail><Detail><DetailLabel>Created</DetailLabel><DetailValue>{format(new Date(account.createdAt), "MM/dd/yyyy, hh:mm a")}</DetailValue>diff --cc frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/ActiveDirectoryAccountForm.tsxindex 04da5834eb,346829eaa7..796f0cb0d0--- a/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/ActiveDirectoryAccountForm.tsx+++ b/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/ActiveDirectoryAccountForm.tsx@@@ -5,13 -5,15 +5,17 @@@ import { z } from "zod"import { FormControl, Input, Select, SelectItem } from "@app/components/v2";import { Button, SheetFooter } from "@app/components/v3";-import { PamResourceType, TActiveDirectoryAccount } from "@app/hooks/api/pam";import { UNCHANGED_PASSWORD_SENTINEL } from "@app/hooks/api/pam/constants";-import { ActiveDirectoryAccountType } from "@app/hooks/api/pam/types/active-directory-resource";+import {+ ActiveDirectoryAccountType,+ TActiveDirectoryAccount+} from "@app/hooks/api/pamDomain/active-directory-types";- import { GenericAccountFields, genericAccountFieldsSchema } from "./GenericAccountFields";+ import {+ AccountPolicyField,+ GenericAccountFields,+ genericAccountFieldsSchema+ } from "./GenericAccountFields";import { MetadataFields } from "./MetadataFields";import { RequireMfaField } from "./RequireMfaField";diff --cc frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/PamAccountForm.tsxindex 192bf5fb86,f84020db20..9d661431de--- a/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/PamAccountForm.tsx+++ b/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/PamAccountForm.tsx@@@ -57,9 -57,10 +58,10 @@@ const CreateForm = (...rest,folderId,resourceId,- resourceType,+ parentType: resourceType,projectId,- internalMetadata+ internalMetadata,+ policyId});createNotification({text: "Successfully created account",@@@ -165,14 -175,16 +167,16 @@@ const UpdateForm = ({ account, closeShe> & {internalMetadata?: Record<string, unknown>;metadata?: { key: string; value: string }[];+ policyId?: string | null;}) => {- const { internalMetadata, ...rest } = formData;+ const { internalMetadata, policyId, ...rest } = formData;const updatedAccount = await updatePamAccount.mutateAsync({accountId: account.id,- resourceType: account.resource.resourceType,+ parentType: account.parentType,...rest,- internalMetadata+ internalMetadata,+ policyId});createNotification({text: "Successfully updated account",diff --cc frontend/src/pages/pam/PamResourceByIDPage/PamResourceByIDPage.tsxindex cdfd97dac1,8749010012..fdfb67f7b5--- a/frontend/src/pages/pam/PamResourceByIDPage/PamResourceByIDPage.tsx+++ b/frontend/src/pages/pam/PamResourceByIDPage/PamResourceByIDPage.tsx@@@ -34,8 -35,11 +35,10 @@@ importPamResourceDependenciesSection,PamResourceDetailsSection,PamResourceMetadataSection,- PamResourceRelatedResourcesSection,PamResourceRotationPolicySection,- PamRotationPolicyModal+ PamResourceSessionRecordingSection,+ PamRotationPolicyModal,+ PamSessionRecordingModal} from "./components";const PageContent = () => {diff --cc frontend/src/pages/pam/PamResourceByIDPage/components/index.tsindex 0abf74ba4a,8498e83e14..bd222b160e--- a/frontend/src/pages/pam/PamResourceByIDPage/components/index.ts+++ b/frontend/src/pages/pam/PamResourceByIDPage/components/index.ts@@@ -3,5 -3,9 +3,8 @@@ export { PamResourceConnectionSectionexport { PamResourceDependenciesSection } from "./PamResourceDependenciesSection";export { PamResourceDetailsSection } from "./PamResourceDetailsSection";export { PamResourceMetadataSection } from "./PamResourceMetadataSection";-export { PamResourceRelatedResourcesSection } from "./PamResourceRelatedResourcesSection";export { PamResourceRotationPolicySection } from "./PamResourceRotationPolicySection";+ export type { SessionRecordingConfig } from "./PamResourceSessionRecordingSection";+ export { PamResourceSessionRecordingSection } from "./PamResourceSessionRecordingSection";export { PamRotationPolicyModal } from "./PamRotationPolicyModal";+ export { PamSessionRecordingModal } from "./PamSessionRecordingModal";diff --cc frontend/src/pages/project/RoleDetailsBySlugPage/components/ProjectRoleModifySection.utils.tsxindex 1fa2e6a625,442cb5f2a9..3c0f09fb6b--- a/frontend/src/pages/project/RoleDetailsBySlugPage/components/ProjectRoleModifySection.utils.tsx+++ b/frontend/src/pages/project/RoleDetailsBySlugPage/components/ProjectRoleModifySection.utils.tsx@@@ -1041,10 -1054,10 +1062,11 @@@ export const rolePermission2Form = (perProjectPermissionSub.AppConnections,ProjectPermissionSub.PamFolders,ProjectPermissionSub.PamResources,+ ProjectPermissionSub.PamDomains,ProjectPermissionSub.McpEndpoints,ProjectPermissionSub.McpServers,- ProjectPermissionSub.McpActivityLogs+ ProjectPermissionSub.McpActivityLogs,+ ProjectPermissionSub.Insights].includes(subject)) {// from above statement we are sure it won't be undefined@@@ -3401,9 -3455,9 +3486,10 @@@ const SecretScanningSubject = (enabledconst PamPermissionSubjects = (enabled = false) => ({[ProjectPermissionSub.PamFolders]: enabled,[ProjectPermissionSub.PamResources]: enabled,+ [ProjectPermissionSub.PamDomains]: enabled,[ProjectPermissionSub.PamAccounts]: enabled,[ProjectPermissionSub.PamSessions]: enabled,+ [ProjectPermissionSub.PamAccountPolicies]: enabled,[ProjectPermissionSub.PamDiscovery]: enabled});