Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

fix(pam): address review feedback on RDP/AD support

bernie-g3eb84d67b78c
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.ts
index 610805af00..170ff3af5f 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
@@ -104,8 +104,9 @@ const registerPerTypeEndpoints = (
gatewayId: z.string().uuid().optional().describe("The ID of the gateway to use"),
gatewayPoolId: z.string().uuid().optional().describe("The ID of the gateway pool to use"),
recordingConnectionId: z.string().uuid().optional().describe("The ID of the recording connection to use"),
- settingsOverrides: PamAccountSettingsOverridesSchema.optional()
- .describe("Account-level template settings overrides")
+ settingsOverrides: PamAccountSettingsOverridesSchema.optional().describe(
+ "Account-level template settings overrides"
+ )
}),
response: {
200: z.object({
@@ -188,8 +189,9 @@ const registerPerTypeEndpoints = (
.nullable()
.optional()
.describe("The ID of the recording connection to use"),
- settingsOverrides: PamAccountSettingsOverridesSchema.optional()
- .describe("Account-level template settings overrides")
+ settingsOverrides: PamAccountSettingsOverridesSchema.optional().describe(
+ "Account-level template settings overrides"
+ )
}),
response: {
200: z.object({
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.ts
index 505850f3bc..3f493b5909 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
@@ -56,10 +56,10 @@ export const pamAccountTemplateServiceFactory = (deps: TPamAccountTemplateServic
const validateTemplateRecordingS3Config = async (
recordingConnectionId: string | null | undefined,
- settings: TPamTemplateSettings,
+ settings: TPamTemplateSettings | undefined,
ctx: TActorContext
): Promise<TPamRecordingResolvedConfig | null> => {
- const isS3Backend = settings.recordingStorageBackend === PamRecordingStorageBackend.AwsS3;
+ const isS3Backend = settings?.recordingStorageBackend === PamRecordingStorageBackend.AwsS3;
let resolvedS3Config = null;
if (recordingConnectionId && settings) {
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.ts
index 36eca54695..e02eac7060 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
@@ -217,8 +217,9 @@ describe("getAccountAccessibilityIssues", () => {
expect(
getAccountAccessibilityIssues({
accountType: PamAccountType.Postgres,
- hasGateway: true,
- hasRecordingConfig: false,
+ gatewayId: "gw-1",
+ templateRecordingConnectionId: null,
+ templateSettings: {},
credentialConfigured: true
})
).toEqual([]);
@@ -228,8 +229,8 @@ describe("getAccountAccessibilityIssues", () => {
expect(
getAccountAccessibilityIssues({
accountType: PamAccountType.Postgres,
- hasGateway: false,
- hasRecordingConfig: false,
+ templateRecordingConnectionId: null,
+ templateSettings: {},
credentialConfigured: false
})
).toEqual([PamAccountAccessibilityIssue.NoGateway, PamAccountAccessibilityIssue.NoCredential]);
@@ -239,8 +240,9 @@ describe("getAccountAccessibilityIssues", () => {
expect(
getAccountAccessibilityIssues({
accountType: PamAccountType.Windows,
- hasGateway: true,
- hasRecordingConfig: false,
+ gatewayId: "gw-1",
+ templateRecordingConnectionId: null,
+ templateSettings: {},
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.ts
index 62a2dea8a7..8cdacabbd0 100644
--- a/backend/src/ee/services/pam-account/pam-account-schemas.ts
+++ b/backend/src/ee/services/pam-account/pam-account-schemas.ts
@@ -9,7 +9,10 @@ import { BadRequestError } from "@app/lib/errors";
import { PamAccountType } from "../pam/pam-enums";
import { getApplicablePolicies, PamPolicyDescriptorSchema } from "../pam/pam-policies";
-import { PamTemplateSettingsSchema } from "../pam-account-template/pam-account-template-schemas";
+import {
+ PamAccountSettingsOverridesSchema,
+ PamTemplateSettingsSchema
+} from "../pam-account-template/pam-account-template-schemas";
import { PamRecordingStorageBackend } from "../pam-session-recording/pam-recording-enums";
const resolveSrv = promisify(dns.resolveSrv);
@@ -56,11 +59,7 @@ export const ACCOUNT_TYPE_CONFIGS = {
database: z.string().trim().min(1).max(255),
sslEnabled: z.boolean(),
sslRejectUnauthorized: z.boolean(),
- sslCertificate: z
- .string()
- .trim()
- .transform((v) => v || undefined)
- .optional()
+ sslCertificate: optionalTrimmedString
}),
credentials: z.object({
username: z.string().trim().min(1).max(63),
@@ -97,11 +96,7 @@ export const ACCOUNT_TYPE_CONFIGS = {
database: z.string().trim().min(1).max(64),
sslEnabled: z.boolean(),
sslRejectUnauthorized: z.boolean(),
- sslCertificate: z
- .string()
- .trim()
- .transform((v) => v || undefined)
- .optional()
+ sslCertificate: optionalTrimmedString
}),
credentials: z.object({
username: z.string().trim().min(1).max(32),
@@ -138,11 +133,7 @@ export const ACCOUNT_TYPE_CONFIGS = {
database: z.string().trim().min(1).max(255),
sslEnabled: z.boolean(),
sslRejectUnauthorized: z.boolean(),
- sslCertificate: z
- .string()
- .trim()
- .transform((v) => v || undefined)
- .optional()
+ sslCertificate: optionalTrimmedString
}),
credentials: z.discriminatedUnion("authMethod", [
z.object({
@@ -285,11 +276,7 @@ export const ACCOUNT_TYPE_CONFIGS = {
}),
sslEnabled: z.boolean(),
sslRejectUnauthorized: z.boolean(),
- sslCertificate: z
- .string()
- .trim()
- .transform((v) => v || undefined)
- .optional()
+ sslCertificate: optionalTrimmedString
}),
credentials: z.object({
username: z.string().trim().min(1).max(255),
@@ -333,11 +320,7 @@ export const ACCOUNT_TYPE_CONFIGS = {
z.object({
authMethod: z.literal("password"),
username: z.string().trim().min(1),
- password: z
- .string()
- .trim()
- .transform((v) => v || undefined)
- .optional()
+ password: optionalTrimmedString
}),
z.object({
authMethod: z.literal("public-key"),
@@ -374,11 +357,7 @@ export const ACCOUNT_TYPE_CONFIGS = {
connectionDetails: z.object({
url: z.string().url().trim().max(500),
sslRejectUnauthorized: z.boolean(),
- sslCertificate: z
- .string()
- .trim()
- .transform((v) => v || undefined)
- .optional()
+ sslCertificate: optionalTrimmedString
}),
credentials: z.discriminatedUnion("authMethod", [
z.object({
@@ -416,12 +395,7 @@ export const ACCOUNT_TYPE_CONFIGS = {
}),
credentials: z.object({
username: z.string().trim().min(1).max(255),
- password: z
- .string()
- .trim()
- .max(255)
- .transform((v) => v || undefined)
- .optional()
+ password: optionalTrimmedString
}),
sanitizedCredentials: z.object({
username: z.string()
@@ -437,7 +411,7 @@ export const ACCOUNT_TYPE_CONFIGS = {
connectionDetails: z.object({
domain: z.string().trim().min(1).max(255),
dcAddress: z.string().trim().min(1).max(255),
- hostnames: delimitedStringList,
+ hosts: delimitedStringList,
port: z.coerce.number().int().min(1).max(65535),
rdpPort: z.coerce.number().int().min(1).max(65535),
useLdaps: z.boolean(),
@@ -447,17 +421,14 @@ export const ACCOUNT_TYPE_CONFIGS = {
}),
credentials: z.object({
username: z.string().trim().min(1).max(255),
- password: z.string().trim().min(1).max(255),
- domain: z.string().trim().max(255).optional()
+ password: z.string().trim().min(1).max(255)
}),
sanitizedCredentials: z.object({
- username: z.string(),
- domain: z.string().optional()
+ username: z.string()
}),
ui: {
- domain: { label: "Domain" },
dcAddress: { label: "DC Address" },
- hostnames: { label: "Allowed Hosts", widget: PamFieldWidget.Textarea },
+ hosts: { label: "Allowed Hosts", widget: PamFieldWidget.Textarea },
port: { label: "LDAP Port", defaultValue: 389 },
rdpPort: { label: "RDP Port", defaultValue: 3389 },
useLdaps: { label: "Use LDAPS" },
@@ -578,8 +549,8 @@ export const extractGatewayTarget = async (
}
case PamAccountType.ActiveDirectory:
return {
- host: (validated as { hostnames: string[]; rdpPort: number }).hostnames[0],
- port: (validated as { hostnames: string[]; rdpPort: number }).rdpPort
+ host: (validated as { hosts: string[]; rdpPort: number }).hosts[0],
+ port: (validated as { hosts: string[]; rdpPort: number }).rdpPort
};
default:
throw new Error(`No gateway target extraction defined for account type '${accountType}'`);
@@ -597,45 +568,39 @@ export enum PamAccountAccessibilityIssue {
export const accountTypeRequiresRecording = (accountType: PamAccountType): boolean =>
accountType === PamAccountType.Windows || accountType === PamAccountType.ActiveDirectory;
-export const hasPamAccountRecordingConfig = ({
- recordingConnectionId,
- templateRecordingConnectionId,
- settingsOverrides,
- templateSettings
-}: {
+export const getAccountAccessibilityIssues = (account: {
+ accountType: PamAccountType | string;
+ gatewayId?: string | null;
+ gatewayPoolId?: string | null;
+ templateGatewayId?: string | null;
+ templateGatewayPoolId?: string | null;
recordingConnectionId?: string | null;
templateRecordingConnectionId: string | null;
settingsOverrides?: unknown;
templateSettings: unknown;
-}): boolean => {
- const settingsParsed = PamTemplateSettingsSchema.safeParse(templateSettings);
- const parsedTemplateSettings = settingsParsed.success ? settingsParsed.data : null;
- const accountSettingsOverrides = (settingsOverrides ?? {}) as { recordingS3Config?: unknown };
-
- return Boolean(
- parsedTemplateSettings?.recordingStorageBackend === PamRecordingStorageBackend.AwsS3 &&
- (recordingConnectionId || templateRecordingConnectionId) &&
- (accountSettingsOverrides.recordingS3Config || parsedTemplateSettings.recordingS3Config)
- );
-};
-
-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 (!account.gatewayId && !account.gatewayPoolId && !account.templateGatewayId && !account.templateGatewayPoolId) {
+ issues.push(PamAccountAccessibilityIssue.NoGateway);
}
- if (!credentialConfigured) issues.push(PamAccountAccessibilityIssue.NoCredential);
+
+ if (accountTypeRequiresRecording(account.accountType as PamAccountType)) {
+ const settingsParsed = PamTemplateSettingsSchema.safeParse(account.templateSettings);
+ const parsedTemplateSettings = settingsParsed.success ? settingsParsed.data : null;
+ const overridesParsed = PamAccountSettingsOverridesSchema.safeParse(account.settingsOverrides ?? {});
+ const parsedOverrides = overridesParsed.success ? overridesParsed.data : null;
+
+ const hasRecordingConfig = Boolean(
+ parsedTemplateSettings?.recordingStorageBackend === PamRecordingStorageBackend.AwsS3 &&
+ (account.recordingConnectionId || account.templateRecordingConnectionId) &&
+ (parsedOverrides?.recordingS3Config || parsedTemplateSettings?.recordingS3Config)
+ );
+ if (!hasRecordingConfig) issues.push(PamAccountAccessibilityIssue.NoRecordingConfig);
+ }
+
+ if (!account.credentialConfigured) issues.push(PamAccountAccessibilityIssue.NoCredential);
return issues;
};
diff --git a/backend/src/ee/services/pam-account/pam-account-service.ts b/backend/src/ee/services/pam-account/pam-account-service.ts
index 97a9ba9b08..14e19d37a2 100644
--- a/backend/src/ee/services/pam-account/pam-account-service.ts
+++ b/backend/src/ee/services/pam-account/pam-account-service.ts
@@ -31,16 +31,15 @@ import {
} from "../pam/pam-permission";
import {
mintCorsProbeUrl,
+ resolveOverridesS3Config,
validateGatewayAttachment,
- validateRecordingConnection,
- validateRecordingS3Config
+ validateRecordingConnection
} from "../pam/pam-validators";
import { TPamAccountTemplateDALFactory } from "../pam-account-template/pam-account-template-dal";
import { TPamFolderDALFactory } from "../pam-folder/pam-folder-dal";
import { TPamAccountDALFactory } from "./pam-account-dal";
import {
getAccountAccessibilityIssues,
- hasPamAccountRecordingConfig,
isCredentialConfigured,
parseInternalMetadata,
sanitizeCredentials,
@@ -111,12 +110,7 @@ export const pamAccountServiceFactory = (deps: TPamAccountServiceFactoryDep) =>
templateSettings: unknown;
credentialConfigured: boolean;
}) => {
- const accessibilityIssues = getAccountAccessibilityIssues({
- accountType: a.accountType as PamAccountType,
- hasGateway: Boolean(a.gatewayId || a.gatewayPoolId || a.templateGatewayId || a.templateGatewayPoolId),
- hasRecordingConfig: hasPamAccountRecordingConfig(a),
- credentialConfigured: a.credentialConfigured
- });
+ const accessibilityIssues = getAccountAccessibilityIssues(a);
return { isAccessible: accessibilityIssues.length === 0, accessibilityIssues };
};
@@ -248,16 +242,12 @@ export const pamAccountServiceFactory = (deps: TPamAccountServiceFactoryDep) =>
await validateGatewayAttachment(deps, gatewayId, gatewayPoolId, ctx);
await validateRecordingConnection(deps, recordingConnectionId, ctx);
- let resolvedS3Config = null;
- if (settingsOverrides?.recordingS3Config) {
- const connId = recordingConnectionId ?? template.recordingConnectionId;
- if (!connId) {
- throw new BadRequestError({
- message: "S3 recording config requires an AWS connection on the account or template"
- });
- }
- resolvedS3Config = await validateRecordingS3Config(deps, connId, settingsOverrides.recordingS3Config, ctx);
- }
+ const resolvedS3Config = await resolveOverridesS3Config(
+ deps,
+ settingsOverrides,
+ recordingConnectionId ?? template.recordingConnectionId,
+ ctx
+ );
const validatedConnectionDetails = validateConnectionDetails(accountType, connectionDetails);
const validatedCredentials = validateCredentials(accountType, credentials);
@@ -369,18 +359,13 @@ export const pamAccountServiceFactory = (deps: TPamAccountServiceFactoryDep) =>
await validateGatewayAttachment(deps, gatewayId, gatewayPoolId, ctx);
await validateRecordingConnection(deps, recordingConnectionId, ctx);
- let resolvedS3Config = null;
- if (settingsOverrides?.recordingS3Config) {
- const connId =
- (recordingConnectionId !== undefined ? recordingConnectionId : existing.recordingConnectionId) ??
- existing.templateRecordingConnectionId;
- if (!connId) {
- throw new BadRequestError({
- message: "S3 recording config requires an AWS connection on the account or template"
- });
- }
- resolvedS3Config = await validateRecordingS3Config(deps, connId, settingsOverrides.recordingS3Config, ctx);
- }
+ const resolvedS3Config = await resolveOverridesS3Config(
+ deps,
+ settingsOverrides,
+ (recordingConnectionId !== undefined ? recordingConnectionId : existing.recordingConnectionId) ??
+ existing.templateRecordingConnectionId,
+ ctx
+ );
const updateData: Record<string, unknown> = {};
if (name !== undefined) updateData.name = name;
diff --git a/backend/src/ee/services/pam-project/pam-project-bootstrap.ts b/backend/src/ee/services/pam-project/pam-project-bootstrap.ts
index 2bfaeeb98b..28a11b51b6 100644
--- a/backend/src/ee/services/pam-project/pam-project-bootstrap.ts
+++ b/backend/src/ee/services/pam-project/pam-project-bootstrap.ts
@@ -150,8 +150,8 @@ export const DEFAULT_ACCOUNT_TEMPLATES: TDefaultTemplate[] = [
}
},
{
- name: "active-directory",
- type: PamAccountType.ActiveDirectory,
+ name: "windows",
+ type: PamAccountType.Windows,
settings: {
recordingEnabled: true,
recordingStorageBackend: PamRecordingStorageBackend.AwsS3,
@@ -166,8 +166,8 @@ export const DEFAULT_ACCOUNT_TEMPLATES: TDefaultTemplate[] = [
}
},
{
- name: "windows",
- type: PamAccountType.Windows,
+ name: "active-directory",
+ type: PamAccountType.ActiveDirectory,
settings: {
recordingEnabled: true,
recordingStorageBackend: PamRecordingStorageBackend.AwsS3,
diff --git a/backend/src/ee/services/pam-session/pam-session-service.ts b/backend/src/ee/services/pam-session/pam-session-service.ts
index f461dda39f..94f7c613c8 100644
--- a/backend/src/ee/services/pam-session/pam-session-service.ts
+++ b/backend/src/ee/services/pam-session/pam-session-service.ts
@@ -31,9 +31,9 @@ import {
import { resolveAccessControls } from "../pam/pam-policies";
import { TPamAccountDALFactory } from "../pam-account/pam-account-dal";
import {
- accountTypeRequiresRecording,
extractGatewayTarget,
- hasPamAccountRecordingConfig,
+ getAccountAccessibilityIssues,
+ PamAccountAccessibilityIssue,
parseInternalMetadata,
validateConnectionDetails
} from "../pam-account/pam-account-schemas";
@@ -105,14 +105,9 @@ export const pamSessionServiceFactory = ({
ctx: TActorContext
) => checkAccountAccess(permissionService, accountId, folderId, projectId, action, ctx);
- const enforceRecordingConfig = (account: {
- accountType: string;
- recordingConnectionId?: string | null;
- templateRecordingConnectionId: string | null;
- settingsOverrides?: unknown;
- templateSettings: unknown;
- }) => {
- if (accountTypeRequiresRecording(account.accountType as PamAccountType) && !hasPamAccountRecordingConfig(account)) {
+ const enforceRecordingConfig = (account: Parameters<typeof getAccountAccessibilityIssues>[0]) => {
+ const issues = getAccountAccessibilityIssues(account);
+ if (issues.includes(PamAccountAccessibilityIssue.NoRecordingConfig)) {
throw new BadRequestError({
message: "S3 recording must be configured before launching this account"
});
diff --git a/backend/src/ee/services/pam-web-access/pam-session-handlers.ts b/backend/src/ee/services/pam-web-access/pam-session-handlers.ts
index 24162e2126..dfdcdece47 100644
--- a/backend/src/ee/services/pam-web-access/pam-session-handlers.ts
+++ b/backend/src/ee/services/pam-web-access/pam-session-handlers.ts
@@ -28,6 +28,7 @@ export const SESSION_HANDLERS: Partial<Record<PamAccountType, TSessionHandlerEnt
gatewayAccountType: PamAccountType.Windows,
handler: handleRdpSession
},
+ // AD accounts use RDP through the Windows gateway protocol
[PamAccountType.ActiveDirectory]: {
gatewayAccountType: PamAccountType.Windows,
handler: handleRdpSession
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.ts
index 7d78d5e5bc..81f0bb9b0f 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
@@ -27,9 +27,9 @@ import { PamAccessMethod, PamSessionStatus } from "../pam/pam-enums";
import { checkAccountAccess } from "../pam/pam-permission";
import { TPamAccountDALFactory } from "../pam-account/pam-account-dal";
import {
- accountTypeRequiresRecording,
extractGatewayTarget,
- hasPamAccountRecordingConfig
+ getAccountAccessibilityIssues,
+ PamAccountAccessibilityIssue
} from "../pam-account/pam-account-schemas";
import { TPamSessionDALFactory } from "../pam-session/pam-session-dal";
import { SESSION_HANDLERS } from "./pam-session-handlers";
@@ -132,14 +132,9 @@ export const pamWebAccessServiceFactory = ({
socket.close();
};
- const enforceRecordingConfig = (account: {
- accountType: string;
- recordingConnectionId?: string | null;
- templateRecordingConnectionId: string | null;
- settingsOverrides?: unknown;
- templateSettings: unknown;
- }) => {
- if (accountTypeRequiresRecording(account.accountType as PamAccountType) && !hasPamAccountRecordingConfig(account)) {
+ const enforceRecordingConfig = (account: Parameters<typeof getAccountAccessibilityIssues>[0]) => {
+ const issues = getAccountAccessibilityIssues(account);
+ if (issues.includes(PamAccountAccessibilityIssue.NoRecordingConfig)) {
throw new BadRequestError({
message: "S3 recording must be configured before launching this account"
});
diff --git a/backend/src/ee/services/pam/pam-enums.ts b/backend/src/ee/services/pam/pam-enums.ts
index f46dc08249..21a9628191 100644
--- a/backend/src/ee/services/pam/pam-enums.ts
+++ b/backend/src/ee/services/pam/pam-enums.ts
@@ -8,8 +8,8 @@ export enum PamAccountType {
Redis = "redis",
Kubernetes = "kubernetes",
AwsIam = "aws-iam",
- ActiveDirectory = "active-directory",
- Windows = "windows"
+ Windows = "windows",
+ ActiveDirectory = "active-directory"
}
export enum PamResourceRole {
diff --git a/backend/src/ee/services/pam/pam-validators.ts b/backend/src/ee/services/pam/pam-validators.ts
index 7c1168b980..426a8fc7b7 100644
--- a/backend/src/ee/services/pam/pam-validators.ts
+++ b/backend/src/ee/services/pam/pam-validators.ts
@@ -1,6 +1,6 @@
import { ForbiddenError, subject } from "@casl/ability";
-import { ActionProjectType, OrganizationActionScope } from "@app/db/schemas";
+import { OrganizationActionScope } from "@app/db/schemas";
import { TGatewayPoolServiceFactory } from "@app/ee/services/gateway-pool/gateway-pool-service";
import { TGatewayV2DALFactory } from "@app/ee/services/gateway-v2/gateway-v2-dal";
import {
@@ -9,10 +9,6 @@ import {
OrgPermissionSubjects
} from "@app/ee/services/permission/org-permission";
import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service-types";
-import {
- ProjectPermissionAppConnectionActions,
- ProjectPermissionSub
-} from "@app/ee/services/permission/project-permission";
import { BadRequestError, NotFoundError } from "@app/lib/errors";
import { TAppConnectionDALFactory } from "@app/services/app-connection/app-connection-dal";
import { AppConnection, AWSRegion } from "@app/services/app-connection/app-connection-enums";
@@ -21,6 +17,7 @@ import { getAwsConnectionConfig } from "@app/services/app-connection/aws/aws-con
import { TAwsConnectionConfig } from "@app/services/app-connection/aws/aws-connection-types";
import { TKmsServiceFactory } from "@app/services/kms/kms-service";
+import { TPamAccountSettingsOverrides } from "../pam-account-template/pam-account-template-schemas";
import { PamRecordingStorageBackend } from "../pam-session-recording/pam-recording-enums";
import { PAM_RECORDING_STORAGE_FACTORY_MAP } from "../pam-session-recording/pam-recording-storage-factory";
import { normalizeKeyPrefix, TPamRecordingResolvedConfig } from "../pam-session-recording/pam-recording-storage-types";
@@ -86,36 +83,21 @@ const enforceAppConnectionConnect = async (
throw new BadRequestError({ message: "Recording connection must be an AWS connection" });
}
- if (conn.projectId) {
- const { permission } = await permissionService.getProjectPermission({
- actor: ctx.actor,
- actorId: ctx.actorId,
- projectId: conn.projectId,
- actorAuthMethod: ctx.actorAuthMethod,
- actorOrgId: ctx.actorOrgId,
- actionProjectType: ActionProjectType.Any
- });
- ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionAppConnectionActions.Connect,
- subject(ProjectPermissionSub.AppConnections, { connectionId })
- );
- } else {
- if (conn.orgId !== ctx.actorOrgId) {
- throw new NotFoundError({ message: "Recording connection not found" });
- }
- const { permission: orgPermission } = await permissionService.getOrgPermission({
- actorId: ctx.actorId,
- actor: ctx.actor,
- orgId: conn.orgId,
- actorOrgId: ctx.actorOrgId,
- actorAuthMethod: ctx.actorAuthMethod,
- scope: OrganizationActionScope.Any
- });
- ForbiddenError.from(orgPermission).throwUnlessCan(
- OrgPermissionAppConnectionActions.Connect,
- subject(OrgPermissionSubjects.AppConnections, { connectionId })
- );
+ if (conn.orgId !== ctx.actorOrgId) {
+ throw new NotFoundError({ message: "Recording connection not found" });
}
+ const { permission: orgPermission } = await permissionService.getOrgPermission({
+ actorId: ctx.actorId,
+ actor: ctx.actor,
+ orgId: conn.orgId,
+ actorOrgId: ctx.actorOrgId,
+ actorAuthMethod: ctx.actorAuthMethod,
+ scope: OrganizationActionScope.Any
+ });
+ ForbiddenError.from(orgPermission).throwUnlessCan(
+ OrgPermissionAppConnectionActions.Connect,
+ subject(OrgPermissionSubjects.AppConnections, { connectionId })
+ );
return conn;
};
@@ -158,6 +140,23 @@ export const validateRecordingS3Config = async (
return resolvedConfig;
};
+export const resolveOverridesS3Config = async (
+ deps: Pick<TPamValidatorDeps, "permissionService" | "appConnectionDAL" | "kmsService">,
+ settingsOverrides: TPamAccountSettingsOverrides | null | undefined,
+ effectiveConnectionId: string | null | undefined,
+ ctx: TActorContext
+): Promise<TPamRecordingResolvedConfig | null> => {
+ if (!settingsOverrides?.recordingS3Config) return null;
+
+ if (!effectiveConnectionId) {
+ throw new BadRequestError({
+ message: "S3 recording config requires an AWS connection on the account or template"
+ });
+ }
+
+ return validateRecordingS3Config(deps, effectiveConnectionId, settingsOverrides.recordingS3Config, ctx);
+};
+
export const mintCorsProbeUrl = async (resolvedConfig: TPamRecordingResolvedConfig): Promise<string | null> => {
try {
const probeKey = `${normalizeKeyPrefix(resolvedConfig.keyPrefix)}.cors-probe`;
diff --git a/frontend/src/hooks/api/pam/enums.ts b/frontend/src/hooks/api/pam/enums.ts
index ab4c562dd3..3a9ed47aca 100644
--- a/frontend/src/hooks/api/pam/enums.ts
+++ b/frontend/src/hooks/api/pam/enums.ts
@@ -8,8 +8,8 @@ export enum PamAccountType {
Redis = "redis",
Kubernetes = "kubernetes",
AwsIam = "aws-iam",
- ActiveDirectory = "active-directory",
- Windows = "windows"
+ Windows = "windows",
+ ActiveDirectory = "active-directory"
}
export enum PamPolicyType {
@@ -21,6 +21,7 @@ export enum PamPolicyType {
export enum SessionChannelType {
Terminal = "terminal",
Exec = "exec",
+ Sftp = "sftp",
Rdp = "rdp"
}
diff --git a/frontend/src/pages/pam/PamAccountAccessPage/RdpContent.tsx b/frontend/src/pages/pam/PamAccountAccessPage/RdpContent.tsx
index 0e85c8206a..582dd5db20 100644
--- a/frontend/src/pages/pam/PamAccountAccessPage/RdpContent.tsx
+++ b/frontend/src/pages/pam/PamAccountAccessPage/RdpContent.tsx
@@ -12,15 +12,17 @@ import { WebAccessStatusCard } from "./WebAccessStatusCard";
type RdpContentProps = {
account: TPamAccount;
reason?: string;
+ mfaSessionId?: string;
};
-export const RdpContent = ({ account, reason }: RdpContentProps) => {
+export const RdpContent = ({ account, reason, mfaSessionId }: RdpContentProps) => {
const [sessionEnded, setSessionEnded] = useState(false);
const { containerRef, isConnected, error, disconnect, reconnect } = useRdpSession({
accountId: account.id,
accountName: account.name,
reason,
+ mfaSessionId,
onSessionEnd: () => setSessionEnded(true)
});
diff --git a/frontend/src/pages/pam/PamAccountAccessPage/useRdpSession.ts b/frontend/src/pages/pam/PamAccountAccessPage/useRdpSession.ts
index 6ca3ca8b2e..aadf1fc96b 100644
--- a/frontend/src/pages/pam/PamAccountAccessPage/useRdpSession.ts
+++ b/frontend/src/pages/pam/PamAccountAccessPage/useRdpSession.ts
@@ -79,6 +79,7 @@ type UseRdpSessionOptions = {
accountId: string;
accountName: string;
reason?: string;
+ mfaSessionId?: string;
onSessionEnd?: () => void;
};
@@ -86,6 +87,7 @@ export const useRdpSession = ({
accountId,
accountName,
reason,
+ mfaSessionId,
onSessionEnd
}: UseRdpSessionOptions) => {
const containerRef = useRef<HTMLDivElement | null>(null);
@@ -136,7 +138,7 @@ export const useRdpSession = ({
const { data } = await apiRequest.post<{ ticket: string }>(
`/api/v1/pam/accounts/${accountId}/web-access-ticket`,
- { reason }
+ { reason, mfaSessionId }
);
if (!isCurrent()) return;
const proxyAddress = buildProxyAddress(data.ticket);
@@ -198,7 +200,7 @@ export const useRdpSession = ({
containerRef.current.appendChild(el);
elementRef.current = el;
- }, [accountId, accountName, reason, buildProxyAddress, teardown]);
+ }, [accountId, accountName, reason, mfaSessionId, buildProxyAddress, teardown]);
const handleConnectError = useCallback((err: unknown) => {
let message = "Failed to start RDP session";