Skip to content

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

Show dependencies on resources

x032205ccd94be5d762
diff --git a/backend/src/ee/routes/v1/pam-account-routers/pam-account-router.ts b/backend/src/ee/routes/v1/pam-account-routers/pam-account-router.ts
index c731c9dd2d..9cc175344d 100644
--- a/backend/src/ee/routes/v1/pam-account-routers/pam-account-router.ts
+++ b/backend/src/ee/routes/v1/pam-account-routers/pam-account-router.ts
@@ -36,7 +36,8 @@ const SanitizedAccountSchema = z
])
.and(
z.object({
- credentialsConfigured: z.boolean()
+ credentialsConfigured: z.boolean(),
+ dependencyCount: z.number().default(0)
})
);
diff --git a/backend/src/ee/routes/v1/pam-resource-routers/pam-resource-router.ts b/backend/src/ee/routes/v1/pam-resource-routers/pam-resource-router.ts
index 64f1240d26..8932e9726d 100644
--- a/backend/src/ee/routes/v1/pam-resource-routers/pam-resource-router.ts
+++ b/backend/src/ee/routes/v1/pam-resource-routers/pam-resource-router.ts
@@ -1,5 +1,6 @@
import { z } from "zod";
+import { PamAccountDependenciesSchema } from "@app/db/schemas";
import { EventType } from "@app/ee/services/audit-log/audit-log-types";
import {
ActiveDirectoryResourceListItemSchema,
@@ -17,7 +18,7 @@ import {
MySQLResourceListItemSchema,
SanitizedMySQLResourceSchema
} from "@app/ee/services/pam-resource/mysql/mysql-resource-schemas";
-import { PamResourceOrderBy } from "@app/ee/services/pam-resource/pam-resource-enums";
+import { PamResource, PamResourceOrderBy } from "@app/ee/services/pam-resource/pam-resource-enums";
import {
PostgresResourceListItemSchema,
SanitizedPostgresResourceSchema
@@ -216,4 +217,39 @@ export const registerPamResourceRouter = async (server: FastifyZodProvider) => {
return { resources, totalCount };
}
});
+
+ server.route({
+ method: "GET",
+ url: "/:resourceType/:resourceId/dependencies",
+ config: {
+ rateLimit: readLimit
+ },
+ schema: {
+ operationId: "getPamResourceDependencies",
+ description: "List dependencies that run on this resource",
+ params: z.object({
+ resourceType: z.nativeEnum(PamResource),
+ resourceId: z.string().uuid()
+ }),
+ response: {
+ 200: z.object({
+ dependencies: PamAccountDependenciesSchema.extend({
+ accountName: z.string().nullable()
+ }).array()
+ })
+ }
+ },
+ onRequest: verifyAuth([AuthMode.JWT]),
+ handler: async (req) => {
+ const dependencies = await server.services.pamDiscoverySource.getResourceDependencies({
+ resourceId: req.params.resourceId,
+ actorId: req.permission.id,
+ actor: req.permission.type,
+ actorAuthMethod: req.permission.authMethod,
+ actorOrgId: req.permission.orgId
+ });
+
+ return { dependencies };
+ }
+ });
};
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 79f624f76a..ae98952b66 100644
--- a/backend/src/ee/services/pam-account/pam-account-service.ts
+++ b/backend/src/ee/services/pam-account/pam-account-service.ts
@@ -50,6 +50,7 @@ import { TUserDALFactory } from "@app/services/user/user-dal";
import { EventType, TAuditLogServiceFactory } from "../audit-log/audit-log-types";
import { TGatewayV2ServiceFactory } from "../gateway-v2/gateway-v2-service";
+import { TPamAccountDependenciesDALFactory } from "../pam-discovery/pam-account-dependencies-dal";
import { TPamResourceDALFactory } from "../pam-resource/pam-resource-dal";
import { PamResource } from "../pam-resource/pam-resource-enums";
import { TPamAccountCredentials } from "../pam-resource/pam-resource-types";
@@ -90,6 +91,7 @@ type TPamAccountServiceFactoryDep = {
approvalRequestGrantsDAL: TApprovalRequestGrantsDALFactory;
pamSessionExpirationService: Pick<TPamSessionExpirationServiceFactory, "scheduleSessionExpiration">;
resourceMetadataDAL: Pick<TResourceMetadataDALFactory, "insertMany" | "delete">;
+ pamAccountDependenciesDAL: Pick<TPamAccountDependenciesDALFactory, "countByAccountIds">;
};
export type TPamAccountServiceFactory = ReturnType<typeof pamAccountServiceFactory>;
@@ -111,7 +113,8 @@ export const pamAccountServiceFactory = ({
approvalPolicyDAL,
approvalRequestGrantsDAL,
pamSessionExpirationService,
- resourceMetadataDAL
+ resourceMetadataDAL,
+ pamAccountDependenciesDAL
}: TPamAccountServiceFactoryDep) => {
const create = async (
{
@@ -553,10 +556,16 @@ export const pamAccountServiceFactory = ({
}
}
+ // Fetch dependency counts for all permitted accounts
+ const permittedAccountIds = decryptedAndPermittedAccounts.map((a) => a.id);
+ const dependencyCountMap =
+ permittedAccountIds.length > 0 ? await pamAccountDependenciesDAL.countByAccountIds(permittedAccountIds) : {};
+
return {
accounts: decryptedAndPermittedAccounts.map((a) => ({
...a,
- metadata: metadataByAccountId[a.id] || []
+ metadata: metadataByAccountId[a.id] || [],
+ dependencyCount: dependencyCountMap[a.id] || 0
})),
totalCount
};
diff --git a/backend/src/ee/services/pam-discovery/pam-account-dependencies-dal.ts b/backend/src/ee/services/pam-discovery/pam-account-dependencies-dal.ts
index dcf885bde7..d2edad18b6 100644
--- a/backend/src/ee/services/pam-discovery/pam-account-dependencies-dal.ts
+++ b/backend/src/ee/services/pam-discovery/pam-account-dependencies-dal.ts
@@ -27,10 +27,12 @@ export const pamAccountDependenciesDALFactory = (db: TDbClient) => {
const findByResourceId = async (resourceId: string, tx?: Knex) => {
try {
const docs = await (tx || db.replicaNode())(TableName.PamAccountDependency)
- .where({ resourceId })
- .orderBy("name", "asc");
+ .where(`${TableName.PamAccountDependency}.resourceId`, resourceId)
+ .leftJoin(TableName.PamAccount, `${TableName.PamAccountDependency}.accountId`, `${TableName.PamAccount}.id`)
+ .select(`${TableName.PamAccountDependency}.*`, `${TableName.PamAccount}.name as accountName`)
+ .orderBy(`${TableName.PamAccountDependency}.name`, "asc");
- return docs as TPamAccountDependencies[];
+ return docs as (TPamAccountDependencies & { accountName: string | null })[];
} catch (error) {
throw new DatabaseError({ error, name: "Find PAM account dependencies by resource ID" });
}
diff --git a/backend/src/ee/services/pam-discovery/pam-discovery-source-service.ts b/backend/src/ee/services/pam-discovery/pam-discovery-source-service.ts
index 89e1526a47..9ac5fbf099 100644
--- a/backend/src/ee/services/pam-discovery/pam-discovery-source-service.ts
+++ b/backend/src/ee/services/pam-discovery/pam-discovery-source-service.ts
@@ -5,6 +5,7 @@ import { TPamAccountDALFactory } from "@app/ee/services/pam-account/pam-account-
import { OrgPermissionGatewayActions, OrgPermissionSubjects } from "@app/ee/services/permission/org-permission";
import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service-types";
import {
+ ProjectPermissionActions,
ProjectPermissionPamAccountActions,
ProjectPermissionPamDiscoveryActions,
ProjectPermissionSub
@@ -17,6 +18,7 @@ import { TKmsServiceFactory } from "@app/services/kms/kms-service";
import { TGatewayV2DALFactory } from "../gateway-v2/gateway-v2-dal";
import { TGatewayV2ServiceFactory } from "../gateway-v2/gateway-v2-service";
+import { TPamResourceDALFactory } from "../pam-resource/pam-resource-dal";
import { decryptResourceMetadata } from "../pam-resource/pam-resource-fns";
import { TPamAccountDependenciesDALFactory } from "./pam-account-dependencies-dal";
import { PamDiscoverySourceRunStatus, PamDiscoverySourceStatus, PamDiscoveryType } from "./pam-discovery-enums";
@@ -65,9 +67,16 @@ type TPamDiscoverySourceServiceFactoryDep = {
pamDiscoverySourceDependenciesDAL: Pick<TPamDiscoverySourceDependenciesDALFactory, "countByDiscoverySourceIds">;
pamAccountDependenciesDAL: Pick<
TPamAccountDependenciesDALFactory,
- "countByAccountIds" | "countByResourceIds" | "findByAccountId" | "findById" | "updateById" | "deleteById"
+ | "countByAccountIds"
+ | "countByResourceIds"
+ | "findByAccountId"
+ | "findByResourceId"
+ | "findById"
+ | "updateById"
+ | "deleteById"
>;
pamAccountDAL: Pick<TPamAccountDALFactory, "findByIdWithResourceDetails" | "findMetadataByAccountIds">;
+ pamResourceDAL: Pick<TPamResourceDALFactory, "findById">;
permissionService: Pick<TPermissionServiceFactory, "getProjectPermission" | "getOrgPermission">;
kmsService: Pick<TKmsServiceFactory, "createCipherPairWithDataKey">;
gatewayV2DAL: Pick<TGatewayV2DALFactory, "findOne">;
@@ -85,6 +94,7 @@ export const pamDiscoverySourceServiceFactory = ({
pamDiscoverySourceDependenciesDAL,
pamAccountDependenciesDAL,
pamAccountDAL,
+ pamResourceDAL,
permissionService,
kmsService,
gatewayV2DAL,
@@ -672,6 +682,39 @@ export const pamDiscoverySourceServiceFactory = ({
return pamAccountDependenciesDAL.findByAccountId(accountId);
};
+ const getResourceDependencies = async ({
+ resourceId,
+ actor,
+ actorId,
+ actorAuthMethod,
+ actorOrgId
+ }: {
+ resourceId: string;
+ actor: ActorType;
+ actorId: string;
+ actorAuthMethod: ActorAuthMethod;
+ actorOrgId: string;
+ }) => {
+ const resource = await pamResourceDAL.findById(resourceId);
+ if (!resource) throw new NotFoundError({ message: `Resource with ID '${resourceId}' not found` });
+
+ const { permission } = await permissionService.getProjectPermission({
+ actor,
+ actorId,
+ projectId: resource.projectId,
+ actorAuthMethod,
+ actorOrgId,
+ actionProjectType: ActionProjectType.PAM
+ });
+
+ ForbiddenError.from(permission).throwUnlessCan(
+ ProjectPermissionActions.Read,
+ subject(ProjectPermissionSub.PamResources, { name: resource.name })
+ );
+
+ return pamAccountDependenciesDAL.findByResourceId(resourceId);
+ };
+
const updateAccountDependency = async ({
accountId,
dependencyId,
@@ -748,6 +791,7 @@ export const pamDiscoverySourceServiceFactory = ({
getDiscoveredResources,
getDiscoveredAccounts,
getAccountDependencies,
+ getResourceDependencies,
updateAccountDependency,
deleteAccountDependency,
listDiscoverySourceOptions
diff --git a/backend/src/server/routes/index.ts b/backend/src/server/routes/index.ts
index 7dd21fc31d..0017ff8d9f 100644
--- a/backend/src/server/routes/index.ts
+++ b/backend/src/server/routes/index.ts
@@ -2715,7 +2715,8 @@ export const registerRoutes = async (
approvalRequestGrantsDAL,
approvalPolicyDAL,
pamSessionExpirationService,
- resourceMetadataDAL
+ resourceMetadataDAL,
+ pamAccountDependenciesDAL
});
const pamAccountRotation = pamAccountRotationServiceFactory({
@@ -2771,6 +2772,7 @@ export const registerRoutes = async (
pamDiscoverySourceDependenciesDAL,
pamAccountDependenciesDAL,
pamAccountDAL,
+ pamResourceDAL,
permissionService,
kmsService,
gatewayV2DAL,
diff --git a/frontend/src/hooks/api/pam/mutations.tsx b/frontend/src/hooks/api/pam/mutations.tsx
index 3b5902ea32..ab0a749774 100644
--- a/frontend/src/hooks/api/pam/mutations.tsx
+++ b/frontend/src/hooks/api/pam/mutations.tsx
@@ -193,6 +193,7 @@ export const useTogglePamAccountDependency = () => {
},
onSuccess: (_, { accountId }) => {
queryClient.invalidateQueries({ queryKey: pamKeys.accountDependencies(accountId) });
+ queryClient.invalidateQueries({ queryKey: pamKeys.allResourceDependencies() });
}
});
};
@@ -215,6 +216,7 @@ export const useDeletePamAccountDependency = () => {
},
onSuccess: (_, { accountId }) => {
queryClient.invalidateQueries({ queryKey: pamKeys.accountDependencies(accountId) });
+ queryClient.invalidateQueries({ queryKey: pamKeys.allResourceDependencies() });
}
});
};
diff --git a/frontend/src/hooks/api/pam/queries.tsx b/frontend/src/hooks/api/pam/queries.tsx
index f33dd81b17..5a40509ef5 100644
--- a/frontend/src/hooks/api/pam/queries.tsx
+++ b/frontend/src/hooks/api/pam/queries.tsx
@@ -10,6 +10,7 @@ import {
TPamAccount,
TPamAccountDependency,
TPamResource,
+ TPamResourceDependency,
TPamSession
} from "./types";
@@ -32,6 +33,13 @@ export const pamKeys = {
resourceId
],
listRelatedResources: (resourceId: string) => [...pamKeys.resource(), "related", resourceId],
+ allResourceDependencies: () => [...pamKeys.resource(), "dependencies"] as const,
+ resourceDependencies: (resourceType: string, resourceId: string) => [
+ ...pamKeys.resource(),
+ "dependencies",
+ resourceType,
+ resourceId
+ ],
listAccounts: ({ projectId, ...params }: TListPamAccountsDTO) => [
...pamKeys.account(),
"list",
@@ -157,6 +165,22 @@ export const useListRelatedResources = (
});
};
+export const useGetPamResourceDependencies = (
+ resourceType?: PamResourceType,
+ resourceId?: string
+) => {
+ return useQuery({
+ queryKey: pamKeys.resourceDependencies(resourceType || "", resourceId || ""),
+ queryFn: async () => {
+ const { data } = await apiRequest.get<{ dependencies: TPamResourceDependency[] }>(
+ `/api/v1/pam/resources/${resourceType}/${resourceId}/dependencies`
+ );
+ return data.dependencies;
+ },
+ enabled: !!resourceType && !!resourceId
+ });
+};
+
// Accounts
type TListPamAccountsResponse = {
accounts: TPamAccount[];
diff --git a/frontend/src/hooks/api/pam/types/base-account.ts b/frontend/src/hooks/api/pam/types/base-account.ts
index 79819e454a..9d94f20871 100644
--- a/frontend/src/hooks/api/pam/types/base-account.ts
+++ b/frontend/src/hooks/api/pam/types/base-account.ts
@@ -20,6 +20,7 @@ export interface TBasePamAccount {
lastRotatedAt?: string | null;
lastRotationMessage?: string | null;
rotationStatus?: string | null;
+ dependencyCount?: number;
metadata?: { key: string; value: string }[];
createdAt: string;
updatedAt: string;
diff --git a/frontend/src/hooks/api/pam/types/index.ts b/frontend/src/hooks/api/pam/types/index.ts
index a26a7bd62b..4171de9f52 100644
--- a/frontend/src/hooks/api/pam/types/index.ts
+++ b/frontend/src/hooks/api/pam/types/index.ts
@@ -211,3 +211,7 @@ export type TPamAccountDependency = {
createdAt: string;
updatedAt: string;
};
+
+export type TPamResourceDependency = TPamAccountDependency & {
+ accountName: string | null;
+};
diff --git a/frontend/src/pages/pam/PamAccountByIDPage/components/PamAccountDependenciesSection.tsx b/frontend/src/pages/pam/PamAccountByIDPage/components/PamAccountDependenciesSection.tsx
index 652456d0f4..5a4d46de4a 100644
--- a/frontend/src/pages/pam/PamAccountByIDPage/components/PamAccountDependenciesSection.tsx
+++ b/frontend/src/pages/pam/PamAccountByIDPage/components/PamAccountDependenciesSection.tsx
@@ -1,291 +1,17 @@
-import { useState } from "react";
-import { format } from "date-fns";
-import {
- ChevronDownIcon,
- ChevronRightIcon,
- CircleHelpIcon,
- EllipsisVerticalIcon,
- TrashIcon
-} from "lucide-react";
+import type { TPamAccount } from "@app/hooks/api/pam";
+import { useGetPamAccountDependencies } from "@app/hooks/api/pam";
-import { createNotification } from "@app/components/notifications";
-import { DeleteActionModal } from "@app/components/v2";
-import {
- Badge,
- Tooltip,
- TooltipContent,
- TooltipTrigger,
- UnstableDropdownMenu,
- UnstableDropdownMenuContent,
- UnstableDropdownMenuItem,
- UnstableDropdownMenuTrigger,
- UnstableEmpty,
- UnstableEmptyHeader,
- UnstableEmptyTitle,
- UnstableIconButton,
- UnstableTable,
- UnstableTableBody,
- UnstableTableCell,
- UnstableTableHead,
- UnstableTableHeader,
- UnstableTableRow
-} from "@app/components/v3";
-import type { TPamAccount, TPamAccountDependency } from "@app/hooks/api/pam";
-import {
- useDeletePamAccountDependency,
- useGetPamAccountDependencies,
- useTogglePamAccountDependency
-} from "@app/hooks/api/pam";
-
-const DEPENDENCY_TYPE_LABEL: Record<string, string> = {
- "windows-service": "Service",
- "scheduled-task": "Task",
- "iis-app-pool": "App Pool"
-};
-
-const DATA_LABEL_MAP: Record<string, string> = {
- runAsAccount: "Run As Account",
- startMode: "Start Mode",
- processId: "Process ID",
- pathName: "Path",
- description: "Description",
- taskPath: "Task Path",
- logonType: "Logon Type",
- runLevel: "Run Level",
- lastRunTime: "Last Run",
- nextRunTime: "Next Run",
- lastTaskResult: "Last Result",
- triggers: "Triggers",
- actions: "Actions",
- managedRuntimeVersion: "Runtime Version",
- managedPipelineMode: "Pipeline Mode",
- autoStart: "Auto Start",
- identityType: "Identity Type"
-};
-
-const COL_COUNT = 7;
-const DATA_KEY_ORDER: Record<string, number> = { actions: -2, triggers: -1 };
-
-const formatValue = (key: string, value: unknown): string => {
- if (value === null || value === undefined) return "-";
- if (typeof value === "boolean") return value ? "Yes" : "No";
- if (Array.isArray(value)) return value.length === 0 ? "-" : JSON.stringify(value, null, 2);
- if ((key === "lastRunTime" || key === "nextRunTime") && typeof value === "string") {
- try {
- return format(new Date(value), "MMM d, yyyy HH:mm");
- } catch {
- return String(value);
- }
- }
- return String(value);
-};
-
-const DependencyRow = ({
- dep,
- accountId,
- toggleMutation,
- onDeleteClick
-}: {
- dep: TPamAccountDependency;
- accountId: string;
- toggleMutation: ReturnType<typeof useTogglePamAccountDependency>;
- onDeleteClick: (dep: TPamAccountDependency) => void;
-}) => {
- const [isExpanded, setIsExpanded] = useState(false);
-
- const dataEntries = Object.entries(dep.data || {})
- .filter(([, v]) => v !== null && v !== undefined && v !== "")
- .sort((a, b) => (DATA_KEY_ORDER[a[0]] ?? 0) - (DATA_KEY_ORDER[b[0]] ?? 0));
-
- return (
- <>
- <UnstableTableRow className="group cursor-pointer" onClick={() => setIsExpanded(!isExpanded)}>
- <UnstableTableCell className="w-5">
- {isExpanded ? (
- <ChevronDownIcon className="size-4 text-muted" />
- ) : (
- <ChevronRightIcon className="size-4 text-muted" />
- )}
- </UnstableTableCell>
- <UnstableTableCell className="font-medium">{dep.displayName || dep.name}</UnstableTableCell>
- <UnstableTableCell>
- <Badge variant="info">
- {DEPENDENCY_TYPE_LABEL[dep.dependencyType] || dep.dependencyType}
- </Badge>
- </UnstableTableCell>
- <UnstableTableCell className="text-muted">{dep.resourceName ?? "-"}</UnstableTableCell>
- <UnstableTableCell className="text-muted">{dep.state ?? "-"}</UnstableTableCell>
- <UnstableTableCell>
- {dep.isRotationSyncEnabled ? (
- <Badge variant="success">Enabled</Badge>
- ) : (
- <Badge variant="neutral">Disabled</Badge>
- )}
- </UnstableTableCell>
- <UnstableTableCell>
- <UnstableDropdownMenu>
- <UnstableDropdownMenuTrigger asChild>
- <UnstableIconButton variant="ghost" size="xs" onClick={(e) => e.stopPropagation()}>
- <EllipsisVerticalIcon />
- </UnstableIconButton>
- </UnstableDropdownMenuTrigger>
- <UnstableDropdownMenuContent sideOffset={2} align="end">
- <UnstableDropdownMenuItem
- onClick={(e) => {
- e.stopPropagation();
- toggleMutation.mutate({
- accountId,
- dependencyId: dep.id,
- isRotationSyncEnabled: !dep.isRotationSyncEnabled
- });
- }}
- >
- {dep.isRotationSyncEnabled ? "Disable Rotation Sync" : "Enable Rotation Sync"}
- </UnstableDropdownMenuItem>
- <UnstableDropdownMenuItem
- variant="danger"
- onClick={(e) => {
- e.stopPropagation();
- onDeleteClick(dep);
- }}
- >
- <TrashIcon className="size-4" />
- Delete
- </UnstableDropdownMenuItem>
- </UnstableDropdownMenuContent>
- </UnstableDropdownMenu>
- </UnstableTableCell>
- </UnstableTableRow>
- {isExpanded && (
- <UnstableTableRow>
- <UnstableTableCell colSpan={COL_COUNT} className="bg-mineshaft-700/30 px-6 py-4">
- <div className="grid grid-cols-2 gap-x-8 gap-y-2 text-sm">
- <div className="flex justify-between border-b border-mineshaft-600 py-1">
- <span className="text-muted">Name</span>
- <span className="font-mono text-xs">{dep.name}</span>
- </div>
- <div className="flex justify-between border-b border-mineshaft-600 py-1">
- <span className="text-muted">Source</span>
- <span>{dep.source}</span>
- </div>
- <div className="flex justify-between border-b border-mineshaft-600 py-1">
- <span className="text-muted">Resource</span>
- <span>{dep.resourceName ?? "-"}</span>
- </div>
- <div className="flex justify-between border-b border-mineshaft-600 py-1">
- <span className="text-muted">Last Discovered</span>
- <span>{format(new Date(dep.updatedAt), "MMM d, yyyy HH:mm")}</span>
- </div>
- {dataEntries.map(([key, value]) => (
- <div key={key} className="flex justify-between border-b border-mineshaft-600 py-1">
- <span className="text-muted">{DATA_LABEL_MAP[key] || key}</span>
- {Array.isArray(value) && value.length > 0 ? (
- <pre className="max-h-32 max-w-xs overflow-auto rounded bg-mineshaft-800 px-2 py-1 font-mono text-xs">
- {JSON.stringify(value, null, 2)}
- </pre>
- ) : (
- <span className="font-mono text-xs">{formatValue(key, value)}</span>
- )}
- </div>
- ))}
- </div>
- </UnstableTableCell>
- </UnstableTableRow>
- )}
- </>
- );
-};
+import { PamDependenciesTable } from "../../components/PamDependenciesTable";
export const PamAccountDependenciesSection = ({ account }: { account: TPamAccount }) => {
const { data: dependencies, isPending } = useGetPamAccountDependencies(account.id);
- const toggleMutation = useTogglePamAccountDependency();
- const deleteMutation = useDeletePamAccountDependency();
-
- const [deleteTarget, setDeleteTarget] = useState<TPamAccountDependency | null>(null);
-
- const handleDelete = async () => {
- if (!deleteTarget) return;
- try {
- await deleteMutation.mutateAsync({
- accountId: account.id,
- dependencyId: deleteTarget.id
- });
- createNotification({ text: "Dependency deleted", type: "success" });
- setDeleteTarget(null);
- } catch {
- createNotification({ text: "Failed to delete dependency", type: "error" });
- }
- };
return (
- <>
- <UnstableTable>
- <UnstableTableHeader>
- <UnstableTableRow>
- <UnstableTableHead className="w-5" />
- <UnstableTableHead>Name</UnstableTableHead>
- <UnstableTableHead>Type</UnstableTableHead>
- <UnstableTableHead>Resource</UnstableTableHead>
- <UnstableTableHead>State</UnstableTableHead>
- <UnstableTableHead>
- <div className="flex items-center gap-1">
- Rotation Sync
- <Tooltip>
- <TooltipTrigger asChild>
- <CircleHelpIcon className="size-3.5 text-muted" />
- </TooltipTrigger>
- <TooltipContent side="top" className="max-w-xs">
- When enabled, secret rotation will automatically sync credentials to this
- dependency after rotating the account password
- </TooltipContent>
- </Tooltip>
- </div>
- </UnstableTableHead>
- <UnstableTableHead className="w-5" />
- </UnstableTableRow>
- </UnstableTableHeader>
- <UnstableTableBody>
- {isPending && (
- <UnstableTableRow>
- <UnstableTableCell colSpan={COL_COUNT} className="text-center text-muted">
- Loading dependencies...
- </UnstableTableCell>
- </UnstableTableRow>
- )}
- {!isPending && (!dependencies || dependencies.length === 0) && (
- <UnstableTableRow>
- <UnstableTableCell colSpan={COL_COUNT}>
- <UnstableEmpty className="border-0 bg-transparent py-8 shadow-none">
- <UnstableEmptyHeader>
- <UnstableEmptyTitle>No dependencies discovered</UnstableEmptyTitle>
- </UnstableEmptyHeader>
- </UnstableEmpty>
- </UnstableTableCell>
- </UnstableTableRow>
- )}
- {!isPending &&
- dependencies?.map((dep) => (
- <DependencyRow
- key={dep.id}
- dep={dep}
- accountId={account.id}
- toggleMutation={toggleMutation}
- onDeleteClick={setDeleteTarget}
- />
- ))}
- </UnstableTableBody>
- </UnstableTable>
-
- <DeleteActionModal
- isOpen={!!deleteTarget}
- title={`Delete dependency "${deleteTarget?.displayName || deleteTarget?.name}"?`}
- subTitle="This will permanently remove this dependency and break the audit trail for rotation tracking."
- onChange={(isOpen) => {
- if (!isOpen) setDeleteTarget(null);
- }}
- deleteKey="confirm"
- onDeleteApproved={handleDelete}
- />
- </>
+ <PamDependenciesTable
+ dependencies={dependencies}
+ isPending={isPending}
+ contextColumnLabel="Resource"
+ getContextValue={(dep) => dep.resourceName}
+ />
);
};
diff --git a/frontend/src/pages/pam/PamResourceByIDPage/PamResourceByIDPage.tsx b/frontend/src/pages/pam/PamResourceByIDPage/PamResourceByIDPage.tsx
index 17c4db5b87..303f9721c6 100644
--- a/frontend/src/pages/pam/PamResourceByIDPage/PamResourceByIDPage.tsx
+++ b/frontend/src/pages/pam/PamResourceByIDPage/PamResourceByIDPage.tsx
@@ -31,6 +31,7 @@ import { PamUpdateResourceModal } from "../PamResourcesPage/components/PamUpdate
import {
PamResourceAccountsSection,
PamResourceConnectionSection,
+ PamResourceDependenciesSection,
PamResourceDetailsSection,
PamResourceMetadataSection,
PamResourceRelatedResourcesSection
@@ -207,6 +208,9 @@ const PageContent = () => {
<Tabs value={selectedTab} onValueChange={handleTabChange}>
<TabList>
<Tab value="accounts">Accounts</Tab>
+ {resource.resourceType === PamResourceType.Windows && (
+ <Tab value="dependencies">Dependencies</Tab>
+ )}
{resource.resourceType === PamResourceType.ActiveDirectory && (
<Tab value="related-resources">Related Resources</Tab>
)}
@@ -214,6 +218,11 @@ const PageContent = () => {
<TabPanel value="accounts">
<PamResourceAccountsSection resource={resource} />
</TabPanel>
+ {resource.resourceType === PamResourceType.Windows && (
+ <TabPanel value="dependencies">
+ <PamResourceDependenciesSection resource={resource} />
+ </TabPanel>
+ )}
{resource.resourceType === PamResourceType.ActiveDirectory && (
<TabPanel value="related-resources">
<PamResourceRelatedResourcesSection resource={resource} />
diff --git a/frontend/src/pages/pam/PamResourceByIDPage/components/PamResourceAccountsSection.tsx b/frontend/src/pages/pam/PamResourceByIDPage/components/PamResourceAccountsSection.tsx
index 1865d6f351..63d23a53c7 100644
--- a/frontend/src/pages/pam/PamResourceByIDPage/components/PamResourceAccountsSection.tsx
+++ b/frontend/src/pages/pam/PamResourceByIDPage/components/PamResourceAccountsSection.tsx
@@ -78,6 +78,9 @@ type Props = {
const hasAccountType = (resourceType: PamResourceType) =>
resourceType === PamResourceType.Windows || resourceType === PamResourceType.ActiveDirectory;
+const hasAccountsWithDependencies = (resourceType: PamResourceType) =>
+ resourceType === PamResourceType.Windows || resourceType === PamResourceType.ActiveDirectory;
+
const getAccountType = (account: TPamAccount): string | undefined => {
if (account.resource.resourceType === PamResourceType.Windows) {
return (account as TWindowsAccount).internalMetadata?.accountType;
@@ -288,6 +291,9 @@ export const PamResourceAccountsSection = ({ resource }: Props) => {
<UnstableTableHeader>
<UnstableTableRow>
<UnstableTableHead>Account Name</UnstableTableHead>
+ {hasAccountsWithDependencies(resource.resourceType) && (
+ <UnstableTableHead>Dependencies</UnstableTableHead>
+ )}
{hasAccountType(resource.resourceType) && <UnstableTableHead>Type</UnstableTableHead>}
<UnstableTableHead className="w-5" />
</UnstableTableRow>
@@ -296,7 +302,11 @@ export const PamResourceAccountsSection = ({ resource }: Props) => {
{isPending && (
<UnstableTableRow>
<UnstableTableCell
- colSpan={hasAccountType(resource.resourceType) ? 3 : 2}
+ colSpan={
+ 2 +
+ (hasAccountType(resource.resourceType) ? 1 : 0) +
+ (hasAccountsWithDependencies(resource.resourceType) ? 1 : 0)
+ }
className="text-center text-muted"
>
Loading accounts...
@@ -305,7 +315,13 @@ export const PamResourceAccountsSection = ({ resource }: Props) => {
)}
{!isPending && accounts.length === 0 && (
<UnstableTableRow>
- <UnstableTableCell colSpan={hasAccountType(resource.resourceType) ? 3 : 2}>
+ <UnstableTableCell
+ colSpan={
+ 2 +
+ (hasAccountType(resource.resourceType) ? 1 : 0) +
+ (hasAccountsWithDependencies(resource.resourceType) ? 1 : 0)
+ }
+ >
<UnstableEmpty className="border-0 bg-transparent py-8 shadow-none">
<UnstableEmptyHeader>
<UnstableEmptyTitle>
@@ -374,6 +390,11 @@ export const PamResourceAccountsSection = ({ resource }: Props) => {
)}
</div>
</UnstableTableCell>
+ {hasAccountsWithDependencies(resource.resourceType) && (
+ <UnstableTableCell>
+ <span className="text-muted">{account.dependencyCount ?? 0}</span>
+ </UnstableTableCell>
+ )}
{hasAccountType(resource.resourceType) && (
<UnstableTableCell>
<span className="capitalize">{getAccountType(account) ?? "-"}</span>
diff --git a/frontend/src/pages/pam/PamResourceByIDPage/components/PamResourceDependenciesSection.tsx b/frontend/src/pages/pam/PamResourceByIDPage/components/PamResourceDependenciesSection.tsx
new file mode 100644
index 0000000000..68946a92e7
--- /dev/null
+++ b/frontend/src/pages/pam/PamResourceByIDPage/components/PamResourceDependenciesSection.tsx
@@ -0,0 +1,20 @@
+import type { TPamResource } from "@app/hooks/api/pam";
+import { useGetPamResourceDependencies } from "@app/hooks/api/pam";
+
+import { PamDependenciesTable } from "../../components/PamDependenciesTable";
+
+export const PamResourceDependenciesSection = ({ resource }: { resource: TPamResource }) => {
+ const { data: dependencies, isPending } = useGetPamResourceDependencies(
+ resource.resourceType,
+ resource.id
+ );
+
+ return (
+ <PamDependenciesTable
+ dependencies={dependencies}
+ isPending={isPending}
+ contextColumnLabel="Account"
+ getContextValue={(dep) => dep.accountName}
+ />
+ );
+};
diff --git a/frontend/src/pages/pam/PamResourceByIDPage/components/index.ts b/frontend/src/pages/pam/PamResourceByIDPage/components/index.ts
index 252d81b2a2..e46921b7fa 100644
--- a/frontend/src/pages/pam/PamResourceByIDPage/components/index.ts
+++ b/frontend/src/pages/pam/PamResourceByIDPage/components/index.ts
@@ -1,5 +1,6 @@
export { PamResourceAccountsSection } from "./PamResourceAccountsSection";
export { PamResourceConnectionSection } from "./PamResourceConnectionSection";
+export { PamResourceDependenciesSection } from "./PamResourceDependenciesSection";
export { PamResourceDetailsSection } from "./PamResourceDetailsSection";
export { PamResourceMetadataSection } from "./PamResourceMetadataSection";
export { PamResourceRelatedResourcesSection } from "./PamResourceRelatedResourcesSection";
diff --git a/frontend/src/pages/pam/PamResourceByIDPage/route.tsx b/frontend/src/pages/pam/PamResourceByIDPage/route.tsx
index 9ea0bb0b59..35b8af2e4b 100644
--- a/frontend/src/pages/pam/PamResourceByIDPage/route.tsx
+++ b/frontend/src/pages/pam/PamResourceByIDPage/route.tsx
@@ -6,6 +6,7 @@ import { PamResourceByIDPage } from "./PamResourceByIDPage";
export enum ResourceDetailTab {
Accounts = "accounts",
+ Dependencies = "dependencies",
RelatedResources = "related-resources"
}
diff --git a/frontend/src/pages/pam/components/PamDependenciesTable.tsx b/frontend/src/pages/pam/components/PamDependenciesTable.tsx
new file mode 100644
index 0000000000..2eccf9af1d
--- /dev/null
+++ b/frontend/src/pages/pam/components/PamDependenciesTable.tsx
@@ -0,0 +1,308 @@
+import { useState } from "react";
+import { format } from "date-fns";
+import {
+ ChevronDownIcon,
+ ChevronRightIcon,
+ CircleHelpIcon,
+ EllipsisVerticalIcon,
+ TrashIcon
+} from "lucide-react";
+
+import { createNotification } from "@app/components/notifications";
+import { DeleteActionModal } from "@app/components/v2";
+import {
+ Badge,
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger,
+ UnstableDropdownMenu,
+ UnstableDropdownMenuContent,
+ UnstableDropdownMenuItem,
+ UnstableDropdownMenuTrigger,
+ UnstableEmpty,
+ UnstableEmptyHeader,
+ UnstableEmptyTitle,
+ UnstableIconButton,
+ UnstableTable,
+ UnstableTableBody,
+ UnstableTableCell,
+ UnstableTableHead,
+ UnstableTableHeader,
+ UnstableTableRow
+} from "@app/components/v3";
+import type { TPamAccountDependency } from "@app/hooks/api/pam";
+import { useDeletePamAccountDependency, useTogglePamAccountDependency } from "@app/hooks/api/pam";
+
+const DEPENDENCY_TYPE_LABEL: Record<string, string> = {
+ "windows-service": "Service",
+ "scheduled-task": "Task",
+ "iis-app-pool": "App Pool"
+};
+
+const DATA_LABEL_MAP: Record<string, string> = {
+ runAsAccount: "Run As Account",
+ startMode: "Start Mode",
+ processId: "Process ID",
+ pathName: "Path",
+ description: "Description",
+ taskPath: "Task Path",
+ logonType: "Logon Type",
+ runLevel: "Run Level",
+ lastRunTime: "Last Run",
+ nextRunTime: "Next Run",
+ lastTaskResult: "Last Result",
+ triggers: "Triggers",
+ actions: "Actions",
+ managedRuntimeVersion: "Runtime Version",
+ managedPipelineMode: "Pipeline Mode",
+ autoStart: "Auto Start",
+ identityType: "Identity Type"
+};
+
+const DATA_KEY_ORDER: Record<string, number> = { actions: -2, triggers: -1 };
+
+const formatValue = (key: string, value: unknown): string => {
+ if (value === null || value === undefined) return "-";
+ if (typeof value === "boolean") return value ? "Yes" : "No";
+ if (Array.isArray(value)) return value.length === 0 ? "-" : JSON.stringify(value, null, 2);
+ if ((key === "lastRunTime" || key === "nextRunTime") && typeof value === "string") {
+ try {
+ return format(new Date(value), "MMM d, yyyy HH:mm");
+ } catch {
+ return String(value);
+ }
+ }
+ return String(value);
+};
+
+type TDependencyItem = TPamAccountDependency & {
+ accountName?: string | null;
+};
+
+const DependencyRow = ({
+ dep,
+ contextColumn,
+ colCount,
+ toggleMutation,
+ onDeleteClick
+}: {
+ dep: TDependencyItem;
+ contextColumn: { label: string; value: string | null | undefined };
+ colCount: number;
+ toggleMutation: ReturnType<typeof useTogglePamAccountDependency>;
+ onDeleteClick: (dep: TDependencyItem) => void;
+}) => {
+ const [isExpanded, setIsExpanded] = useState(false);
+
+ const dataEntries = Object.entries(dep.data || {})
+ .filter(([, v]) => v !== null && v !== undefined && v !== "")
+ .sort((a, b) => (DATA_KEY_ORDER[a[0]] ?? 0) - (DATA_KEY_ORDER[b[0]] ?? 0));
+
+ return (
+ <>
+ <UnstableTableRow className="group cursor-pointer" onClick={() => setIsExpanded(!isExpanded)}>
+ <UnstableTableCell className="w-5">
+ {isExpanded ? (
+ <ChevronDownIcon className="size-4 text-muted" />
+ ) : (
+ <ChevronRightIcon className="size-4 text-muted" />
+ )}
+ </UnstableTableCell>
+ <UnstableTableCell className="font-medium">{dep.displayName || dep.name}</UnstableTableCell>
+ <UnstableTableCell>
+ <Badge variant="info">
+ {DEPENDENCY_TYPE_LABEL[dep.dependencyType] || dep.dependencyType}
+ </Badge>
+ </UnstableTableCell>
+ <UnstableTableCell className="text-muted">{contextColumn.value ?? "-"}</UnstableTableCell>
+ <UnstableTableCell className="text-muted">{dep.state ?? "-"}</UnstableTableCell>
+ <UnstableTableCell>
+ {dep.isRotationSyncEnabled ? (
+ <Badge variant="success">Enabled</Badge>
+ ) : (
+ <Badge variant="neutral">Disabled</Badge>
+ )}
+ </UnstableTableCell>
+ <UnstableTableCell>
+ <UnstableDropdownMenu>
+ <UnstableDropdownMenuTrigger asChild>
+ <UnstableIconButton variant="ghost" size="xs" onClick={(e) => e.stopPropagation()}>
+ <EllipsisVerticalIcon />
+ </UnstableIconButton>
+ </UnstableDropdownMenuTrigger>
+ <UnstableDropdownMenuContent sideOffset={2} align="end">
+ <UnstableDropdownMenuItem
+ onClick={(e) => {
+ e.stopPropagation();
+ toggleMutation.mutate({
+ accountId: dep.accountId,
+ dependencyId: dep.id,
+ isRotationSyncEnabled: !dep.isRotationSyncEnabled
+ });
+ }}
+ >
+ {dep.isRotationSyncEnabled ? "Disable Rotation Sync" : "Enable Rotation Sync"}
+ </UnstableDropdownMenuItem>
+ <UnstableDropdownMenuItem
+ variant="danger"
+ onClick={(e) => {
+ e.stopPropagation();
+ onDeleteClick(dep);
+ }}
+ >
+ <TrashIcon className="size-4" />
+ Delete
+ </UnstableDropdownMenuItem>
+ </UnstableDropdownMenuContent>
+ </UnstableDropdownMenu>
+ </UnstableTableCell>
+ </UnstableTableRow>
+ {isExpanded && (
+ <UnstableTableRow>
+ <UnstableTableCell colSpan={colCount} className="bg-mineshaft-700/30 px-6 py-4">
+ <div className="grid grid-cols-2 gap-x-8 gap-y-2 text-sm">
+ <div className="flex justify-between border-b border-mineshaft-600 py-1">
+ <span className="text-muted">Name</span>
+ <span className="font-mono text-xs">{dep.name}</span>
+ </div>
+ <div className="flex justify-between border-b border-mineshaft-600 py-1">
+ <span className="text-muted">Source</span>
+ <span>{dep.source}</span>
+ </div>
+ <div className="flex justify-between border-b border-mineshaft-600 py-1">
+ <span className="text-muted">{contextColumn.label}</span>
+ <span>{contextColumn.value ?? "-"}</span>
+ </div>
+ <div className="flex justify-between border-b border-mineshaft-600 py-1">
+ <span className="text-muted">Last Discovered</span>
+ <span>{format(new Date(dep.updatedAt), "MMM d, yyyy HH:mm")}</span>
+ </div>
+ {dataEntries.map(([key, value]) => (
+ <div key={key} className="flex justify-between border-b border-mineshaft-600 py-1">
+ <span className="text-muted">{DATA_LABEL_MAP[key] || key}</span>
+ {Array.isArray(value) && value.length > 0 ? (
+ <pre className="max-h-32 max-w-xs overflow-auto rounded bg-mineshaft-800 px-2 py-1 font-mono text-xs">
+ {JSON.stringify(value, null, 2)}
+ </pre>
+ ) : (
+ <span className="font-mono text-xs">{formatValue(key, value)}</span>
+ )}
+ </div>
+ ))}
+ </div>
+ </UnstableTableCell>
+ </UnstableTableRow>
+ )}
+ </>
+ );
+};
+
+type PamDependenciesTableProps = {
+ dependencies: TDependencyItem[] | undefined;
+ isPending: boolean;
+ contextColumnLabel: string;
+ getContextValue: (dep: TDependencyItem) => string | null | undefined;
+};
+
+const COL_COUNT = 7;
+
+export const PamDependenciesTable = ({
+ dependencies,
+ isPending,
+ contextColumnLabel,
+ getContextValue
+}: PamDependenciesTableProps) => {
+ const toggleMutation = useTogglePamAccountDependency();
+ const deleteMutation = useDeletePamAccountDependency();
+ const [deleteTarget, setDeleteTarget] = useState<TDependencyItem | null>(null);
+
+ const handleDelete = async () => {
+ if (!deleteTarget) return;
+ try {
+ await deleteMutation.mutateAsync({
+ accountId: deleteTarget.accountId,
+ dependencyId: deleteTarget.id
+ });
+ createNotification({ text: "Dependency deleted", type: "success" });
+ setDeleteTarget(null);
+ } catch {
+ createNotification({ text: "Failed to delete dependency", type: "error" });
+ }
+ };
+
+ return (
+ <>
+ <UnstableTable>
+ <UnstableTableHeader>
+ <UnstableTableRow>
+ <UnstableTableHead className="w-5" />
+ <UnstableTableHead>Name</UnstableTableHead>
+ <UnstableTableHead>Type</UnstableTableHead>
+ <UnstableTableHead>{contextColumnLabel}</UnstableTableHead>
+ <UnstableTableHead>State</UnstableTableHead>
+ <UnstableTableHead>
+ <div className="flex items-center gap-1">
+ Rotation Sync
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <CircleHelpIcon className="size-3.5 text-muted" />
+ </TooltipTrigger>
+ <TooltipContent side="top" className="max-w-xs">
+ When enabled, secret rotation will automatically sync credentials to this
+ dependency after rotating the account password
+ </TooltipContent>
+ </Tooltip>
+ </div>
+ </UnstableTableHead>
+ <UnstableTableHead className="w-5" />
+ </UnstableTableRow>
+ </UnstableTableHeader>
+ <UnstableTableBody>
+ {isPending && (
+ <UnstableTableRow>
+ <UnstableTableCell colSpan={COL_COUNT} className="text-center text-muted">
+ Loading dependencies...
+ </UnstableTableCell>
+ </UnstableTableRow>
+ )}
+ {!isPending && (!dependencies || dependencies.length === 0) && (
+ <UnstableTableRow>
+ <UnstableTableCell colSpan={COL_COUNT}>
+ <UnstableEmpty className="border-0 bg-transparent py-8 shadow-none">
+ <UnstableEmptyHeader>
+ <UnstableEmptyTitle>No dependencies discovered</UnstableEmptyTitle>
+ </UnstableEmptyHeader>
+ </UnstableEmpty>
+ </UnstableTableCell>
+ </UnstableTableRow>
+ )}
+ {!isPending &&
+ dependencies?.map((dep) => (
+ <DependencyRow
+ key={dep.id}
+ dep={dep}
+ contextColumn={{
+ label: contextColumnLabel,
+ value: getContextValue(dep)
+ }}
+ colCount={COL_COUNT}
+ toggleMutation={toggleMutation}
+ onDeleteClick={setDeleteTarget}
+ />
+ ))}
+ </UnstableTableBody>
+ </UnstableTable>
+
+ <DeleteActionModal
+ isOpen={!!deleteTarget}
+ title={`Delete dependency "${deleteTarget?.displayName || deleteTarget?.name}"?`}
+ subTitle="This will permanently remove this dependency and break the audit trail for rotation tracking."
+ onChange={(isOpen) => {
+ if (!isOpen) setDeleteTarget(null);
+ }}
+ deleteKey="confirm"
+ onDeleteApproved={handleDelete}
+ />
+ </>
+ );
+};