Skip to content

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

feat(pam): add AWS IAM account type with web and CLI access (#7054)

Saif Ur Rahman8dcfe886233f
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 c276ccbe11..404c2cfd14 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
@@ -324,7 +324,11 @@ export const registerPamAccountRouter = async (server: FastifyZodProvider) => {
onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
handler: async () => {
return {
- accountTypes: buildPamAccountTypeMetadata(new Set(Object.keys(SESSION_HANDLERS) as PamAccountType[]))
+ // AWS IAM supports browser access (console URL redirect) but not WebSocket-based terminal,
+ // so it's added separately from SESSION_HANDLERS
+ accountTypes: buildPamAccountTypeMetadata(
+ new Set([...Object.keys(SESSION_HANDLERS), PamAccountType.AwsIam] as PamAccountType[])
+ )
};
}
});
diff --git a/backend/src/ee/routes/v1/pam-routers/pam-session-router.ts b/backend/src/ee/routes/v1/pam-routers/pam-session-router.ts
index 73afa36c26..96bd317179 100644
--- a/backend/src/ee/routes/v1/pam-routers/pam-session-router.ts
+++ b/backend/src/ee/routes/v1/pam-routers/pam-session-router.ts
@@ -3,7 +3,7 @@ import z from "zod";
import { PamSessionsSchema } from "@app/db/schemas";
import { EventType, UserAgentType } from "@app/ee/services/audit-log/audit-log-types";
-import { PamAccountType, PamSessionStatus } from "@app/ee/services/pam/pam-enums";
+import { PamAccessMethod, PamAccountType, PamSessionStatus } from "@app/ee/services/pam/pam-enums";
import { PamPolicyRulesSchema } from "@app/ee/services/pam/pam-policies";
import { hostPattern } from "@app/ee/services/pam-account/pam-account-schemas";
import { PamRecordingStorageBackend } from "@app/ee/services/pam-session-recording/pam-recording-enums";
@@ -302,6 +302,7 @@ export const registerPamWebAccessRouter = async (server: FastifyZodProvider) =>
.optional()
.describe("Session duration (e.g. '1h', '30m'). Capped at the account's max session duration."),
mfaSessionId: z.string().max(64).optional().describe("MFA session ID from a completed MFA verification"),
+ accessMethod: z.enum(["cli", "web"]).optional().default("cli").describe("Access method (cli or web)"),
targetHost: z
.string()
.trim()
@@ -315,13 +316,19 @@ export const registerPamWebAccessRouter = async (server: FastifyZodProvider) =>
sessionId: z.string().describe("The ID of the created session"),
accountType: z.nativeEnum(PamAccountType).describe("The account type"),
metadata: z.record(z.string()).optional().describe("Account-type-specific metadata (e.g., username)"),
- relayHost: z.string().describe("The relay host to connect to"),
- relayClientCertificate: z.string().describe("Client certificate for the relay connection"),
- relayClientPrivateKey: z.string().describe("Client private key for the relay connection"),
- relayServerCertificateChain: z.string().describe("Server certificate chain for the relay connection"),
- gatewayClientCertificate: z.string().describe("Client certificate for the gateway connection"),
- gatewayClientPrivateKey: z.string().describe("Client private key for the gateway connection"),
- gatewayServerCertificateChain: z.string().describe("Server certificate chain for the gateway connection")
+ relayHost: z.string().optional().describe("The relay host to connect to"),
+ relayClientCertificate: z.string().optional().describe("Client certificate for the relay connection"),
+ relayClientPrivateKey: z.string().optional().describe("Client private key for the relay connection"),
+ relayServerCertificateChain: z
+ .string()
+ .optional()
+ .describe("Server certificate chain for the relay connection"),
+ gatewayClientCertificate: z.string().optional().describe("Client certificate for the gateway connection"),
+ gatewayClientPrivateKey: z.string().optional().describe("Client private key for the gateway connection"),
+ gatewayServerCertificateChain: z
+ .string()
+ .optional()
+ .describe("Server certificate chain for the gateway connection")
})
}
},
@@ -347,6 +354,7 @@ export const registerPamWebAccessRouter = async (server: FastifyZodProvider) =>
reason: req.body.reason,
duration: req.body.duration,
mfaSessionId: req.body.mfaSessionId,
+ accessMethod: req.body.accessMethod === "web" ? PamAccessMethod.Web : PamAccessMethod.Cli,
targetHost: req.body.targetHost
});
diff --git a/backend/src/ee/services/pam-account/pam-account-dal.ts b/backend/src/ee/services/pam-account/pam-account-dal.ts
index 31f5eff444..ee70bedef1 100644
--- a/backend/src/ee/services/pam-account/pam-account-dal.ts
+++ b/backend/src/ee/services/pam-account/pam-account-dal.ts
@@ -7,14 +7,21 @@ import { ormify } from "@app/lib/knex";
import { PamAccountType } from "../pam/pam-enums";
import { PamRecordingStorageBackend } from "../pam-session-recording/pam-recording-enums";
+import { ACCOUNT_TYPE_CONFIGS } from "./pam-account-schemas";
const recordingRequiredAccountTypes = [PamAccountType.Windows, PamAccountType.WindowsAd]
.map((type) => `'${type}'`)
.join(", ");
+const gatewayExemptAccountTypes = (Object.entries(ACCOUNT_TYPE_CONFIGS) as [string, { requiresGateway?: boolean }][])
+ .filter(([, config]) => config.requiresGateway === false)
+ .map(([type]) => `'${type}'`)
+ .join(", ");
+
export const accountAccessibilitySql = (accountTable: string, templateTable: string): string =>
`(
- ("${accountTable}"."gatewayId" is not null or "${accountTable}"."gatewayPoolId" is not null
+ ("${templateTable}"."type" in (${gatewayExemptAccountTypes})
+ or "${accountTable}"."gatewayId" is not null or "${accountTable}"."gatewayPoolId" is not null
or "${templateTable}"."gatewayId" is not null or "${templateTable}"."gatewayPoolId" is not null)
and "${accountTable}"."credentialConfigured" = true
and ("${templateTable}"."type" not in (${recordingRequiredAccountTypes})
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 9e6f9664d8..a46f8aa7db 100644
--- a/backend/src/ee/services/pam-account/pam-account-schemas.ts
+++ b/backend/src/ee/services/pam-account/pam-account-schemas.ts
@@ -461,6 +461,31 @@ export const ACCOUNT_TYPE_CONFIGS = {
},
password: { widget: PamFieldWidget.Password, secret: true }
}
+ },
+
+ [PamAccountType.AwsIam]: {
+ name: "AWS IAM",
+ icon: "Amazon Web Services.png",
+ requiresGateway: false,
+ connectionDetails: z.object({
+ roleArn: z.string().trim().min(1).max(2048)
+ }),
+ credentials: z.object({
+ targetRoleArn: z.string().trim().min(1).max(2048)
+ }),
+ sanitizedCredentials: z.object({
+ targetRoleArn: z.string().optional()
+ }),
+ ui: {
+ roleArn: {
+ label: "PAM Role ARN",
+ tooltip: "The ARN of the IAM role that Infisical assumes to broker access to the target role."
+ },
+ targetRoleArn: {
+ label: "Target Role ARN",
+ tooltip: "The ARN of the IAM role the user will assume when accessing this account."
+ }
+ }
}
} as const satisfies Partial<
Record<
@@ -468,6 +493,7 @@ export const ACCOUNT_TYPE_CONFIGS = {
{
name: string;
icon: string;
+ requiresGateway?: boolean;
connectionDetails: z.ZodTypeAny;
credentials: z.ZodTypeAny;
sanitizedCredentials: z.ZodTypeAny;
@@ -569,6 +595,8 @@ export const extractGatewayTarget = async (
host: (validated as { hosts: string[]; rdpPort: number }).hosts[0],
port: (validated as { hosts: string[]; rdpPort: number }).rdpPort
};
+ case PamAccountType.AwsIam:
+ throw new Error("AWS IAM accounts do not use gateway routing");
default:
throw new Error(`No gateway target extraction defined for account type '${accountType}'`);
}
@@ -631,6 +659,13 @@ export enum PamAccountAccessibilityIssue {
export const accountTypeRequiresRecording = (accountType: PamAccountType): boolean =>
accountType === PamAccountType.Windows || accountType === PamAccountType.WindowsAd;
+export const accountTypeRequiresGateway = (accountType: PamAccountType): boolean => {
+ const config = ACCOUNT_TYPE_CONFIGS[accountType as TSupportedAccountType] as
+ | { requiresGateway?: boolean }
+ | undefined;
+ return config?.requiresGateway !== false;
+};
+
export const getAccountAccessibilityIssues = (account: {
accountType: PamAccountType | string;
gatewayId?: string | null;
@@ -645,7 +680,13 @@ export const getAccountAccessibilityIssues = (account: {
}): PamAccountAccessibilityIssue[] => {
const issues: PamAccountAccessibilityIssue[] = [];
- if (!account.gatewayId && !account.gatewayPoolId && !account.templateGatewayId && !account.templateGatewayPoolId) {
+ if (
+ accountTypeRequiresGateway(account.accountType as PamAccountType) &&
+ !account.gatewayId &&
+ !account.gatewayPoolId &&
+ !account.templateGatewayId &&
+ !account.templateGatewayPoolId
+ ) {
issues.push(PamAccountAccessibilityIssue.NoGateway);
}
@@ -704,6 +745,7 @@ export const PamAccountTypeMetadataSchema = z.object({
name: z.string(),
icon: z.string(),
supportsWebAccess: z.boolean(),
+ requiresGateway: z.boolean(),
connectionFields: z.array(PamFieldDescriptorSchema),
credentialFields: z.array(PamFieldDescriptorSchema),
applicablePolicies: z.array(PamPolicyDescriptorSchema)
@@ -856,6 +898,7 @@ export const buildPamAccountTypeMetadata = (webAccessSupportedTypes: Set<PamAcco
name: config.name,
icon: config.icon,
supportsWebAccess: webAccessSupportedTypes.has(type),
+ requiresGateway: accountTypeRequiresGateway(type),
connectionFields: fieldsFromSchema(config.connectionDetails, config.ui),
credentialFields: fieldsFromSchema(config.credentials, config.ui),
applicablePolicies: getApplicablePolicies(type)
diff --git a/backend/src/ee/services/pam-session/aws-iam/aws-iam-federation.ts b/backend/src/ee/services/pam-session/aws-iam/aws-iam-federation.ts
new file mode 100644
index 0000000000..1062c2769e
--- /dev/null
+++ b/backend/src/ee/services/pam-session/aws-iam/aws-iam-federation.ts
@@ -0,0 +1,180 @@
+import { AssumeRoleCommand, Credentials, STSClient, STSClientConfig } from "@aws-sdk/client-sts";
+import axios from "axios";
+
+import { CustomAWSHasher } from "@app/lib/aws/hashing";
+import { getConfig } from "@app/lib/config/env";
+import { crypto } from "@app/lib/crypto";
+import { BadRequestError, InternalServerError } from "@app/lib/errors";
+
+export const AWS_STS_MIN_DURATION_SECONDS = 900;
+
+const AWS_STS_DEFAULT_REGION = "us-east-1";
+
+const createStsClient = (credentials?: Credentials): STSClient => {
+ const appCfg = getConfig();
+
+ const config: STSClientConfig = {
+ region: AWS_STS_DEFAULT_REGION,
+ useFipsEndpoint: crypto.isFipsModeEnabled(),
+ sha256: CustomAWSHasher
+ };
+
+ if (credentials) {
+ config.credentials = {
+ accessKeyId: credentials.AccessKeyId!,
+ secretAccessKey: credentials.SecretAccessKey!,
+ sessionToken: credentials.SessionToken
+ };
+ } else if (appCfg.PAM_AWS_ACCESS_KEY_ID && appCfg.PAM_AWS_SECRET_ACCESS_KEY) {
+ config.credentials = {
+ accessKeyId: appCfg.PAM_AWS_ACCESS_KEY_ID,
+ secretAccessKey: appCfg.PAM_AWS_SECRET_ACCESS_KEY
+ };
+ }
+
+ return new STSClient(config);
+};
+
+const assumePamRole = async ({
+ connectionDetails,
+ projectId,
+ sessionDuration = AWS_STS_MIN_DURATION_SECONDS,
+ sessionNameSuffix = "validation"
+}: {
+ connectionDetails: { roleArn: string };
+ projectId: string;
+ sessionDuration?: number;
+ sessionNameSuffix?: string;
+}): Promise<Credentials> => {
+ const stsClient = createStsClient();
+
+ const result = await stsClient.send(
+ new AssumeRoleCommand({
+ RoleArn: connectionDetails.roleArn,
+ RoleSessionName: `infisical-pam-${sessionNameSuffix}-${Date.now()}`,
+ DurationSeconds: sessionDuration,
+ ExternalId: projectId
+ })
+ );
+
+ if (!result.Credentials) {
+ throw new InternalServerError({
+ message: "Failed to assume PAM role - AWS STS did not return credentials"
+ });
+ }
+
+ return result.Credentials;
+};
+
+const assumeTargetRole = async ({
+ pamCredentials,
+ targetRoleArn,
+ projectId,
+ roleSessionName,
+ sessionDuration = AWS_STS_MIN_DURATION_SECONDS
+}: {
+ pamCredentials: Credentials;
+ targetRoleArn: string;
+ projectId: string;
+ roleSessionName: string;
+ sessionDuration?: number;
+}): Promise<Credentials> => {
+ const chainedStsClient = createStsClient(pamCredentials);
+
+ const result = await chainedStsClient.send(
+ new AssumeRoleCommand({
+ RoleArn: targetRoleArn,
+ RoleSessionName: roleSessionName,
+ DurationSeconds: sessionDuration,
+ ExternalId: projectId
+ })
+ );
+
+ if (!result.Credentials) {
+ throw new BadRequestError({
+ message: "Failed to assume target role - verify the target role trust policy allows the PAM role to assume it"
+ });
+ }
+
+ return result.Credentials;
+};
+
+export type TAwsIamSessionCredentials = {
+ accessKeyId: string;
+ secretAccessKey: string;
+ sessionToken: string;
+ expiresAt: Date;
+};
+
+export const generateAwsIamSessionCredentials = async ({
+ connectionDetails,
+ targetRoleArn,
+ roleSessionName,
+ projectId,
+ sessionDuration
+}: {
+ connectionDetails: { roleArn: string };
+ targetRoleArn: string;
+ roleSessionName: string;
+ projectId: string;
+ sessionDuration: number;
+}): Promise<TAwsIamSessionCredentials> => {
+ const pamCredentials = await assumePamRole({
+ connectionDetails,
+ projectId,
+ sessionDuration,
+ sessionNameSuffix: "session"
+ });
+
+ const targetCredentials = await assumeTargetRole({
+ pamCredentials,
+ targetRoleArn,
+ projectId,
+ roleSessionName,
+ sessionDuration
+ });
+
+ const { AccessKeyId, SecretAccessKey, SessionToken, Expiration } = targetCredentials;
+
+ if (!AccessKeyId || !SecretAccessKey || !SessionToken) {
+ throw new InternalServerError({
+ message: "AWS STS returned credentials missing required fields"
+ });
+ }
+
+ return {
+ accessKeyId: AccessKeyId,
+ secretAccessKey: SecretAccessKey,
+ sessionToken: SessionToken,
+ expiresAt: Expiration ?? new Date(Date.now() + sessionDuration * 1000)
+ };
+};
+
+export const exchangeCredentialsForConsoleUrl = async (
+ credentials: Pick<TAwsIamSessionCredentials, "accessKeyId" | "secretAccessKey" | "sessionToken">
+): Promise<string> => {
+ const sessionJson = JSON.stringify({
+ sessionId: credentials.accessKeyId,
+ sessionKey: credentials.secretAccessKey,
+ sessionToken: credentials.sessionToken
+ });
+
+ const federationEndpoint = "https://signin.aws.amazon.com/federation";
+ const signinTokenUrl = `${federationEndpoint}?Action=getSigninToken&Session=${encodeURIComponent(sessionJson)}`;
+
+ const tokenResponse = await axios.get<{ SigninToken?: string }>(signinTokenUrl, { timeout: 10000 });
+
+ if (!tokenResponse.data.SigninToken) {
+ throw new InternalServerError({
+ message: `AWS federation endpoint did not return a SigninToken: ${JSON.stringify(tokenResponse.data).substring(0, 200)}`
+ });
+ }
+
+ const consoleDestination = `https://console.aws.amazon.com/`;
+ return `${federationEndpoint}?Action=login&SigninToken=${encodeURIComponent(tokenResponse.data.SigninToken)}&Destination=${encodeURIComponent(consoleDestination)}`;
+};
+
+export const extractAwsAccountIdFromArn = (arn: string): string | null => {
+ const parts = arn.split(":");
+ return parts.length >= 5 ? parts[4] : null;
+};
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 34f77ea48b..e8b01bf039 100644
--- a/backend/src/ee/services/pam-session/pam-session-service.ts
+++ b/backend/src/ee/services/pam-session/pam-session-service.ts
@@ -1,4 +1,5 @@
import net from "net";
+import RE2 from "re2";
import { TGatewayPoolServiceFactory } from "@app/ee/services/gateway-pool/gateway-pool-service";
import { TGatewayV2ServiceFactory } from "@app/ee/services/gateway-v2/gateway-v2-service";
@@ -51,6 +52,12 @@ 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";
import { ResourcePermissionPamResourceActions } from "../permission/resource-permission";
+import {
+ AWS_STS_MIN_DURATION_SECONDS,
+ exchangeCredentialsForConsoleUrl,
+ extractAwsAccountIdFromArn,
+ generateAwsIamSessionCredentials
+} from "./aws-iam/aws-iam-federation";
import { DEFAULT_SESSION_DURATION_MS } from "./pam-session-constants";
import { TPamSessionDALFactory } from "./pam-session-dal";
import { TPamSessionExpirationServiceFactory } from "./pam-session-expiration-queue";
@@ -360,6 +367,7 @@ export const pamSessionServiceFactory = ({
reason,
duration,
mfaSessionId,
+ accessMethod = PamAccessMethod.Cli,
targetHost
}: {
path: string;
@@ -372,6 +380,7 @@ export const pamSessionServiceFactory = ({
reason?: string;
duration?: string;
mfaSessionId?: string;
+ accessMethod?: PamAccessMethod;
targetHost?: string;
}) => {
const account = await resolveAccountByPath(projectId, path);
@@ -415,6 +424,82 @@ export const pamSessionServiceFactory = ({
sessionDurationMs = Math.min(parsed, maxDurationMs);
}
+ // AWS IAM: no gateway, no proxy -- generate STS credentials directly
+ if (account.accountType === PamAccountType.AwsIam) {
+ const stsDurationSeconds = Math.floor(sessionDurationMs / 1000);
+
+ if (stsDurationSeconds < AWS_STS_MIN_DURATION_SECONDS) {
+ throw new BadRequestError({
+ message: `AWS IAM sessions require a minimum duration of ${AWS_STS_MIN_DURATION_SECONDS} seconds (15 minutes)`
+ });
+ }
+
+ const rawConnectionDetails = await decrypt(projectId, account.encryptedConnectionDetails);
+ const rawCredentials = await decrypt(projectId, account.encryptedCredentials);
+
+ const stsCredentials = await generateAwsIamSessionCredentials({
+ connectionDetails: { roleArn: rawConnectionDetails.roleArn as string },
+ targetRoleArn: rawCredentials.targetRoleArn as string,
+ roleSessionName: actorEmail.replace(new RE2(/[^\w+=,.@-]/g), "_").substring(0, 64),
+ projectId,
+ sessionDuration: stsDurationSeconds
+ });
+
+ const { expiresAt } = stsCredentials;
+
+ const metadata: Record<string, string> = {};
+
+ if (accessMethod === PamAccessMethod.Web) {
+ const consoleUrl = await exchangeCredentialsForConsoleUrl({
+ accessKeyId: stsCredentials.accessKeyId,
+ secretAccessKey: stsCredentials.secretAccessKey,
+ sessionToken: stsCredentials.sessionToken
+ });
+ metadata.consoleUrl = consoleUrl;
+ } else {
+ metadata.accessKeyId = stsCredentials.accessKeyId;
+ metadata.secretAccessKey = stsCredentials.secretAccessKey;
+ metadata.sessionToken = stsCredentials.sessionToken;
+ metadata.expiresAt = expiresAt.toISOString();
+ metadata.targetRoleArn = rawCredentials.targetRoleArn as string;
+ metadata.federatedUsername = actorEmail;
+
+ const awsAccountId = extractAwsAccountIdFromArn(rawConnectionDetails.roleArn as string);
+ if (awsAccountId) {
+ metadata.awsAccountId = awsAccountId;
+ }
+ }
+
+ const session = await pamSessionDAL.create({
+ status: PamSessionStatus.Active,
+ accessMethod,
+ expiresAt,
+ startedAt: new Date(),
+ accountName: account.name,
+ accountType: account.accountType,
+ actorEmail,
+ actorIp,
+ actorName,
+ actorUserAgent,
+ projectId,
+ accountId: account.id,
+ userId: actor.actorId,
+ reason: trimmedReason,
+ folderName: account.folderName
+ });
+
+ await pamSessionExpirationService.scheduleSessionExpiration(session.id, expiresAt);
+
+ return {
+ sessionId: session.id,
+ accountId: account.id,
+ accountType: account.accountType as PamAccountType,
+ accountName: account.name,
+ metadata,
+ sessionDurationMs
+ };
+ }
+
await checkAccount(
account.id,
account.folderId,
diff --git a/backend/src/ee/services/pam/pam-policies.ts b/backend/src/ee/services/pam/pam-policies.ts
index cd48d4e450..0d6f8f6671 100644
--- a/backend/src/ee/services/pam/pam-policies.ts
+++ b/backend/src/ee/services/pam/pam-policies.ts
@@ -49,11 +49,17 @@ export const patternsStringSchema = (maxPatterns = 20, maxPatternLength = 500) =
{ message: "One or more patterns are not valid regular expressions" }
);
+type TPamPolicyTypeOverride = {
+ description?: string;
+ schema?: z.ZodTypeAny;
+};
+
type TPamPolicyDefinition = {
label: string;
description: string;
appliesTo: PamAccountType[] | "all";
schema: z.ZodTypeAny;
+ typeOverrides?: Partial<Record<PamAccountType, TPamPolicyTypeOverride>>;
};
export const PAM_POLICY_DEFINITIONS: Record<PamPolicyType, TPamPolicyDefinition> = {
@@ -73,7 +79,13 @@ export const PAM_POLICY_DEFINITIONS: Record<PamPolicyType, TPamPolicyDefinition>
label: "Max Session Duration",
description: "Maximum session length in seconds (60 to 86400).",
appliesTo: "all",
- schema: z.number().int().min(60).max(86400)
+ schema: z.number().int().min(60).max(86400),
+ typeOverrides: {
+ [PamAccountType.AwsIam]: {
+ description: "Maximum session length in seconds (900 to 3600).",
+ schema: z.number().int().min(900).max(3600)
+ }
+ }
},
[PamPolicyType.CommandBlocking]: {
label: "Command Blocking",
@@ -97,7 +109,10 @@ export const policyAppliesTo = (policy: PamPolicyType, accountType: PamAccountTy
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 }));
+ .map(([key, def]) => {
+ const override = def.typeOverrides?.[accountType];
+ return { key, label: def.label, description: override?.description ?? def.description };
+ });
export type TValidatePolicyValuesResult = { ok: true; data: Record<string, unknown> } | { ok: false; message: string };
@@ -128,7 +143,9 @@ export const validatePolicyValues = (
};
}
- const parsed = PAM_POLICY_DEFINITIONS[policy].schema.safeParse(value);
+ const def = PAM_POLICY_DEFINITIONS[policy];
+ const schema = def.typeOverrides?.[accountType]?.schema ?? def.schema;
+ const parsed = schema.safeParse(value);
if (!parsed.success) {
const reason = parsed.error.issues.map((issue) => issue.message).join("; ");
return { ok: false, message: `Invalid configuration for policy '${key}': ${reason}` };
diff --git a/frontend/src/hooks/api/pam/mutations.tsx b/frontend/src/hooks/api/pam/mutations.tsx
index ca4cc77b0b..24220a9e05 100644
--- a/frontend/src/hooks/api/pam/mutations.tsx
+++ b/frontend/src/hooks/api/pam/mutations.tsx
@@ -18,6 +18,7 @@ import {
TDeletePamAccountDTO,
TDeletePamAccountTemplateDTO,
TDeletePamFolderDTO,
+ TPamAccessResponse,
TPamAccountTemplate,
TPamFolder,
TPamSession,
@@ -387,6 +388,33 @@ export const useRemoveFolderGroupMember = () => {
});
};
+export const useAccessPamAccount = () => {
+ return useMutation({
+ mutationFn: async ({
+ path,
+ reason,
+ duration,
+ mfaSessionId,
+ accessMethod
+ }: {
+ path: string;
+ reason?: string;
+ duration?: string;
+ mfaSessionId?: string;
+ accessMethod?: "cli" | "web";
+ }) => {
+ const { data } = await apiRequest.post<TPamAccessResponse>("/api/v1/pam/accounts/access", {
+ path,
+ reason,
+ duration,
+ mfaSessionId,
+ accessMethod
+ });
+ return data;
+ }
+ });
+};
+
export const useAddPamProductIdentityMember = () => {
const queryClient = useQueryClient();
return useMutation({
diff --git a/frontend/src/hooks/api/pam/types/index.ts b/frontend/src/hooks/api/pam/types/index.ts
index 7b32f83b1e..de8b237420 100644
--- a/frontend/src/hooks/api/pam/types/index.ts
+++ b/frontend/src/hooks/api/pam/types/index.ts
@@ -47,11 +47,18 @@ export type TPamAccountTypeMetadata = {
name: string;
icon: string;
supportsWebAccess: boolean;
+ requiresGateway: boolean;
connectionFields: TPamFieldDescriptor[];
credentialFields: TPamFieldDescriptor[];
applicablePolicies: TPamPolicyDescriptor[];
};
+export type TPamAccessResponse = {
+ sessionId: string;
+ accountType: string;
+ metadata?: Record<string, string>;
+};
+
// New model types
export enum PamAccountAccessibilityIssue {
diff --git a/frontend/src/pages/pam/PamAccountAccessPage/AwsIamAccessContent.tsx b/frontend/src/pages/pam/PamAccountAccessPage/AwsIamAccessContent.tsx
new file mode 100644
index 0000000000..b86127cb99
--- /dev/null
+++ b/frontend/src/pages/pam/PamAccountAccessPage/AwsIamAccessContent.tsx
@@ -0,0 +1,196 @@
+import React, { useCallback, useRef, useState } from "react";
+import { Loader2, ShieldAlert, TriangleAlert } from "lucide-react";
+
+import { Button, Label, TextArea } from "@app/components/v3";
+import { apiRequest } from "@app/config/request";
+import { MfaSessionStatus, TMfaSessionStatusResponse } from "@app/hooks/api/mfaSession/types";
+import { PamPolicyType, TPamAccount, useAccessPamAccount } from "@app/hooks/api/pam";
+
+import { WebAccessStatusCard } from "./WebAccessStatusCard";
+
+const resolvePolicy = (account: TPamAccount) => {
+ const policies = (account.templatePolicies ?? {}) as Record<string, unknown>;
+ return {
+ requireReason: policies[PamPolicyType.RequireReason] === true
+ };
+};
+
+const MFA_POLL_INTERVAL = 2000;
+const MFA_TIMEOUT = 5 * 60 * 1000;
+
+type Props = {
+ account: TPamAccount;
+};
+
+export const AwsIamAccessContent = ({ account }: Props) => {
+ const accessPamAccount = useAccessPamAccount();
+
+ const [step, setStep] = useState<"reason" | "mfa" | "loading" | "error">("reason");
+ const [reason, setReason] = useState("");
+ const [errorMessage, setErrorMessage] = useState<string | null>(null);
+
+ const hasRequestedRef = useRef(false);
+ const popupRef = useRef<Window | null>(null);
+
+ const policy = resolvePolicy(account);
+
+ const callAccess = useCallback(
+ async (mfaSessionId?: string) => {
+ if (!account.folderName) {
+ setErrorMessage("Account folder name is missing");
+ setStep("error");
+ return;
+ }
+
+ setStep("loading");
+
+ try {
+ const response = await accessPamAccount.mutateAsync({
+ path: `${account.folderName}/${account.name}`,
+ reason: reason.trim() || undefined,
+ accessMethod: "web",
+ mfaSessionId
+ });
+
+ const consoleUrl = response.metadata?.consoleUrl;
+ if (!consoleUrl) {
+ setErrorMessage("Backend did not return a console URL");
+ setStep("error");
+ return;
+ }
+
+ popupRef.current?.close();
+ window.location.href = consoleUrl;
+ } catch (err: unknown) {
+ const axiosErr = err as {
+ response?: {
+ data?: {
+ error?: string;
+ message?: string;
+ details?: { mfaSessionId?: string };
+ };
+ };
+ };
+
+ if (axiosErr?.response?.data?.error === "SESSION_MFA_REQUIRED") {
+ const mfaSid = axiosErr.response!.data!.details?.mfaSessionId;
+ if (mfaSid) {
+ setStep("mfa");
+ const mfaUrl = `${window.location.origin}/mfa-session/${mfaSid}`;
+ popupRef.current = window.open(mfaUrl, "_blank");
+
+ const startTime = Date.now();
+ const pollInterval = window.setInterval(async () => {
+ try {
+ if (Date.now() - startTime > MFA_TIMEOUT) {
+ window.clearInterval(pollInterval);
+ setErrorMessage("MFA verification timed out");
+ setStep("error");
+ return;
+ }
+ const resp = await apiRequest.get<TMfaSessionStatusResponse>(
+ `/api/v2/mfa-sessions/${mfaSid}/status`
+ );
+ if (resp.data.status === MfaSessionStatus.ACTIVE) {
+ window.clearInterval(pollInterval);
+ await callAccess(mfaSid);
+ }
+ } catch {
+ window.clearInterval(pollInterval);
+ setErrorMessage("MFA verification failed");
+ setStep("error");
+ }
+ }, MFA_POLL_INTERVAL);
+ return;
+ }
+ }
+
+ setErrorMessage(axiosErr?.response?.data?.message ?? "Failed to access AWS Console");
+ setStep("error");
+ }
+ },
+ [account.folderName, account.name, reason, accessPamAccount]
+ );
+
+ const handleReasonSubmit = useCallback(() => {
+ if (policy.requireReason && !reason.trim()) return;
+ if (hasRequestedRef.current) return;
+ hasRequestedRef.current = true;
+ callAccess();
+ }, [policy.requireReason, reason, callAccess]);
+
+ if (step === "error") {
+ return (
+ <WebAccessStatusCard
+ tone="danger"
+ icon={TriangleAlert}
+ title="Access Failed"
+ description={errorMessage ?? "An unknown error occurred"}
+ >
+ <Button
+ variant="pam"
+ isFullWidth
+ onClick={() => {
+ hasRequestedRef.current = false;
+ setErrorMessage(null);
+ setStep("reason");
+ }}
+ >
+ Try Again
+ </Button>
+ </WebAccessStatusCard>
+ );
+ }
+
+ if (step === "reason" && (policy.requireReason || !hasRequestedRef.current)) {
+ return (
+ <WebAccessStatusCard icon={ShieldAlert} title="Before You Continue">
+ <div className="flex flex-col gap-3">
+ <div>
+ <Label className="mb-1 text-label">
+ {policy.requireReason ? "Reason (required)" : "Reason (optional)"}
+ </Label>
+ <TextArea
+ value={reason}
+ onChange={(e: React.ChangeEvent<HTMLTextAreaElement>) => setReason(e.target.value)}
+ placeholder="Why do you need access?"
+ rows={3}
+ maxLength={1000}
+ />
+ </div>
+ <Button
+ variant="pam"
+ isFullWidth
+ onClick={handleReasonSubmit}
+ disabled={policy.requireReason && !reason.trim()}
+ >
+ {!policy.requireReason && !reason.trim() ? "Skip & Continue" : "Continue"}
+ </Button>
+ </div>
+ </WebAccessStatusCard>
+ );
+ }
+
+ if (step === "mfa") {
+ return (
+ <WebAccessStatusCard
+ icon={ShieldAlert}
+ title="MFA Verification"
+ description="Complete multi-factor authentication in the popup window."
+ >
+ <div className="flex items-center justify-center py-4">
+ <Loader2 className="size-6 animate-spin text-product-pam" />
+ </div>
+ </WebAccessStatusCard>
+ );
+ }
+
+ return (
+ <div className="flex h-dvh w-screen items-center justify-center bg-background p-4">
+ <div className="flex flex-col items-center gap-3 text-center">
+ <Loader2 className="size-8 animate-spin text-product-pam" />
+ <p className="text-sm font-medium text-foreground">Connecting to AWS...</p>
+ </div>
+ </div>
+ );
+};
diff --git a/frontend/src/pages/pam/PamAccountAccessPage/PamAccountAccessPage.tsx b/frontend/src/pages/pam/PamAccountAccessPage/PamAccountAccessPage.tsx
index e47be05599..8d7ada6c6b 100644
--- a/frontend/src/pages/pam/PamAccountAccessPage/PamAccountAccessPage.tsx
+++ b/frontend/src/pages/pam/PamAccountAccessPage/PamAccountAccessPage.tsx
@@ -6,6 +6,7 @@ import { TriangleAlert } from "lucide-react";
import { PamAccountType, TPamAccount, useGetPamAccountById } from "@app/hooks/api/pam";
import { PamDataExplorerPage } from "@app/pages/pam/PamDataExplorerPage/PamDataExplorerPage";
+import { AwsIamAccessContent } from "./AwsIamAccessContent";
import { DisconnectedScreen } from "./DisconnectedScreen";
import { RdpLauncher } from "./RdpLauncher";
import { SessionAccessGate } from "./ReasonGate";
@@ -111,6 +112,10 @@ const PageContent = () => {
);
}
+ if (account.accountType === PamAccountType.AwsIam) {
+ return <AwsIamAccessContent account={account} />;
+ }
+
if (account.accountType === PamAccountType.SSH) {
return <TerminalContent account={account} />;
}
diff --git a/frontend/src/pages/pam/PamAccountsPage/components/AccountDetailSheet.tsx b/frontend/src/pages/pam/PamAccountsPage/components/AccountDetailSheet.tsx
index 2f5c7f0a55..895a5b1102 100644
--- a/frontend/src/pages/pam/PamAccountsPage/components/AccountDetailSheet.tsx
+++ b/frontend/src/pages/pam/PamAccountsPage/components/AccountDetailSheet.tsx
@@ -493,6 +493,9 @@ const SettingsTab = ({
const [showGatewayPicker, setShowGatewayPicker] = useState(false);
const [showRecordingPicker, setShowRecordingPicker] = useState(false);
+ const { map: settingsTypeMap } = usePamAccountTypeMap();
+ const showGatewaySection =
+ settingsTypeMap[account?.accountType as PamAccountType]?.requiresGateway !== false;
const showRecordingOverride = account && accountTypeRequiresRecording(account.accountType);
const {
@@ -657,55 +660,62 @@ const SettingsTab = ({
<CardDescription>System configuration overrides.</CardDescription>
</CardHeader>
<CardContent className="flex flex-col gap-4">
- <div
- className={`rounded-md border p-4 ${isGatewayOverriding ? "border-product-pam/50" : "border-border"}`}
- >
- <div className="flex items-start justify-between gap-4">
- <div className="flex items-start gap-3">
- <div className="flex size-9 shrink-0 items-center justify-center rounded-md border border-border bg-container">
- <Network className="size-4 text-muted" />
- </div>
- <div>
- <p className="font-medium text-foreground">
- Gateway
- {isGatewayOverriding && (
- <span className="ml-2 text-xs font-normal text-product-pam">(override)</span>
- )}
- </p>
- <p className="text-sm text-muted">
- {isGatewayOverriding
- ? `Overriding the template default (${inheritedGatewayLabel}) for this account.`
- : `Inherited from ${account.templateName}: ${inheritedGatewayLabel}`}
- </p>
+ {!showGatewaySection && !showRecordingOverride && (
+ <p className="text-sm text-muted">No settings available for this account type.</p>
+ )}
+ {showGatewaySection && (
+ <div
+ className={`rounded-md border p-4 ${isGatewayOverriding ? "border-product-pam/50" : "border-border"}`}
+ >
+ <div className="flex items-start justify-between gap-4">
+ <div className="flex items-start gap-3">
+ <div className="flex size-9 shrink-0 items-center justify-center rounded-md border border-border bg-container">
+ <Network className="size-4 text-muted" />
+ </div>
+ <div>
+ <p className="font-medium text-foreground">
+ Gateway
+ {isGatewayOverriding && (
+ <span className="ml-2 text-xs font-normal text-product-pam">
+ (override)
+ </span>
+ )}
+ </p>
+ <p className="text-sm text-muted">
+ {isGatewayOverriding
+ ? `Overriding the template default (${inheritedGatewayLabel}) for this account.`
+ : `Inherited from ${account.templateName}: ${inheritedGatewayLabel}`}
+ </p>
+ </div>
</div>
+ {isGatewayOverriding ? (
+ <Button type="button" size="sm" variant="ghost" onClick={removeGatewayOverride}>
+ Remove Override
+ </Button>
+ ) : (
+ <Button
+ type="button"
+ size="sm"
+ variant="outline"
+ onClick={() => setShowGatewayPicker(true)}
+ >
+ <SquarePen className="mr-1.5 size-3.5" />
+ Override
+ </Button>
+ )}
</div>
- {isGatewayOverriding ? (
- <Button type="button" size="sm" variant="ghost" onClick={removeGatewayOverride}>
- Remove Override
- </Button>
- ) : (
- <Button
- type="button"
- size="sm"
- variant="outline"
- onClick={() => setShowGatewayPicker(true)}
- >
- <SquarePen className="mr-1.5 size-3.5" />
- Override
- </Button>
+
+ {isGatewayOverriding && (
+ <div className="mt-4">
+ <GatewayPicker
+ value={{ gatewayId, gatewayPoolId }}
+ onChange={setGateway}
+ isRequired
+ />
+ </div>
)}
</div>
-
- {isGatewayOverriding && (
- <div className="mt-4">
- <GatewayPicker
- value={{ gatewayId, gatewayPoolId }}
- onChange={setGateway}
- isRequired
- />
- </div>
- )}
- </div>
+ )}
{showRecordingOverride && (
<div
diff --git a/frontend/src/pages/pam/PamAccountsPage/components/CreateAccountSheet.tsx b/frontend/src/pages/pam/PamAccountsPage/components/CreateAccountSheet.tsx
index 3e4a85910b..45a81cc3db 100644
--- a/frontend/src/pages/pam/PamAccountsPage/components/CreateAccountSheet.tsx
+++ b/frontend/src/pages/pam/PamAccountsPage/components/CreateAccountSheet.tsx
@@ -120,7 +120,10 @@ export const CreateAccountSheet = ({ isOpen, onOpenChange, defaultFolderId }: Pr
const selectedMetadata = accountTypes.find((t) => t.type === selectedTemplate?.type);
const needsGateway = Boolean(
- selectedTemplate && !selectedTemplate.gatewayId && !selectedTemplate.gatewayPoolId
+ selectedMetadata?.requiresGateway !== false &&
+ selectedTemplate &&
+ !selectedTemplate.gatewayId &&
+ !selectedTemplate.gatewayPoolId
);
const needsRecording = Boolean(
selectedTemplate &&
diff --git a/frontend/src/pages/pam/PamTemplatesPage/components/TemplateDetailSheet.tsx b/frontend/src/pages/pam/PamTemplatesPage/components/TemplateDetailSheet.tsx
index 5f957a74bb..27e3358947 100644
--- a/frontend/src/pages/pam/PamTemplatesPage/components/TemplateDetailSheet.tsx
+++ b/frontend/src/pages/pam/PamTemplatesPage/components/TemplateDetailSheet.tsx
@@ -282,6 +282,7 @@ const SettingsTab = ({
const policies = watch("policies");
const storageBackend = watch("recordingStorageBackend");
const requiresRecording = accountTypeRequiresRecording(template.type);
+ const showGatewaySettings = accountTypeMap[template.type]?.requiresGateway !== false;
const typeName = accountTypeMap[template.type]?.name ?? template.type;
const applicablePolicies = (accountTypeMap[template.type]?.applicablePolicies ?? []).filter(
(p) => POLICY_EDITORS[p.key]
@@ -409,193 +410,199 @@ const SettingsTab = ({
</Card>
)}
- <Card>
- <CardHeader className="border-b">
- <CardTitle className="text-base">System Settings</CardTitle>
- <CardDescription>System-level defaults for accounts using this template.</CardDescription>
- </CardHeader>
- <CardContent className="flex flex-col gap-6">
- <Field>
- <FieldLabel>Gateway</FieldLabel>
- <FieldContent>
- <GatewayPicker
- value={{ gatewayId, gatewayPoolId }}
- onChange={(value) => {
- setValue("gatewayId", value.gatewayId, { shouldDirty: true });
- setValue("gatewayPoolId", value.gatewayPoolId, { shouldDirty: true });
- }}
- noGatewayLabel="No Gateway"
- noGatewayIcon={Ban}
- />
- <FieldDescription>
- Used to reach accounts unless overridden on the account.
- </FieldDescription>
- </FieldContent>
- </Field>
- </CardContent>
- </Card>
-
- <Card>
- <CardHeader className="border-b">
- <CardTitle className="text-base">Session Recording</CardTitle>
- <CardDescription>
- Where session recordings for accounts using this template are stored.
- </CardDescription>
- </CardHeader>
- <CardContent className="flex flex-col gap-6">
- <Controller
- name="recordingStorageBackend"
- control={control}
- render={({ field }) => (
- <Field>
- <FieldLabel>Storage backend</FieldLabel>
- <FieldContent>
- <Select value={field.value} onValueChange={(v) => field.onChange(v)}>
- <SelectTrigger className="w-full">
- <SelectValue />
- </SelectTrigger>
- <SelectContent position="popper">
- <SelectItem value="postgres">Internal Database</SelectItem>
- <SelectItem value="aws-s3">AWS S3</SelectItem>
- </SelectContent>
- </Select>
- </FieldContent>
- </Field>
- )}
- />
+ {showGatewaySettings && (
+ <Card>
+ <CardHeader className="border-b">
+ <CardTitle className="text-base">System Settings</CardTitle>
+ <CardDescription>
+ System-level defaults for accounts using this template.
+ </CardDescription>
+ </CardHeader>
+ <CardContent className="flex flex-col gap-6">
+ <Field>
+ <FieldLabel>Gateway</FieldLabel>
+ <FieldContent>
+ <GatewayPicker
+ value={{ gatewayId, gatewayPoolId }}
+ onChange={(value) => {
+ setValue("gatewayId", value.gatewayId, { shouldDirty: true });
+ setValue("gatewayPoolId", value.gatewayPoolId, { shouldDirty: true });
+ }}
+ noGatewayLabel="No Gateway"
+ noGatewayIcon={Ban}
+ />
+ <FieldDescription>
+ Used to reach accounts unless overridden on the account.
+ </FieldDescription>
+ </FieldContent>
+ </Field>
+ </CardContent>
+ </Card>
+ )}
- {requiresRecording && storageBackend === "postgres" && (
- <Alert variant="warning">
- <AlertTriangleIcon />
- <AlertTitle>Accounts cannot be launched</AlertTitle>
- <AlertDescription>
- {typeName} accounts require an external recording storage backend. Accounts using
- this template can still be created, but sessions can&apos;t be launched until
- external storage is configured.
- </AlertDescription>
- </Alert>
- )}
-
- {storageBackend === "aws-s3" && (
- <>
+ {showGatewaySettings && (
+ <Card>
+ <CardHeader className="border-b">
+ <CardTitle className="text-base">Session Recording</CardTitle>
+ <CardDescription>
+ Where session recordings for accounts using this template are stored.
+ </CardDescription>
+ </CardHeader>
+ <CardContent className="flex flex-col gap-6">
+ <Controller
+ name="recordingStorageBackend"
+ control={control}
+ render={({ field }) => (
+ <Field>
+ <FieldLabel>Storage backend</FieldLabel>
+ <FieldContent>
+ <Select value={field.value} onValueChange={(v) => field.onChange(v)}>
+ <SelectTrigger className="w-full">
+ <SelectValue />
+ </SelectTrigger>
+ <SelectContent position="popper">
+ <SelectItem value="postgres">Internal Database</SelectItem>
+ <SelectItem value="aws-s3">AWS S3</SelectItem>
+ </SelectContent>
+ </Select>
+ </FieldContent>
+ </Field>
+ )}
+ />
+
+ {requiresRecording && storageBackend === "postgres" && (
<Alert variant="warning">
<AlertTriangleIcon />
- <AlertTitle>Changing bucket affects existing recordings</AlertTitle>
+ <AlertTitle>Accounts cannot be launched</AlertTitle>
<AlertDescription>
- Changing the bucket on a template with existing recordings makes those recordings
- inaccessible unless you manually migrate each object. Keep the same bucket and key
- prefix when rotating credentials.
+ {typeName} accounts require an external recording storage backend. Accounts using
+ this template can still be created, but sessions can&apos;t be launched until
+ external storage is configured.
</AlertDescription>
</Alert>
+ )}
- <Controller
- name="recordingConnectionId"
- control={control}
- render={({ field, fieldState }) => (
- <Field>
- <FieldLabel>AWS Connection</FieldLabel>
- <FieldContent>
- <Select
- value={field.value ?? ""}
- onValueChange={(v) => field.onChange(v || null)}
- >
- <SelectTrigger className="w-full" isError={!!fieldState.error}>
- <SelectValue placeholder="Select an AWS connection" />
- </SelectTrigger>
- <SelectContent position="popper">
- {awsConnections.map((conn) => (
- <SelectItem key={conn.id} value={conn.id}>
- {conn.name}
- </SelectItem>
- ))}
- </SelectContent>
- </Select>
- {fieldState.error ? (
- <FieldError>{fieldState.error.message}</FieldError>
- ) : (
- <FieldDescription>
- The AWS connection used to authenticate with S3.
- </FieldDescription>
- )}
- </FieldContent>
- </Field>
- )}
- />
-
- <Controller
- name="s3Bucket"
- control={control}
- render={({ field, fieldState }) => (
- <Field>
- <FieldLabel>S3 Bucket</FieldLabel>
- <FieldContent>
- <Input
- {...field}
- placeholder="my-recordings-bucket"
- isError={!!fieldState.error}
- />
- <FieldError>{fieldState.error?.message}</FieldError>
- </FieldContent>
- </Field>
- )}
- />
-
- <Controller
- name="s3Region"
- control={control}
- render={({ field }) => (
- <Field>
- <FieldLabel>Region</FieldLabel>
- <FieldContent>
- <Input {...field} placeholder="us-east-1" />
- </FieldContent>
- </Field>
- )}
- />
-
- <Controller
- name="s3KeyPrefix"
- control={control}
- render={({ field }) => (
- <Field>
- <FieldLabel>Key prefix (optional)</FieldLabel>
- <FieldContent>
- <Input {...field} placeholder="pam-recordings/" />
- <FieldDescription>Optional prefix for S3 object keys.</FieldDescription>
- </FieldContent>
- </Field>
- )}
- />
- </>
- )}
+ {storageBackend === "aws-s3" && (
+ <>
+ <Alert variant="warning">
+ <AlertTriangleIcon />
+ <AlertTitle>Changing bucket affects existing recordings</AlertTitle>
+ <AlertDescription>
+ Changing the bucket on a template with existing recordings makes those
+ recordings inaccessible unless you manually migrate each object. Keep the same
+ bucket and key prefix when rotating credentials.
+ </AlertDescription>
+ </Alert>
+
+ <Controller
+ name="recordingConnectionId"
+ control={control}
+ render={({ field, fieldState }) => (
+ <Field>
+ <FieldLabel>AWS Connection</FieldLabel>
+ <FieldContent>
+ <Select
+ value={field.value ?? ""}
+ onValueChange={(v) => field.onChange(v || null)}
+ >
+ <SelectTrigger className="w-full" isError={!!fieldState.error}>
+ <SelectValue placeholder="Select an AWS connection" />
+ </SelectTrigger>
+ <SelectContent position="popper">
+ {awsConnections.map((conn) => (
+ <SelectItem key={conn.id} value={conn.id}>
+ {conn.name}
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
+ {fieldState.error ? (
+ <FieldError>{fieldState.error.message}</FieldError>
+ ) : (
+ <FieldDescription>
+ The AWS connection used to authenticate with S3.
+ </FieldDescription>
+ )}
+ </FieldContent>
+ </Field>
+ )}
+ />
- <Controller
- control={control}
- name="settings.sessionLogMaskingPatterns"
- render={({ field, fieldState }) => (
- <Field>
- <FieldLabel>Session Log Masking</FieldLabel>
- <FieldContent>
- <TextArea
- rows={5}
- placeholder={"rm\\s+-rf.*\npassword\\s*=\\s*\\S+\n\\b\\d{3}-\\d{2}-\\d{4}\\b"}
- value={field.value ?? ""}
- isError={!!fieldState.error}
- onChange={(e) => {
- const val = e.target.value;
- field.onChange(val.trim() ? val : "");
- }}
- />
- <FieldDescription>
- Matching content in session recordings will be masked (one regex per line).
- </FieldDescription>
- <FieldError>{fieldState.error?.message}</FieldError>
- </FieldContent>
- </Field>
+ <Controller
+ name="s3Bucket"
+ control={control}
+ render={({ field, fieldState }) => (
+ <Field>
+ <FieldLabel>S3 Bucket</FieldLabel>
+ <FieldContent>
+ <Input
+ {...field}
+ placeholder="my-recordings-bucket"
+ isError={!!fieldState.error}
+ />
+ <FieldError>{fieldState.error?.message}</FieldError>
+ </FieldContent>
+ </Field>
+ )}
+ />
+
+ <Controller
+ name="s3Region"
+ control={control}
+ render={({ field }) => (
+ <Field>
+ <FieldLabel>Region</FieldLabel>
+ <FieldContent>
+ <Input {...field} placeholder="us-east-1" />
+ </FieldContent>
+ </Field>
+ )}
+ />
+
+ <Controller
+ name="s3KeyPrefix"
+ control={control}
+ render={({ field }) => (
+ <Field>
+ <FieldLabel>Key prefix (optional)</FieldLabel>
+ <FieldContent>
+ <Input {...field} placeholder="pam-recordings/" />
+ <FieldDescription>Optional prefix for S3 object keys.</FieldDescription>
+ </FieldContent>
+ </Field>
+ )}
+ />
+ </>
)}
- />
- </CardContent>
- </Card>
+
+ <Controller
+ control={control}
+ name="settings.sessionLogMaskingPatterns"
+ render={({ field, fieldState }) => (
+ <Field>
+ <FieldLabel>Session Log Masking</FieldLabel>
+ <FieldContent>
+ <TextArea
+ rows={5}
+ placeholder={"rm\\s+-rf.*\npassword\\s*=\\s*\\S+\n\\b\\d{3}-\\d{2}-\\d{4}\\b"}
+ value={field.value ?? ""}
+ isError={!!fieldState.error}
+ onChange={(e) => {
+ const val = e.target.value;
+ field.onChange(val.trim() ? val : "");
+ }}
+ />
+ <FieldDescription>
+ Matching content in session recordings will be masked (one regex per line).
+ </FieldDescription>
+ <FieldError>{fieldState.error?.message}</FieldError>
+ </FieldContent>
+ </Field>
+ )}
+ />
+ </CardContent>
+ </Card>
+ )}
<div aria-hidden className="h-8 shrink-0" />
{isDirty && <SheetSaveBar isPending={updateTemplate.isPending} onDiscard={() => reset()} />}