Skip to content

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

feat(pam): supporting changes for tf 388

Andrey9ccacab89350
diff --git a/frontend/src/hooks/api/pam/enums.ts b/frontend/src/hooks/api/pam/enums.ts
index a4a3773107..a376336c4d 100644
--- a/frontend/src/hooks/api/pam/enums.ts
+++ b/frontend/src/hooks/api/pam/enums.ts
@@ -87,18 +87,34 @@ export const PAM_ROTATION_INTERVAL_OPTIONS: { seconds: number; label: string }[]
{ seconds: 2592000, label: "30 days" }
];
+const INTERVAL_UNITS = [
+ { size: 86400, unit: "day" },
+ { size: 3600, unit: "hour" },
+ { size: 60, unit: "minute" }
+];
+
export const formatRotationInterval = (seconds: number | null | undefined): string => {
if (seconds == null) return "Manual only";
const preset = PAM_ROTATION_INTERVAL_OPTIONS.find((option) => option.seconds === seconds);
if (preset) return preset.label;
- const hours = Math.round(seconds / 3600);
- if (hours % 24 === 0) {
- const days = hours / 24;
- return days === 1 ? "1 day" : `${days} days`;
- }
- return hours === 1 ? "1 hour" : `${hours} hours`;
+ const { size, unit } = INTERVAL_UNITS.find((u) => seconds % u.size === 0) ?? {
+ size: 1,
+ unit: "second"
+ };
+ const amount = seconds / size;
+ return `${amount} ${unit}${amount === 1 ? "" : "s"}`;
};
+// The API accepts any interval, so a saved one may not be a preset.
+export const getRotationIntervalOptions = (savedSeconds: number | null | undefined) =>
+ savedSeconds == null ||
+ PAM_ROTATION_INTERVAL_OPTIONS.some((option) => option.seconds === savedSeconds)
+ ? PAM_ROTATION_INTERVAL_OPTIONS
+ : [
+ ...PAM_ROTATION_INTERVAL_OPTIONS,
+ { seconds: savedSeconds, label: formatRotationInterval(savedSeconds) }
+ ].sort((a, b) => a.seconds - b.seconds);
+
export enum PamPolicyType {
RequiresApproval = "requires-approval",
AllowAutoApproval = "allow-auto-approval",
diff --git a/frontend/src/pages/pam/PamAccountsPage/PamFolderPage/PamFolderPage.tsx b/frontend/src/pages/pam/PamAccountsPage/PamFolderPage/PamFolderPage.tsx
index c634fb992e..0c7fe65d31 100644
--- a/frontend/src/pages/pam/PamAccountsPage/PamFolderPage/PamFolderPage.tsx
+++ b/frontend/src/pages/pam/PamAccountsPage/PamFolderPage/PamFolderPage.tsx
@@ -61,6 +61,7 @@ import { PamSheetTab, usePamSheetState } from "@app/hooks/usePamSheetState";
import { usePopUp } from "@app/hooks/usePopUp";
import { useSlashFocusSearch } from "@app/hooks/useSlashFocusSearch";
+import { CopyIdMenuItem } from "../../components/CopyIdMenuItem";
import { LaunchSessionSheet } from "../../components/LaunchSessionSheet";
import { PAM_FOLDER_TABS } from "../../components/pamResourceTabs";
import { RequestAccessSheet } from "../../components/RequestAccessSheet";
@@ -240,6 +241,7 @@ export const PamFolderPage = () => {
</IconButton>
</DropdownMenuTrigger>
<DropdownMenuContent align="start" sideOffset={4} className="min-w-48">
+ <CopyIdMenuItem id={folderId} />
<Tooltip>
<TooltipTrigger asChild>
<div>
diff --git a/frontend/src/pages/pam/PamAccountsPage/components/AccountActionsMenu.tsx b/frontend/src/pages/pam/PamAccountsPage/components/AccountActionsMenu.tsx
index 54a14c3e27..62462e3afd 100644
--- a/frontend/src/pages/pam/PamAccountsPage/components/AccountActionsMenu.tsx
+++ b/frontend/src/pages/pam/PamAccountsPage/components/AccountActionsMenu.tsx
@@ -19,9 +19,11 @@ import {
} from "@app/hooks/api/pam";
import { PamSheetTab } from "@app/hooks/usePamSheetState";
+import { CopyIdMenuItem } from "../../components/CopyIdMenuItem";
import { PAM_ACCOUNT_TABS } from "../../components/pamResourceTabs";
type Props = {
+ accountId: string;
can: (action: PamResourcePermissionActions) => boolean;
accountType: PamAccountType;
isAccessible: boolean;
@@ -39,6 +41,7 @@ type Props = {
};
export const AccountActionsMenu = ({
+ accountId,
can,
accountType,
isAccessible,
@@ -103,6 +106,7 @@ export const AccountActionsMenu = ({
</IconButton>
</DropdownMenuTrigger>
<DropdownMenuContent align="end" onClick={(e) => e.stopPropagation()}>
+ <CopyIdMenuItem id={accountId} />
{needsApproval ? (
<Tooltip>
<TooltipTrigger asChild>
diff --git a/frontend/src/pages/pam/PamAccountsPage/components/FolderAccountRow.tsx b/frontend/src/pages/pam/PamAccountsPage/components/FolderAccountRow.tsx
index 86c8a54ea3..cfa3e805a1 100644
--- a/frontend/src/pages/pam/PamAccountsPage/components/FolderAccountRow.tsx
+++ b/frontend/src/pages/pam/PamAccountsPage/components/FolderAccountRow.tsx
@@ -101,6 +101,7 @@ export const FolderAccountRow = ({
}
actions={
<AccountActionsMenu
+ accountId={account.id}
can={can}
accountType={accountType}
isAccessible={account.isAccessible}
diff --git a/frontend/src/pages/pam/PamAccountsPage/components/FolderActionsMenu.tsx b/frontend/src/pages/pam/PamAccountsPage/components/FolderActionsMenu.tsx
index e8f5b2c84c..45cbfbe864 100644
--- a/frontend/src/pages/pam/PamAccountsPage/components/FolderActionsMenu.tsx
+++ b/frontend/src/pages/pam/PamAccountsPage/components/FolderActionsMenu.tsx
@@ -20,6 +20,7 @@ import {
} from "@app/hooks/api/pam";
import { PamSheetTab } from "@app/hooks/usePamSheetState";
+import { CopyIdMenuItem } from "../../components/CopyIdMenuItem";
import { PAM_FOLDER_TABS } from "../../components/pamResourceTabs";
type Props = {
@@ -76,6 +77,7 @@ export const FolderActionsMenu = ({
</IconButton>
</DropdownMenuTrigger>
<DropdownMenuContent align="end" onClick={(e) => e.stopPropagation()}>
+ <CopyIdMenuItem id={folder.id} />
<Tooltip>
<TooltipTrigger asChild>
<div>
diff --git a/frontend/src/pages/pam/PamTemplatesPage/PamTemplatesPage.tsx b/frontend/src/pages/pam/PamTemplatesPage/PamTemplatesPage.tsx
index 5492e5b679..731b3ab856 100644
--- a/frontend/src/pages/pam/PamTemplatesPage/PamTemplatesPage.tsx
+++ b/frontend/src/pages/pam/PamTemplatesPage/PamTemplatesPage.tsx
@@ -52,6 +52,7 @@ import { PamSheetTab, usePamSheetState } from "@app/hooks/usePamSheetState";
import { usePopUp } from "@app/hooks/usePopUp";
import { AccountPlatformIcon } from "../components/AccountPlatformIcon";
+import { CopyIdMenuItem } from "../components/CopyIdMenuItem";
import { PAM_TEMPLATE_TABS } from "../components/pamResourceTabs";
import { PamDocsUrls } from "../pam-docs-urls";
import { CreateTemplateModal } from "./components/CreateTemplateModal";
@@ -102,6 +103,7 @@ const TemplateRow = ({
</IconButton>
</DropdownMenuTrigger>
<DropdownMenuContent align="end" sideOffset={4} onClick={(e) => e.stopPropagation()}>
+ <CopyIdMenuItem id={template.id} />
{PAM_TEMPLATE_TABS.map((tab) => (
<DropdownMenuItem
key={tab.value}
diff --git a/frontend/src/pages/pam/PamTemplatesPage/components/TemplateDetailSheet.tsx b/frontend/src/pages/pam/PamTemplatesPage/components/TemplateDetailSheet.tsx
index cc644a277c..86454efba0 100644
--- a/frontend/src/pages/pam/PamTemplatesPage/components/TemplateDetailSheet.tsx
+++ b/frontend/src/pages/pam/PamTemplatesPage/components/TemplateDetailSheet.tsx
@@ -42,9 +42,9 @@ import {
} from "@app/hooks/api/appConnections";
import {
accountTypeRequiresRecording,
+ getRotationIntervalOptions,
isRotatablePamAccountType,
maxGeneratedPasswordLength,
- PAM_ROTATION_INTERVAL_OPTIONS,
PamAccountType,
pamAccountTypeSupportsSessionLogMasking,
PamPolicyType,
@@ -410,6 +410,10 @@ const SettingsTab = ({
)?.app;
const rotationEnabled = watch("settings.rotationEnabled");
const heartbeatEnabled = watch("settings.heartbeatEnabled");
+ const savedSettings = (template.settings ?? {}) as {
+ rotation?: { intervalSeconds?: number | null };
+ heartbeat?: { intervalSeconds?: number | null };
+ };
const requiresRecording = accountTypeRequiresRecording(template.type);
const showGatewaySettings = accountTypeMap[template.type]?.requiresGateway !== false;
const supportsSessionLogMasking = pamAccountTypeSupportsSessionLogMasking(template.type);
@@ -736,11 +740,13 @@ const SettingsTab = ({
<SelectValue />
</SelectTrigger>
<SelectContent position="popper">
- {PAM_ROTATION_INTERVAL_OPTIONS.map((option) => (
- <SelectItem key={option.seconds} value={String(option.seconds)}>
- {option.label}
- </SelectItem>
- ))}
+ {getRotationIntervalOptions(savedSettings.rotation?.intervalSeconds).map(
+ (option) => (
+ <SelectItem key={option.seconds} value={String(option.seconds)}>
+ {option.label}
+ </SelectItem>
+ )
+ )}
</SelectContent>
</Select>
<FieldDescription>
@@ -795,11 +801,13 @@ const SettingsTab = ({
<SelectValue />
</SelectTrigger>
<SelectContent position="popper">
- {PAM_ROTATION_INTERVAL_OPTIONS.map((option) => (
- <SelectItem key={option.seconds} value={String(option.seconds)}>
- {option.label}
- </SelectItem>
- ))}
+ {getRotationIntervalOptions(savedSettings.heartbeat?.intervalSeconds).map(
+ (option) => (
+ <SelectItem key={option.seconds} value={String(option.seconds)}>
+ {option.label}
+ </SelectItem>
+ )
+ )}
</SelectContent>
</Select>
<FieldDescription>
diff --git a/frontend/src/pages/pam/components/CopyIdMenuItem.tsx b/frontend/src/pages/pam/components/CopyIdMenuItem.tsx
new file mode 100644
index 0000000000..6458b030b1
--- /dev/null
+++ b/frontend/src/pages/pam/components/CopyIdMenuItem.tsx
@@ -0,0 +1,16 @@
+import { Copy } from "lucide-react";
+
+import { createNotification } from "@app/components/notifications";
+import { DropdownMenuItem } from "@app/components/v3";
+
+export const CopyIdMenuItem = ({ id }: { id: string }) => (
+ <DropdownMenuItem
+ onClick={async () => {
+ await navigator.clipboard.writeText(id);
+ createNotification({ type: "success", text: "ID copied to clipboard" });
+ }}
+ >
+ <Copy />
+ Copy ID
+ </DropdownMenuItem>
+);