Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
misc: addressed comments
Sheen Capadngand271d62ce41f
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.tsindex c50906bd50..089c08f2b7 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@@ -50,8 +50,7 @@ const SanitizedAccountListItemSchema = BaseAccountFields.extend({accountType: z.string()});-// The admin list surfaces accessibility and approval status so the UI can show appropriate actions-const AdminAccountListItemSchema = SanitizedAccountListItemSchema.extend({+const PamAccountListItemSchema = SanitizedAccountListItemSchema.extend({isAccessible: z.boolean().describe("Whether the account is fully provisioned to launch a session"),accessibilityIssues: z.array(z.nativeEnum(PamAccountAccessibilityIssue))@@ -354,7 +353,7 @@ export const registerPamAccountRouter = async (server: FastifyZodProvider) => {search: z.string().optional().describe("Filter accounts by name")}),response: {- 200: z.object({ accounts: z.array(AdminAccountListItemSchema) })+ 200: z.object({ accounts: z.array(PamAccountListItemSchema) })}},config: { rateLimit: readLimit },diff --git a/docs/documentation/platform/pam/accounts/aws-iam.mdx b/docs/documentation/platform/pam/accounts/aws-iam.mdxindex 1a93572136..a8823b4610 100644--- a/docs/documentation/platform/pam/accounts/aws-iam.mdx+++ b/docs/documentation/platform/pam/accounts/aws-iam.mdx@@ -123,8 +123,9 @@ All actions performed with the credentials are logged in [AWS CloudTrail](https:<Tabs><Tab title="AWS Console">1. Go to **Privileged Access Management → Accounts**- 2. Find the account and click the rocket icon, then select **Connect in Browser**- 3. You'll be taken directly to the AWS console, logged in with the role+ 2. Find the account and click the rocket icon (or select **Launch Session** from the menu)+ 3. Click **Connect in Browser**+ 4. You'll be taken directly to the AWS console, logged in with the role</Tab><Tab title="CLI">The CLI writes temporary credentials to your AWS credentials file as a named profile:diff --git a/docs/documentation/platform/pam/accounts/mysql.mdx b/docs/documentation/platform/pam/accounts/mysql.mdxindex dbafbdaa61..9cacc16456 100644--- a/docs/documentation/platform/pam/accounts/mysql.mdx+++ b/docs/documentation/platform/pam/accounts/mysql.mdx@@ -48,7 +48,8 @@ MySQL accounts let you manage access to your MySQL databases. Users connect throTo connect:1. Go to **Privileged Access Management → Accounts**- 2. Find the account and click the rocket icon, then select **Connect in Browser**+ 2. Find the account and click the rocket icon (or select **Launch Session** from the menu)+ 3. Click **Connect in Browser**</Tab><Tab title="CLI">diff --git a/docs/documentation/platform/pam/accounts/overview.mdx b/docs/documentation/platform/pam/accounts/overview.mdxindex 17c57ae249..126c954b5a 100644--- a/docs/documentation/platform/pam/accounts/overview.mdx+++ b/docs/documentation/platform/pam/accounts/overview.mdx@@ -34,7 +34,7 @@ Accounts live inside [folders](/documentation/platform/pam/folders/overview). To<Steps><Step title="Start adding an account">- Go to **Privileged Access Management → Accounts** and click **Add Account**. The button only appears if you have permission to create accounts in at least one folder.+ Go to **Privileged Access Management → Accounts** and click **Add Account**.</Step><Step title="Select a folder and template">Choose which folder to add the account to, then select a [template](/documentation/platform/pam/templates/overview). The template determines the account type and all the rules that apply.@@ -57,7 +57,7 @@ Once an account exists, users with access can connect from the **Accounts** page### Web Access-Go to **Privileged Access Management → Accounts**, find the account, and click the rocket icon, then select **Connect in Browser**. This opens:+Go to **Privileged Access Management → Accounts**, find the account, and click the rocket icon (or select **Launch Session** from the menu), then click **Connect in Browser**. This opens:- **PostgreSQL / MySQL** — a Data Explorer for browsing tables and a SQL Editor for running queries- **SSH** — an interactive terminal- **AWS IAM** — opens the AWS Console with federated credentialsdiff --git a/docs/documentation/platform/pam/accounts/postgresql.mdx b/docs/documentation/platform/pam/accounts/postgresql.mdxindex 69c09ff72e..8b4bc55e89 100644--- a/docs/documentation/platform/pam/accounts/postgresql.mdx+++ b/docs/documentation/platform/pam/accounts/postgresql.mdx@@ -48,7 +48,8 @@ PostgreSQL accounts let you manage access to your PostgreSQL databases. Users coTo connect:1. Go to **Privileged Access Management → Accounts**- 2. Find the account and click the rocket icon, then select **Connect in Browser**+ 2. Find the account and click the rocket icon (or select **Launch Session** from the menu)+ 3. Click **Connect in Browser**</Tab><Tab title="CLI">diff --git a/docs/documentation/platform/pam/accounts/ssh.mdx b/docs/documentation/platform/pam/accounts/ssh.mdxindex a6bba69f4a..ba0f97c52a 100644--- a/docs/documentation/platform/pam/accounts/ssh.mdx+++ b/docs/documentation/platform/pam/accounts/ssh.mdx@@ -62,8 +62,9 @@ SSH accounts support three authentication methods: password, public key, and cerWeb Access provides an interactive terminal in your browser.1. Go to **Privileged Access Management → Accounts**- 2. Find the account and click the rocket icon, then select **Connect in Browser**- 3. A terminal opens in a new tab+ 2. Find the account and click the rocket icon (or select **Launch Session** from the menu)+ 3. Click **Connect in Browser**+ 4. A terminal opens in a new tabYou get a full shell. To disconnect, type `exit` or close the tab.</Tab>diff --git a/docs/documentation/platform/pam/accounts/windows.mdx b/docs/documentation/platform/pam/accounts/windows.mdxindex 58c74e04e5..6f515aa661 100644--- a/docs/documentation/platform/pam/accounts/windows.mdx+++ b/docs/documentation/platform/pam/accounts/windows.mdx@@ -44,8 +44,9 @@ Windows accounts require session recordings to be stored in an external S3 buckeWeb Access provides a browser-based RDP client:1. Go to **Privileged Access Management → Accounts**- 2. Find the account and click the rocket icon, then select **Connect in Browser**- 3. A remote desktop session opens in a new tab+ 2. Find the account and click the rocket icon (or select **Launch Session** from the menu)+ 3. Click **Connect in Browser**+ 4. A remote desktop session opens in a new tabYou get a full Windows desktop. To disconnect, log out or close the tab.</Tab>diff --git a/frontend/src/hooks/api/pam/mutations.tsx b/frontend/src/hooks/api/pam/mutations.tsxindex 688e967fd3..8435a2894f 100644--- a/frontend/src/hooks/api/pam/mutations.tsx+++ b/frontend/src/hooks/api/pam/mutations.tsx@@ -773,7 +773,7 @@ export const useCreatePamAccessRequest = () => {},onSuccess: () => {queryClient.invalidateQueries({ queryKey: pamKeys.accessRequest() });- // Refresh every account list variant (accessible + admin-list) so the row's access status+ // Refresh every account list variant (accessible + list) so the row's access status// and its icon flip to pending as soon as the request is submitted.queryClient.invalidateQueries({ queryKey: pamKeys.account() });}diff --git a/frontend/src/hooks/api/pam/queries.tsx b/frontend/src/hooks/api/pam/queries.tsxindex 85b27cfe51..c086fc9354 100644--- a/frontend/src/hooks/api/pam/queries.tsx+++ b/frontend/src/hooks/api/pam/queries.tsx@@ -1,12 +1,7 @@import { useCallback, useMemo } from "react";import { createMongoAbility, MongoAbility, RawRuleOf } from "@casl/ability";import { unpackRules } from "@casl/ability/extra";-import {- keepPreviousData,- useInfiniteQuery,- useQuery,- UseQueryOptions-} from "@tanstack/react-query";+import { useQuery, UseQueryOptions } from "@tanstack/react-query";import { apiRequest } from "@app/config/request";import {@@ -25,7 +20,6 @@ import {import {PamAccountAccessibilityIssue,PamFolderPermissionSet,- TAccessiblePamAccount,TListAccessiblePamAccountsDTO,TListPamAccountTemplatesDTO,TPamAccessRequest,@@ -81,8 +75,8 @@ export const pamKeys = {folder: () => [...pamKeys.all, "folder"] as const,listFolders: (params?: { search?: string; filterByAction?: string }) =>[...pamKeys.folder(), "list", params] as const,- adminListAccounts: (params?: { folderId?: string; templateId?: string; search?: string }) =>- [...pamKeys.account(), "admin-list", params] as const,+ listAccounts: (params?: { folderId?: string; templateId?: string; search?: string }) =>+ [...pamKeys.account(), "list", params] as const,accountMembers: (accountId: string) => [...pamKeys.all, "account-members", accountId] as const,folderMembers: (folderId: string) => [...pamKeys.all, "folder-members", folderId] as const,productMembers: () => [...pamKeys.all, "product-members"] as const,@@ -163,7 +157,7 @@ export const usePamAccountActions = (accountId: string, enabled = true) => {};// Builds a `can` checker from packed permission rules already embedded in a list item, so list rows-// don't each fire a per-account /permissions request (see useListPamAccountsAdmin).+// don't each fire a per-account /permissions request (see useListPamAccounts).export const usePamAccountActionsFromPermissions = (permissions?: ResourcePermissionResponse<PamFolderPermissionSet>["permissions"]) => {@@ -176,48 +170,6 @@ export const usePamAccountActionsFromPermissions = (return { can };};-// Accessible Accounts (user-facing)-type TListAccessiblePamAccountsResponse = {- accounts: TAccessiblePamAccount[];- totalCount: number;-};--const ACCESSIBLE_ACCOUNTS_PAGE_SIZE = 50;--export const useListAccessiblePamAccounts = (- filters?: Omit<TListAccessiblePamAccountsDTO, "offset" | "limit">,- options?: { enabled?: boolean }-) => {- return useInfiniteQuery({- queryKey: pamKeys.listAccessibleAccounts(filters),- queryFn: async ({ pageParam = 0 }) => {- const { data } = await apiRequest.get<TListAccessiblePamAccountsResponse>(- "/api/v1/pam/accounts/accessible",- { params: { ...filters, offset: pageParam, limit: ACCESSIBLE_ACCOUNTS_PAGE_SIZE } }- );- return data;- },- initialPageParam: 0,- getNextPageParam: (lastPage, allPages) => {- const fetched = allPages.reduce((sum, p) => sum + p.accounts.length, 0);- return fetched < lastPage.totalCount ? fetched : undefined;- },- enabled: options?.enabled ?? true,- placeholderData: keepPreviousData,- // Grants and pending requests change state on their own (expiry, approval), so poll while any- // are on screen; a fully static list costs nothing.- refetchInterval: (query) => {- const hasLiveAccessState = query.state.data?.pages.some((page) =>- page.accounts.some(- (a) =>- a.accessStatus === PamAccessStatus.Granted || a.accessStatus === PamAccessStatus.Pending- )- );- return hasLiveAccessState ? 60_000 : false;- }- });-};-// Accessible Folders (user-facing)export type TAccessiblePamFolder = {id: string;@@ -225,27 +177,13 @@ export type TAccessiblePamFolder = {accountCount: number;};-export const useListAccessiblePamFolders = (options?: { enabled?: boolean }) => {- return useQuery({- queryKey: pamKeys.accessibleFolders(),- queryFn: async () => {- const { data } = await apiRequest.get<{ folders: TAccessiblePamFolder[] }>(- "/api/v1/pam/folders",- { params: { onlyAccessible: "true" } }- );- return data.folders;- },- enabled: options?.enabled ?? true- });-};--type TAdminListAccountsParams = {+type TListPamAccountsParams = {folderId?: string;templateId?: string;search?: string;};-export type TAdminAccountListItem = {+export type TPamAccountListItem = {id: string;name: string;description: string | null;@@ -268,14 +206,14 @@ export type TAdminAccountListItem = {updatedAt: string;};-export const useListPamAccountsAdmin = (- params?: TAdminListAccountsParams,+export const useListPamAccounts = (+ params?: TListPamAccountsParams,options?: { enabled?: boolean }) => {return useQuery({- queryKey: pamKeys.adminListAccounts(params),+ queryKey: pamKeys.listAccounts(params),queryFn: async () => {- const { data } = await apiRequest.get<{ accounts: TAdminAccountListItem[] }>(+ const { data } = await apiRequest.get<{ accounts: TPamAccountListItem[] }>("/api/v1/pam/accounts",{ params });@@ -296,7 +234,7 @@ export const useListPamAccountsAdmin = (});};-export const useListPamFoldersAdmin = (+export const useListPamFolders = (params?: { search?: string; filterByAction?: string },options?: { enabled?: boolean }) => {diff --git a/frontend/src/pages/pam/PamAccountsPage/PamAccountsPage.tsx b/frontend/src/pages/pam/PamAccountsPage/PamAccountsPage.tsxindex f669652de3..eb52838d35 100644--- a/frontend/src/pages/pam/PamAccountsPage/PamAccountsPage.tsx+++ b/frontend/src/pages/pam/PamAccountsPage/PamAccountsPage.tsx@@ -37,7 +37,10 @@ import {TableBody,TableHead,TableHeader,- TableRow+ TableRow,+ Tooltip,+ TooltipContent,+ TooltipTrigger} from "@app/components/v3";import { Skeleton } from "@app/components/v3/generic/Skeleton";import {@@ -48,7 +51,7 @@ import {useDeletePamFolder,useGetPamAccessCapabilities,useListPamAccountTypes,- useListPamFoldersAdmin+ useListPamFolders} from "@app/hooks/api/pam";import { ProjectType } from "@app/hooks/api/projects/types";import { usePamSheetState } from "@app/hooks/usePamSheetState";@@ -80,12 +83,13 @@ export const PamAccountsPage = () => {const { data: capabilities } = useGetPamAccessCapabilities();// Backed by ReadAccounts/ReadFolder, so every role gets its visible subset (not a 403).- const { data: folders = [], isLoading: isLoadingFolders } = useListPamFoldersAdmin();+ const { data: folders = [], isLoading: isLoadingFolders } = useListPamFolders();// Folders where the user can create accounts — gates the "Add Account" affordance.- const { data: creatableFolders = [] } = useListPamFoldersAdmin({+ const { data: creatableFolders = [] } = useListPamFolders({filterByAction: PamResourcePermissionActions.CreateAccounts});+ // Product admins qualify even with zero folders: the create sheet lets them add one inline.const canManage = creatableFolders.length > 0 || Boolean(capabilities?.isProductAdmin);// Both admin and regular users filter by account type for a consistent view@@ -212,47 +216,69 @@ export const PamAccountsPage = () => {<CardDescription>Launch sessions for accounts you have access to, or manage account settings.</CardDescription>- {canManage && (- <CardAction>- <ButtonGroup>- {creatableFolders.length > 0 && (- <Button- variant="pam"- className={capabilities?.isProductAdmin ? "rounded-r-none" : ""}- onClick={() => handlePopUpOpen("createAccount")}- >- <Plus />- Add Account- </Button>- )}- {capabilities?.isProductAdmin && (- <DropdownMenu>- <DropdownMenuTrigger asChild>- <IconButton- variant="pam"- aria-label="More create options"- className={creatableFolders.length > 0 ? "border-l-transparent" : ""}- >- <ChevronDown />- </IconButton>- </DropdownMenuTrigger>- <DropdownMenuContent- align="end"- sideOffset={4}- className="min-w-48"- onClick={(e) => e.stopPropagation()}+ <CardAction>+ <ButtonGroup>+ {/* Always rendered — disabled rather than hidden, so the affordance is discoverable+ and the reason it's unavailable is explained in the tooltip. */}+ <Tooltip>+ <TooltipTrigger asChild>+ <span className={canManage ? undefined : "cursor-not-allowed"}>+ <Button+ variant="pam"+ isDisabled={!canManage}+ className="rounded-r-none"+ onClick={() => handlePopUpOpen("createAccount")}>- <DropdownMenuLabel>New</DropdownMenuLabel>- <DropdownMenuItem onClick={() => handlePopUpOpen("createFolder")}>- <FolderPlus />- Add Folder- </DropdownMenuItem>- </DropdownMenuContent>- </DropdownMenu>+ <Plus />+ Add Account+ </Button>+ </span>+ </TooltipTrigger>+ {!canManage && (+ <TooltipContent>+ You don't have permission to create accounts in any folder+ </TooltipContent>)}- </ButtonGroup>- </CardAction>- )}+ </Tooltip>+ <DropdownMenu>+ <DropdownMenuTrigger asChild>+ <IconButton+ variant="pam"+ aria-label="More create options"+ className="border-l-transparent"+ >+ <ChevronDown />+ </IconButton>+ </DropdownMenuTrigger>+ <DropdownMenuContent+ align="end"+ sideOffset={4}+ className="min-w-48"+ onClick={(e) => e.stopPropagation()}+ >+ <DropdownMenuLabel>New</DropdownMenuLabel>+ <Tooltip>+ <TooltipTrigger asChild>+ <div>+ <DropdownMenuItem+ isDisabled={!capabilities?.isProductAdmin}+ onClick={() => handlePopUpOpen("createFolder")}+ >+ <FolderPlus />+ Add Folder+ </DropdownMenuItem>+ </div>+ </TooltipTrigger>+ {!capabilities?.isProductAdmin && (+ <TooltipContent side="left">+ Only product admins can create folders+ </TooltipContent>+ )}+ </Tooltip>+ </DropdownMenuContent>+ </DropdownMenu>+ </ButtonGroup>+ </CardAction></CardHeader><CardContent className="flex items-center gap-3"><InputGroup className="flex-1">diff --git a/frontend/src/pages/pam/PamAccountsPage/components/CreateAccountSheet.tsx b/frontend/src/pages/pam/PamAccountsPage/components/CreateAccountSheet.tsxindex 061413556a..ca299309f1 100644--- a/frontend/src/pages/pam/PamAccountsPage/components/CreateAccountSheet.tsx+++ b/frontend/src/pages/pam/PamAccountsPage/components/CreateAccountSheet.tsx@@ -55,7 +55,7 @@ import {useGetPamAccessCapabilities,useListPamAccountTemplates,useListPamAccountTypes,- useListPamFoldersAdmin,+ useListPamFolders,usePamAccountTypeMap} from "@app/hooks/api/pam";@@ -126,7 +126,7 @@ export const CreateAccountSheet = ({ isOpen, onOpenChange, defaultFolderId, onCrconst selectedTemplateId = watch("templateId");const { data: accountTypes = [] } = useListPamAccountTypes();- const { data: folders = [] } = useListPamFoldersAdmin({+ const { data: folders = [] } = useListPamFolders({filterByAction: PamResourcePermissionActions.CreateAccounts});const { data: templates = [] } = useListPamAccountTemplates();@@ -345,23 +345,39 @@ export const CreateAccountSheet = ({ isOpen, onOpenChange, defaultFolderId, onCr<FieldLabel>Account Template<span className="text-product-pam">*</span></FieldLabel>- {isProductAdmin && (- <Button- variant="ghost"- size="xs"- className="text-muted hover:text-foreground"- asChild- >- <Link- to="/organizations/$orgId/pam/templates"- params={{ orgId: currentOrg.id }}- target="_blank"- >- Manage Templates- <ArrowUpRight />- </Link>- </Button>- )}+ <Tooltip>+ <TooltipTrigger asChild>+ <div>+ {isProductAdmin ? (+ <Button+ variant="ghost"+ size="xs"+ className="text-muted hover:text-foreground"+ asChild+ >+ <Link+ to="/organizations/$orgId/pam/templates"+ params={{ orgId: currentOrg.id }}+ target="_blank"+ >+ Manage Templates+ <ArrowUpRight />+ </Link>+ </Button>+ ) : (+ <Button variant="ghost" size="xs" className="text-muted" isDisabled>+ Manage Templates+ <ArrowUpRight />+ </Button>+ )}+ </div>+ </TooltipTrigger>+ {!isProductAdmin && (+ <TooltipContent side="left">+ Only product admins can manage templates+ </TooltipContent>+ )}+ </Tooltip></div><FieldContent className="min-h-0 flex-1"><InputGroup>diff --git a/frontend/src/pages/pam/PamAccountsPage/components/EditAccountForm.tsx b/frontend/src/pages/pam/PamAccountsPage/components/EditAccountForm.tsxindex e875a90847..5464314511 100644--- a/frontend/src/pages/pam/PamAccountsPage/components/EditAccountForm.tsx+++ b/frontend/src/pages/pam/PamAccountsPage/components/EditAccountForm.tsx@@ -19,7 +19,7 @@ import {useGetPamAccountById,useListPamAccountTemplates,useListPamAccountTypes,- useListPamFoldersAdmin,+ useListPamFolders,useUpdatePamAccount} from "@app/hooks/api/pam";import { UNCHANGED_PASSWORD_SENTINEL } from "@app/hooks/api/pam/constants";@@ -64,7 +64,7 @@ export const EditAccountForm = ({ accountId, onDirtyChange }: Props) => {const { data: account, isLoading: isLoadingAccount } = useGetPamAccountById(accountId);const updateAccount = useUpdatePamAccount({ skipValidationToast: true });const { data: accountTypes = [] } = useListPamAccountTypes();- const { data: folders = [] } = useListPamFoldersAdmin();+ const { data: folders = [] } = useListPamFolders();const { data: templates = [] } = useListPamAccountTemplates(account ? { type: account.accountType } : undefined);diff --git a/frontend/src/pages/pam/PamAccountsPage/components/FolderAccountRow.tsx b/frontend/src/pages/pam/PamAccountsPage/components/FolderAccountRow.tsxindex f038f80ee3..a5f64fc95d 100644--- a/frontend/src/pages/pam/PamAccountsPage/components/FolderAccountRow.tsx+++ b/frontend/src/pages/pam/PamAccountsPage/components/FolderAccountRow.tsx@@ -3,7 +3,7 @@ import {PamAccountType,PamResourcePermissionActions,TAccessiblePamAccount,- TAdminAccountListItem,+ TPamAccountListItem,usePamAccountActionsFromPermissions} from "@app/hooks/api/pam";import { PamSheetTab } from "@app/hooks/usePamSheetState";@@ -13,7 +13,7 @@ import { AccountAccessibilityBadgeWithPermission } from "./AccountAccessibilityBimport { AccountActionsMenu } from "./AccountActionsMenu";type Props = {- account: TAdminAccountListItem;+ account: TPamAccountListItem;search: string;onOpenAccount: (accountId: string, tab?: PamSheetTab) => void;onLaunchAccount: (account: TAccessiblePamAccount) => void;diff --git a/frontend/src/pages/pam/PamAccountsPage/components/FolderAccountRows.tsx b/frontend/src/pages/pam/PamAccountsPage/components/FolderAccountRows.tsxindex 1e63ed9ae5..9ac6c553a1 100644--- a/frontend/src/pages/pam/PamAccountsPage/components/FolderAccountRows.tsx+++ b/frontend/src/pages/pam/PamAccountsPage/components/FolderAccountRows.tsx@@ -7,7 +7,7 @@ import {PamAccountType,TAccessiblePamAccount,TPamFolderWithCount,- useListPamAccountsAdmin+ useListPamAccounts} from "@app/hooks/api/pam";import { PamSheetTab } from "@app/hooks/usePamSheetState";@@ -48,7 +48,7 @@ export const FolderAccountRows = ({onResultCount}: Props) => {// Only fetch this folder's accounts once it's open (lazy load per folder)- const { data, isLoading } = useListPamAccountsAdmin({ folderId: folder.id }, { enabled: isOpen });+ const { data, isLoading } = useListPamAccounts({ folderId: folder.id }, { enabled: isOpen });const accounts = data ?? [];const q = search.trim().toLowerCase();diff --git a/frontend/src/pages/pam/PamAccountsPage/components/FolderActionsMenu.tsx b/frontend/src/pages/pam/PamAccountsPage/components/FolderActionsMenu.tsxindex b61d30838b..e3b3274c95 100644--- a/frontend/src/pages/pam/PamAccountsPage/components/FolderActionsMenu.tsx+++ b/frontend/src/pages/pam/PamAccountsPage/components/FolderActionsMenu.tsx@@ -1,3 +1,4 @@+import { useState } from "react";import { MoreHorizontal, Plus, Trash2 } from "lucide-react";import {@@ -6,7 +7,10 @@ import {DropdownMenuItem,DropdownMenuSeparator,DropdownMenuTrigger,- IconButton+ IconButton,+ Tooltip,+ TooltipContent,+ TooltipTrigger} from "@app/components/v3";import {PamResourcePermissionActions,@@ -15,7 +19,7 @@ import {} from "@app/hooks/api/pam";import { PamSheetTab } from "@app/hooks/usePamSheetState";-import { PAM_FOLDER_TABS, visiblePamTabs } from "../../components/pamResourceTabs";+import { PAM_FOLDER_TABS } from "../../components/pamResourceTabs";type Props = {folder: TPamFolderWithCount;@@ -25,21 +29,22 @@ type Props = {};export const FolderActionsMenu = ({ folder, onOpenTab, onAddAccount, onDelete }: Props) => {- // Eagerly fetch permissions so we can hide the menu if user has no actions- const { can, isLoading } = usePamFolderActions(folder.id, true);+ const [isOpen, setIsOpen] = useState(false);- const tabs = visiblePamTabs(PAM_FOLDER_TABS, can);- const canCreateAccounts = can(PamResourcePermissionActions.CreateAccounts);- const canDelete = can(PamResourcePermissionActions.DeleteFolder);- const hasAnyAction = tabs.length > 0 || canCreateAccounts || canDelete;+ // Every role sees the same menu with the same items, so permissions only decide what's disabled —+ // fetch them when the menu opens rather than once per visible folder on page load.+ const { can, isLoading } = usePamFolderActions(folder.id, isOpen);- // Hide the menu entirely while loading or if user has no folder management permissions- if (isLoading || !hasAnyAction) {- return null;- }+ // Treat an unresolved permission set as "not allowed" so nothing is actionable until it loads.+ const allowed = (action: PamResourcePermissionActions) => !isLoading && can(action);+ const canCreateAccounts = allowed(PamResourcePermissionActions.CreateAccounts);+ const canDelete = allowed(PamResourcePermissionActions.DeleteFolder);+ // Items are disabled while permissions load, but the reason isn't known yet — don't claim it's+ // a permission problem until the fetch settles.+ const showReason = !isLoading;return (- <DropdownMenu>+ <DropdownMenu open={isOpen} onOpenChange={setIsOpen}><DropdownMenuTrigger asChild><IconButtonvariant="ghost"@@ -52,27 +57,60 @@ export const FolderActionsMenu = ({ folder, onOpenTab, onAddAccount, onDelete }:</IconButton></DropdownMenuTrigger><DropdownMenuContent align="end" onClick={(e) => e.stopPropagation()}>- {tabs.map((tab) => (- <DropdownMenuItem key={tab.value} onClick={() => onOpenTab(tab.value)}>- <tab.icon />- {tab.label}- </DropdownMenuItem>- ))}- {canCreateAccounts && (- <DropdownMenuItem onClick={onAddAccount}>- <Plus />- Add Account- </DropdownMenuItem>- )}- {canDelete && (- <>- <DropdownMenuSeparator />- <DropdownMenuItem variant="danger" onClick={onDelete}>- <Trash2 />- Delete Folder- </DropdownMenuItem>- </>- )}+ {PAM_FOLDER_TABS.map((tab) => {+ const hasPermission = !tab.action || allowed(tab.action);+ return (+ <Tooltip key={tab.value}>+ <TooltipTrigger asChild>+ <div>+ <DropdownMenuItem+ isDisabled={!hasPermission}+ onClick={() => onOpenTab(tab.value)}+ >+ <tab.icon />+ {tab.label}+ </DropdownMenuItem>+ </div>+ </TooltipTrigger>+ {!hasPermission && showReason && (+ <TooltipContent side="left">+ You don't have permission to access {tab.label.toLowerCase()}+ </TooltipContent>+ )}+ </Tooltip>+ );+ })}+ <Tooltip>+ <TooltipTrigger asChild>+ <div>+ <DropdownMenuItem isDisabled={!canCreateAccounts} onClick={onAddAccount}>+ <Plus />+ Add Account+ </DropdownMenuItem>+ </div>+ </TooltipTrigger>+ {!canCreateAccounts && showReason && (+ <TooltipContent side="left">+ You don't have permission to create accounts in this folder+ </TooltipContent>+ )}+ </Tooltip>+ <DropdownMenuSeparator />+ <Tooltip>+ <TooltipTrigger asChild>+ <div>+ <DropdownMenuItem variant="danger" isDisabled={!canDelete} onClick={onDelete}>+ <Trash2 />+ Delete Folder+ </DropdownMenuItem>+ </div>+ </TooltipTrigger>+ {!canDelete && showReason && (+ <TooltipContent side="left">+ You don't have permission to delete this folder+ </TooltipContent>+ )}+ </Tooltip></DropdownMenuContent></DropdownMenu>);diff --git a/frontend/src/pages/pam/PamDiscoveryPage/components/DiscoveryConfigFields.tsx b/frontend/src/pages/pam/PamDiscoveryPage/components/DiscoveryConfigFields.tsxindex 11db07446f..8cb6d89496 100644--- a/frontend/src/pages/pam/PamDiscoveryPage/components/DiscoveryConfigFields.tsx+++ b/frontend/src/pages/pam/PamDiscoveryPage/components/DiscoveryConfigFields.tsx@@ -20,7 +20,7 @@ import {Switch,TextArea} from "@app/components/v3";-import { PamAccountType, PamDiscoverySchedule, useListPamAccountsAdmin } from "@app/hooks/api/pam";+import { PamAccountType, PamDiscoverySchedule, useListPamAccounts } from "@app/hooks/api/pam";export const discoveryConfigFormShape = {scanLocalAccounts: z.boolean(),@@ -186,7 +186,7 @@ export const SshCredentialAccountsField = ({}: {control: Control<{ credentialAccountIds: string[] }>;}) => {- const { data: accounts = [] } = useListPamAccountsAdmin();+ const { data: accounts = [] } = useListPamAccounts();const sshAccounts = accounts.filter((a) => a.accountType === PamAccountType.SSH);return (@@ -257,7 +257,7 @@ export const CredentialAccountField = ({}: {control: Control<{ credentialAccountId: string }>;}) => {- const { data: accounts = [] } = useListPamAccountsAdmin();+ const { data: accounts = [] } = useListPamAccounts();const credentialAccounts = accounts.filter((a) => a.accountType === PamAccountType.WindowsAd);return (diff --git a/frontend/src/pages/pam/PamDiscoveryPage/components/DiscoverySourceDetailSheet.tsx b/frontend/src/pages/pam/PamDiscoveryPage/components/DiscoverySourceDetailSheet.tsxindex 7fc1750435..05dc344ccc 100644--- a/frontend/src/pages/pam/PamDiscoveryPage/components/DiscoverySourceDetailSheet.tsx+++ b/frontend/src/pages/pam/PamDiscoveryPage/components/DiscoverySourceDetailSheet.tsx@@ -51,7 +51,7 @@ import {pamKeys,TPamDiscoveredAccount,TPamDiscoverySource,- useListPamAccountsAdmin,+ useListPamAccounts,useListPamDiscoveredAccounts,useListPamDiscoveryRuns,useListPamDiscoverySources,@@ -351,7 +351,7 @@ export const DiscoverySourceDetailSheet = ({ isOpen, sourceId, onOpenChange }: Pconst { tab, setTab } = usePamSheetState("discoverySourceId");const { data: sources = [] } = useListPamDiscoverySources();const { data: discoveryTypes = [] } = useListPamDiscoveryTypes();- const { data: adminAccounts = [] } = useListPamAccountsAdmin();+ const { data: adminAccounts = [] } = useListPamAccounts();const { map: accountTypeMap } = usePamAccountTypeMap();const source = sources.find((s) => s.id === sourceId);const typeMeta = discoveryTypes.find((t) => t.type === source?.discoveryType);diff --git a/frontend/src/pages/pam/PamDiscoveryPage/components/ImportDiscoveredModal.tsx b/frontend/src/pages/pam/PamDiscoveryPage/components/ImportDiscoveredModal.tsxindex 4dd59c1aa0..0e6febf9d3 100644--- a/frontend/src/pages/pam/PamDiscoveryPage/components/ImportDiscoveredModal.tsx+++ b/frontend/src/pages/pam/PamDiscoveryPage/components/ImportDiscoveredModal.tsx@@ -22,7 +22,7 @@ import {TPamDiscoveredAccount,useImportPamDiscoveredAccounts,useListPamAccountTemplates,- useListPamFoldersAdmin,+ useListPamFolders,usePamAccountTypeMap} from "@app/hooks/api/pam";@@ -46,7 +46,7 @@ export const ImportDiscoveredModal = ({const [templateByType, setTemplateByType] = useState<Record<string, string>>({});const importAccounts = useImportPamDiscoveredAccounts();- const { data: folders = [] } = useListPamFoldersAdmin();+ const { data: folders = [] } = useListPamFolders();const { data: templates = [] } = useListPamAccountTemplates();const { map: accountTypeMap } = usePamAccountTypeMap();