Skip to content

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

feat(gateways): display PAM connected resources

Andrey202158d70daf
diff --git a/backend/src/ee/routes/v2/gateway-router.ts b/backend/src/ee/routes/v2/gateway-router.ts
index 3877235e27..8cb6cd2b5f 100644
--- a/backend/src/ee/routes/v2/gateway-router.ts
+++ b/backend/src/ee/routes/v2/gateway-router.ts
@@ -316,6 +316,21 @@ export const registerGatewayV2Router = async (server: FastifyZodProvider) => {
projectId: z.string(),
projectName: z.string()
})
+ ),
+ pamAccounts: z.array(
+ z.object({
+ id: z.string(),
+ name: z.string(),
+ accountType: z.string(),
+ folderName: z.string().nullable()
+ })
+ ),
+ pamAccountTemplates: z.array(
+ z.object({
+ id: z.string(),
+ name: z.string(),
+ type: z.string()
+ })
)
})
}
diff --git a/backend/src/ee/services/gateway-v2/gateway-v2-service.ts b/backend/src/ee/services/gateway-v2/gateway-v2-service.ts
index 17d30e36eb..e3f582e727 100644
--- a/backend/src/ee/services/gateway-v2/gateway-v2-service.ts
+++ b/backend/src/ee/services/gateway-v2/gateway-v2-service.ts
@@ -36,6 +36,8 @@ import { TSmtpService } from "@app/services/smtp/smtp-service";
import { TDynamicSecretDALFactory } from "../dynamic-secret/dynamic-secret-dal";
import { PamAccountType } from "../pam/pam-enums";
+import { TPamAccountDALFactory } from "../pam-account/pam-account-dal";
+import { TPamAccountTemplateDALFactory } from "../pam-account-template/pam-account-template-dal";
import { OrgPermissionGatewayActions, OrgPermissionSubjects } from "../permission/org-permission";
import { TPermissionServiceFactory } from "../permission/permission-service-types";
import { TPkiDiscoveryConfigDALFactory } from "../pki-discovery/pki-discovery-config-dal";
@@ -77,6 +79,8 @@ type TGatewayV2ServiceFactoryDep = {
dynamicSecretDAL: Pick<TDynamicSecretDALFactory, "findByGatewayId" | "countByGatewayId">;
identityKubernetesAuthDAL: Pick<TIdentityKubernetesAuthDALFactory, "findByGatewayId" | "countByGatewayId">;
pkiDiscoveryConfigDAL: Pick<TPkiDiscoveryConfigDALFactory, "findByGatewayId" | "countByGatewayId">;
+ pamAccountDAL: Pick<TPamAccountDALFactory, "findByGatewayId" | "countByGatewayId">;
+ pamAccountTemplateDAL: Pick<TPamAccountTemplateDALFactory, "findByGatewayId" | "countByGatewayId">;
resourceAuthMethodService: Pick<
TResourceAuthMethodServiceFactory,
| "initAtCreate"
@@ -104,6 +108,8 @@ export const gatewayV2ServiceFactory = ({
dynamicSecretDAL,
identityKubernetesAuthDAL,
pkiDiscoveryConfigDAL,
+ pamAccountDAL,
+ pamAccountTemplateDAL,
resourceAuthMethodService
}: TGatewayV2ServiceFactoryDep) => {
const $validateIdentityAccessToGateway = async (orgId: string, actorId: string, actorAuthMethod: ActorAuthMethod) => {
@@ -317,15 +323,23 @@ export const gatewayV2ServiceFactory = ({
const gatewayIds = gateways.map((g) => g.id);
- const [appConnectionsCounts, dynamicSecretsCounts, kubernetesAuthsCounts, pkiDiscoveryConfigsCounts] =
- await Promise.all([
- Promise.all(gatewayIds.map((id) => appConnectionDAL.countByGatewayId(id).then((count) => ({ id, count })))),
- Promise.all(gatewayIds.map((id) => dynamicSecretDAL.countByGatewayId(id).then((count) => ({ id, count })))),
- Promise.all(
- gatewayIds.map((id) => identityKubernetesAuthDAL.countByGatewayId(id).then((count) => ({ id, count })))
- ),
- Promise.all(gatewayIds.map((id) => pkiDiscoveryConfigDAL.countByGatewayId(id).then((count) => ({ id, count }))))
- ]);
+ const [
+ appConnectionsCounts,
+ dynamicSecretsCounts,
+ kubernetesAuthsCounts,
+ pkiDiscoveryConfigsCounts,
+ pamAccountsCounts,
+ pamAccountTemplatesCounts
+ ] = await Promise.all([
+ Promise.all(gatewayIds.map((id) => appConnectionDAL.countByGatewayId(id).then((count) => ({ id, count })))),
+ Promise.all(gatewayIds.map((id) => dynamicSecretDAL.countByGatewayId(id).then((count) => ({ id, count })))),
+ Promise.all(
+ gatewayIds.map((id) => identityKubernetesAuthDAL.countByGatewayId(id).then((count) => ({ id, count })))
+ ),
+ Promise.all(gatewayIds.map((id) => pkiDiscoveryConfigDAL.countByGatewayId(id).then((count) => ({ id, count })))),
+ Promise.all(gatewayIds.map((id) => pamAccountDAL.countByGatewayId(id).then((count) => ({ id, count })))),
+ Promise.all(gatewayIds.map((id) => pamAccountTemplateDAL.countByGatewayId(id).then((count) => ({ id, count }))))
+ ]);
const countMap = new Map<string, number>();
@@ -341,6 +355,12 @@ export const gatewayV2ServiceFactory = ({
for (const { id, count } of pkiDiscoveryConfigsCounts) {
countMap.set(id, (countMap.get(id) ?? 0) + count);
}
+ for (const { id, count } of pamAccountsCounts) {
+ countMap.set(id, (countMap.get(id) ?? 0) + count);
+ }
+ for (const { id, count } of pamAccountTemplatesCounts) {
+ countMap.set(id, (countMap.get(id) ?? 0) + count);
+ }
return gateways.map((gateway) => ({
...gateway,
@@ -1263,18 +1283,23 @@ export const gatewayV2ServiceFactory = ({
OrgPermissionSubjects.Gateway
);
- const [appConnections, dynamicSecrets, kubernetesAuths, pkiDiscoveryConfigs] = await Promise.all([
- appConnectionDAL.findByGatewayId(gatewayId),
- dynamicSecretDAL.findByGatewayId(gatewayId),
- identityKubernetesAuthDAL.findByGatewayId(gatewayId),
- pkiDiscoveryConfigDAL.findByGatewayId(gatewayId)
- ]);
+ const [appConnections, dynamicSecrets, kubernetesAuths, pkiDiscoveryConfigs, pamAccounts, pamAccountTemplates] =
+ await Promise.all([
+ appConnectionDAL.findByGatewayId(gatewayId),
+ dynamicSecretDAL.findByGatewayId(gatewayId),
+ identityKubernetesAuthDAL.findByGatewayId(gatewayId),
+ pkiDiscoveryConfigDAL.findByGatewayId(gatewayId),
+ pamAccountDAL.findByGatewayId(gatewayId),
+ pamAccountTemplateDAL.findByGatewayId(gatewayId)
+ ]);
return {
appConnections,
dynamicSecrets,
kubernetesAuths,
- pkiDiscoveryConfigs
+ pkiDiscoveryConfigs,
+ pamAccounts,
+ pamAccountTemplates
};
};
diff --git a/backend/src/ee/services/gateway-v2/gateway-v2-types.ts b/backend/src/ee/services/gateway-v2/gateway-v2-types.ts
index c11dbfe227..08adfa9d25 100644
--- a/backend/src/ee/services/gateway-v2/gateway-v2-types.ts
+++ b/backend/src/ee/services/gateway-v2/gateway-v2-types.ts
@@ -44,9 +44,24 @@ export type TGatewayConnectedPkiDiscoveryConfig = {
projectName?: string;
};
+export type TGatewayConnectedPamAccount = {
+ id: string;
+ name: string;
+ accountType: string;
+ folderName: string | null;
+};
+
+export type TGatewayConnectedPamAccountTemplate = {
+ id: string;
+ name: string;
+ type: string;
+};
+
export type TGatewayConnectedResources = {
appConnections: TGatewayConnectedAppConnection[];
dynamicSecrets: TGatewayConnectedDynamicSecret[];
kubernetesAuths: TGatewayConnectedKubernetesAuth[];
pkiDiscoveryConfigs: TGatewayConnectedPkiDiscoveryConfig[];
+ pamAccounts: TGatewayConnectedPamAccount[];
+ pamAccountTemplates: TGatewayConnectedPamAccountTemplate[];
};
diff --git a/backend/src/ee/services/pam-account-template/pam-account-template-dal.ts b/backend/src/ee/services/pam-account-template/pam-account-template-dal.ts
index c39ae90bdd..7eae03bbeb 100644
--- a/backend/src/ee/services/pam-account-template/pam-account-template-dal.ts
+++ b/backend/src/ee/services/pam-account-template/pam-account-template-dal.ts
@@ -64,5 +64,26 @@ export const pamAccountTemplateDALFactory = (db: TDbClient) => {
};
};
- return { ...orm, findByProjectId, countAccountsByTemplateId, getTemplateRotationStats };
+ const findByGatewayId = async (gatewayId: string, tx?: Knex) =>
+ (tx || db.replicaNode())(TableName.PamAccountTemplate)
+ .where(`${TableName.PamAccountTemplate}.gatewayId`, gatewayId)
+ .select("id", "name", "type");
+
+ const countByGatewayId = async (gatewayId: string, tx?: Knex) => {
+ const result = await (tx || db.replicaNode())(TableName.PamAccountTemplate)
+ .where(`${TableName.PamAccountTemplate}.gatewayId`, gatewayId)
+ .count("id")
+ .first();
+
+ return parseInt(String(result?.count || "0"), 10);
+ };
+
+ return {
+ ...orm,
+ findByProjectId,
+ countAccountsByTemplateId,
+ getTemplateRotationStats,
+ findByGatewayId,
+ countByGatewayId
+ };
};
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 9696cf0410..91cb60e7c7 100644
--- a/backend/src/ee/services/pam-account/pam-account-dal.ts
+++ b/backend/src/ee/services/pam-account/pam-account-dal.ts
@@ -501,8 +501,34 @@ export const pamAccountDALFactory = (db: TDbClient) => {
}
};
+ const findByGatewayId = async (gatewayId: string, tx?: Knex) => {
+ const docs = await (tx || db.replicaNode())(TableName.PamAccount)
+ .join(TableName.PamAccountTemplate, `${TableName.PamAccount}.templateId`, `${TableName.PamAccountTemplate}.id`)
+ .leftJoin(TableName.PamFolder, `${TableName.PamAccount}.folderId`, `${TableName.PamFolder}.id`)
+ .where(`${TableName.PamAccount}.gatewayId`, gatewayId)
+ .select(
+ `${TableName.PamAccount}.id`,
+ `${TableName.PamAccount}.name`,
+ `${TableName.PamAccountTemplate}.type as accountType`,
+ `${TableName.PamFolder}.name as folderName`
+ );
+
+ return docs as { id: string; name: string; accountType: string; folderName: string | null }[];
+ };
+
+ const countByGatewayId = async (gatewayId: string, tx?: Knex) => {
+ const result = await (tx || db.replicaNode())(TableName.PamAccount)
+ .where(`${TableName.PamAccount}.gatewayId`, gatewayId)
+ .count("id")
+ .first();
+
+ return parseInt(String(result?.count || "0"), 10);
+ };
+
return {
...orm,
+ findByGatewayId,
+ countByGatewayId,
findAccessible,
findByIdWithDetails,
findByIdsWithDetails,
diff --git a/backend/src/server/routes/index.ts b/backend/src/server/routes/index.ts
index 919a560901..f5e0b3471e 100644
--- a/backend/src/server/routes/index.ts
+++ b/backend/src/server/routes/index.ts
@@ -2080,6 +2080,8 @@ export const registerRoutes = async (
dynamicSecretDAL,
identityKubernetesAuthDAL,
pkiDiscoveryConfigDAL,
+ pamAccountDAL,
+ pamAccountTemplateDAL,
resourceAuthMethodService
});
diff --git a/frontend/src/hooks/api/gateways-v2/types.ts b/frontend/src/hooks/api/gateways-v2/types.ts
index db5928d741..982a457558 100644
--- a/frontend/src/hooks/api/gateways-v2/types.ts
+++ b/frontend/src/hooks/api/gateways-v2/types.ts
@@ -135,9 +135,24 @@ export type TGatewayConnectedPkiDiscoveryConfig = {
projectName: string;
};
+export type TGatewayConnectedPamAccount = {
+ id: string;
+ name: string;
+ accountType: string;
+ folderName: string | null;
+};
+
+export type TGatewayConnectedPamAccountTemplate = {
+ id: string;
+ name: string;
+ type: string;
+};
+
export type TGatewayConnectedResources = {
appConnections: TGatewayConnectedAppConnection[];
dynamicSecrets: TGatewayConnectedDynamicSecret[];
kubernetesAuths: TGatewayConnectedKubernetesAuth[];
pkiDiscoveryConfigs: TGatewayConnectedPkiDiscoveryConfig[];
+ pamAccounts: TGatewayConnectedPamAccount[];
+ pamAccountTemplates: TGatewayConnectedPamAccountTemplate[];
};
diff --git a/frontend/src/pages/organization/NetworkingPage/GatewayDetailsByIDPage/components/GatewayConnectedResourcesSection/GatewayConnectedResourcesSection.tsx b/frontend/src/pages/organization/NetworkingPage/GatewayDetailsByIDPage/components/GatewayConnectedResourcesSection/GatewayConnectedResourcesSection.tsx
index 2b05d6c48a..06e53bbd1b 100644
--- a/frontend/src/pages/organization/NetworkingPage/GatewayDetailsByIDPage/components/GatewayConnectedResourcesSection/GatewayConnectedResourcesSection.tsx
+++ b/frontend/src/pages/organization/NetworkingPage/GatewayDetailsByIDPage/components/GatewayConnectedResourcesSection/GatewayConnectedResourcesSection.tsx
@@ -36,7 +36,9 @@ const totalCountOf = (r: TGatewayConnectedResources | undefined) =>
? r.appConnections.length +
r.dynamicSecrets.length +
r.kubernetesAuths.length +
- r.pkiDiscoveryConfigs.length
+ r.pkiDiscoveryConfigs.length +
+ r.pamAccounts.length +
+ r.pamAccountTemplates.length
: 0;
const ResourceRow = ({
@@ -169,6 +171,54 @@ export const GatewayConnectedResourcesSection = ({ gatewayId }: Props) => {
</AccordionItem>
)}
+ {(resources?.pamAccounts.length ?? 0) > 0 && (
+ <AccordionItem value="pam-accounts">
+ <AccordionTrigger>
+ <span className="flex-1">PAM Accounts</span>
+ <Badge variant="neutral">{resources?.pamAccounts.length}</Badge>
+ </AccordionTrigger>
+ <AccordionContent className="group-data-[variant=default]/accordion:p-3">
+ <ItemGroup>
+ {resources?.pamAccounts.map((a) => (
+ <ResourceRow
+ key={a.id}
+ name={a.name}
+ subtitle={
+ a.folderName ? `${a.accountType} · ${a.folderName}` : a.accountType
+ }
+ to="/organizations/$orgId/pam/accounts"
+ params={{ orgId: currentOrg.id }}
+ search={{ accountId: a.id }}
+ />
+ ))}
+ </ItemGroup>
+ </AccordionContent>
+ </AccordionItem>
+ )}
+
+ {(resources?.pamAccountTemplates.length ?? 0) > 0 && (
+ <AccordionItem value="pam-account-templates">
+ <AccordionTrigger>
+ <span className="flex-1">PAM Account Templates</span>
+ <Badge variant="neutral">{resources?.pamAccountTemplates.length}</Badge>
+ </AccordionTrigger>
+ <AccordionContent className="group-data-[variant=default]/accordion:p-3">
+ <ItemGroup>
+ {resources?.pamAccountTemplates.map((t) => (
+ <ResourceRow
+ key={t.id}
+ name={t.name}
+ subtitle={t.type}
+ to="/organizations/$orgId/pam/templates"
+ params={{ orgId: currentOrg.id }}
+ search={{ templateId: t.id }}
+ />
+ ))}
+ </ItemGroup>
+ </AccordionContent>
+ </AccordionItem>
+ )}
+
{(resources?.pkiDiscoveryConfigs.length ?? 0) > 0 && (
<AccordionItem value="pki-discovery">
<AccordionTrigger>