Skip to content

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

Allow incomplete PAM account setup

bernie-gb21e1fe190b8
diff --git a/backend/src/db/migrations/20260619144500_pam-account-settings-overrides.ts b/backend/src/db/migrations/20260619144500_pam-account-recording-settings.ts
similarity index 77%
rename from backend/src/db/migrations/20260619144500_pam-account-settings-overrides.ts
rename to backend/src/db/migrations/20260619144500_pam-account-recording-settings.ts
index aee337ab1e..98a16e475d 100644
--- a/backend/src/db/migrations/20260619144500_pam-account-settings-overrides.ts
+++ b/backend/src/db/migrations/20260619144500_pam-account-recording-settings.ts
@@ -3,19 +3,19 @@ import { Knex } from "knex";
import { TableName } from "../schemas";
export async function up(knex: Knex): Promise<void> {
- const hasColumn = await knex.schema.hasColumn(TableName.PamAccount, "settingsOverrides");
+ const hasColumn = await knex.schema.hasColumn(TableName.PamAccount, "recordingSettings");
if (!hasColumn) {
await knex.schema.alterTable(TableName.PamAccount, (t) => {
- t.jsonb("settingsOverrides").nullable();
+ t.jsonb("recordingSettings").nullable();
});
}
}
export async function down(knex: Knex): Promise<void> {
- const hasColumn = await knex.schema.hasColumn(TableName.PamAccount, "settingsOverrides");
+ const hasColumn = await knex.schema.hasColumn(TableName.PamAccount, "recordingSettings");
if (hasColumn) {
await knex.schema.alterTable(TableName.PamAccount, (t) => {
- t.dropColumn("settingsOverrides");
+ t.dropColumn("recordingSettings");
});
}
}
diff --git a/backend/src/db/migrations/20260623144800_pam-account-settings-overrides.ts b/backend/src/db/migrations/20260623144800_pam-account-settings-overrides.ts
new file mode 100644
index 0000000000..02b4d4bd35
--- /dev/null
+++ b/backend/src/db/migrations/20260623144800_pam-account-settings-overrides.ts
@@ -0,0 +1,39 @@
+import { Knex } from "knex";
+
+import { TableName } from "../schemas";
+
+export async function up(knex: Knex): Promise<void> {
+ const hasRecordingSettings = await knex.schema.hasColumn(TableName.PamAccount, "recordingSettings");
+ const hasSettingsOverrides = await knex.schema.hasColumn(TableName.PamAccount, "settingsOverrides");
+
+ if (hasRecordingSettings && !hasSettingsOverrides) {
+ await knex.schema.alterTable(TableName.PamAccount, (t) => {
+ t.renameColumn("recordingSettings", "settingsOverrides");
+ });
+ return;
+ }
+
+ if (!hasSettingsOverrides) {
+ await knex.schema.alterTable(TableName.PamAccount, (t) => {
+ t.jsonb("settingsOverrides").nullable();
+ });
+ }
+}
+
+export async function down(knex: Knex): Promise<void> {
+ const hasRecordingSettings = await knex.schema.hasColumn(TableName.PamAccount, "recordingSettings");
+ const hasSettingsOverrides = await knex.schema.hasColumn(TableName.PamAccount, "settingsOverrides");
+
+ if (hasSettingsOverrides && !hasRecordingSettings) {
+ await knex.schema.alterTable(TableName.PamAccount, (t) => {
+ t.renameColumn("settingsOverrides", "recordingSettings");
+ });
+ return;
+ }
+
+ if (hasSettingsOverrides) {
+ await knex.schema.alterTable(TableName.PamAccount, (t) => {
+ t.dropColumn("settingsOverrides");
+ });
+ }
+}
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 2574c5dbb9..80d478f251 100644
--- a/backend/src/ee/services/pam-account/pam-account-dal.ts
+++ b/backend/src/ee/services/pam-account/pam-account-dal.ts
@@ -6,6 +6,7 @@ import { sanitizeSqlLikeString } from "@app/lib/fn";
import { ormify } from "@app/lib/knex";
import { PamAccountType } from "../pam/pam-enums";
+import { PamRecordingStorageBackend } from "../pam-session-recording/pam-recording-enums";
export const accountAccessibilitySql = (accountTable: string, templateTable: string): string =>
`(
@@ -13,8 +14,15 @@ export const accountAccessibilitySql = (accountTable: string, templateTable: str
or "${templateTable}"."gatewayId" is not null or "${templateTable}"."gatewayPoolId" is not null)
and "${accountTable}"."credentialConfigured" = true
and ("${templateTable}"."type" != '${PamAccountType.Windows}'
- or "${accountTable}"."recordingConnectionId" is not null
- or "${templateTable}"."recordingConnectionId" is not null)
+ or (
+ "${templateTable}"."settings"->>'recordingStorageBackend' = '${PamRecordingStorageBackend.AwsS3}'
+ and ("${accountTable}"."recordingConnectionId" is not null
+ or "${templateTable}"."recordingConnectionId" is not null)
+ and coalesce(
+ "${accountTable}"."settingsOverrides"->'recordingS3Config',
+ "${templateTable}"."settings"->'recordingS3Config'
+ ) is not null
+ ))
)`;
type TPamAccountTemplateInheritedFields = {
@@ -22,6 +30,7 @@ type TPamAccountTemplateInheritedFields = {
templateGatewayId: string | null;
templateGatewayPoolId: string | null;
templateRecordingConnectionId: string | null;
+ templateSettings: unknown;
};
export type TPamAccountListItem = Pick<
@@ -35,6 +44,7 @@ export type TPamAccountListItem = Pick<
| "gatewayId"
| "gatewayPoolId"
| "recordingConnectionId"
+ | "settingsOverrides"
| "createdAt"
| "updatedAt"
> &
@@ -121,11 +131,13 @@ export const pamAccountDALFactory = (db: TDbClient) => {
`${TableName.PamAccount}.gatewayId`,
`${TableName.PamAccount}.gatewayPoolId`,
`${TableName.PamAccount}.recordingConnectionId`,
+ `${TableName.PamAccount}.settingsOverrides`,
`${TableName.PamAccount}.credentialConfigured`,
`${TableName.PamAccount}.createdAt`,
`${TableName.PamAccount}.updatedAt`,
`${TableName.PamAccountTemplate}.type as accountType`,
`${TableName.PamAccountTemplate}.name as templateName`,
+ `${TableName.PamAccountTemplate}.settings as templateSettings`,
`${TableName.PamAccountTemplate}.gatewayId as templateGatewayId`,
`${TableName.PamAccountTemplate}.gatewayPoolId as templateGatewayPoolId`,
`${TableName.PamAccountTemplate}.recordingConnectionId as templateRecordingConnectionId`,
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 8229617d1a..a98a9958bf 100644
--- a/backend/src/ee/services/pam-account/pam-account-service.ts
+++ b/backend/src/ee/services/pam-account/pam-account-service.ts
@@ -36,7 +36,9 @@ import {
validateRecordingS3Config
} from "../pam/pam-validators";
import { TPamAccountTemplateDALFactory } from "../pam-account-template/pam-account-template-dal";
+import { PamTemplateSettingsSchema } from "../pam-account-template/pam-account-template-schemas";
import { TPamFolderDALFactory } from "../pam-folder/pam-folder-dal";
+import { PamRecordingStorageBackend } from "../pam-session-recording/pam-recording-enums";
import { TPamAccountDALFactory } from "./pam-account-dal";
import {
getAccountAccessibilityIssues,
@@ -106,12 +108,23 @@ export const pamAccountServiceFactory = (deps: TPamAccountServiceFactoryDep) =>
templateGatewayId: string | null;
templateGatewayPoolId: string | null;
templateRecordingConnectionId: string | null;
+ settingsOverrides?: unknown;
+ templateSettings: unknown;
credentialConfigured: boolean;
}) => {
+ const settingsParsed = PamTemplateSettingsSchema.safeParse(a.templateSettings);
+ const templateSettings = settingsParsed.success ? settingsParsed.data : null;
+ const accountSettingsOverrides = (a.settingsOverrides ?? {}) as { recordingS3Config?: unknown };
+ const hasRecordingConfig = Boolean(
+ templateSettings?.recordingStorageBackend === PamRecordingStorageBackend.AwsS3 &&
+ (a.recordingConnectionId || a.templateRecordingConnectionId) &&
+ (accountSettingsOverrides.recordingS3Config || templateSettings.recordingS3Config)
+ );
+
const accessibilityIssues = getAccountAccessibilityIssues({
accountType: a.accountType as PamAccountType,
hasGateway: Boolean(a.gatewayId || a.gatewayPoolId || a.templateGatewayId || a.templateGatewayPoolId),
- hasRecordingConfig: Boolean(a.recordingConnectionId || a.templateRecordingConnectionId),
+ hasRecordingConfig,
credentialConfigured: a.credentialConfigured
});
return { isAccessible: accessibilityIssues.length === 0, accessibilityIssues };
@@ -242,16 +255,6 @@ export const pamAccountServiceFactory = (deps: TPamAccountServiceFactoryDep) =>
});
}
- if (accountType === PamAccountType.Windows) {
- const settings = (template.settings ?? {}) as Record<string, unknown>;
- if (settings.recordingStorageBackend !== "aws-s3" || !template.recordingConnectionId) {
- throw new BadRequestError({
- message:
- "Cannot create a Windows account until the account template has S3 recording fully configured (storage backend, AWS connection, and S3 bucket)"
- });
- }
- }
-
await validateGatewayAttachment(deps, gatewayId, gatewayPoolId, ctx);
await validateRecordingConnection(deps, recordingConnectionId, ctx);
diff --git a/frontend/src/pages/pam/PamAccountsPage/components/CreateAccountSheet.tsx b/frontend/src/pages/pam/PamAccountsPage/components/CreateAccountSheet.tsx
index 8283299255..3e4a85910b 100644
--- a/frontend/src/pages/pam/PamAccountsPage/components/CreateAccountSheet.tsx
+++ b/frontend/src/pages/pam/PamAccountsPage/components/CreateAccountSheet.tsx
@@ -457,8 +457,8 @@ export const CreateAccountSheet = ({ isOpen, onOpenChange, defaultFolderId }: Pr
<div className="text-sm">
<p className="font-medium text-warning">S3 recording not configured</p>
<p className="mt-1 text-muted">
- This account type requires S3 recording. Configure it in the account
- template settings before creating an account.
+ This account will be created, but it will remain inaccessible until S3
+ recording is configured on the account or template.
</p>
</div>
</div>
@@ -479,12 +479,7 @@ export const CreateAccountSheet = ({ isOpen, onOpenChange, defaultFolderId }: Pr
<Button type="button" variant="ghost" onClick={() => setStep(1)}>
Back
</Button>
- <Button
- type="submit"
- variant="pam"
- isPending={createAccount.isPending}
- isDisabled={needsRecording}
- >
+ <Button type="submit" variant="pam" isPending={createAccount.isPending}>
Create
</Button>
</SheetFooter>