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
allow web access for domain accounts
x032205ea1bd34f920a
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.tsindex 0fded91401..75ba3548ee 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@@ -712,7 +712,8 @@ export const registerPamAccountRouter = async (server: FastifyZodProvider) => {body: z.object({projectId: z.string().uuid(),mfaSessionId: z.string().optional(),- reason: z.string().trim().max(1000).optional()+ reason: z.string().trim().max(1000).optional(),+ resourceId: z.string().uuid().optional()}),response: {200: z.object({ ticket: z.string() })@@ -734,7 +735,8 @@ export const registerPamAccountRouter = async (server: FastifyZodProvider) => {actorName: `${req.auth.user.firstName ?? ""} ${req.auth.user.lastName ?? ""}`.trim(),auditLogInfo: req.auditLogInfo,mfaSessionId: req.body.mfaSessionId,- reason: req.body.reason+ reason: req.body.reason,+ resourceId: req.body.resourceId});await server.services.telemetry@@ -816,6 +818,7 @@ export const registerPamAccountRouter = async (server: FastifyZodProvider) => {accountId: z.string(),projectId: z.string(),orgId: z.string(),+ resourceId: z.string(),resourceName: z.string(),accountName: z.string(),actorEmail: z.string(),@@ -844,6 +847,7 @@ export const registerPamAccountRouter = async (server: FastifyZodProvider) => {accountId: payload.accountId,projectId: payload.projectId,orgId: payload.orgId,+ resourceId: payload.resourceId,resourceName: payload.resourceName,accountName: payload.accountName,actorEmail: payload.actorEmail,diff --git a/backend/src/ee/services/pam-web-access/pam-web-access-service.ts b/backend/src/ee/services/pam-web-access/pam-web-access-service.tsindex 7c50aa5dbf..b61addde1e 100644--- a/backend/src/ee/services/pam-web-access/pam-web-access-service.ts+++ b/backend/src/ee/services/pam-web-access/pam-web-access-service.ts@@ -104,6 +104,7 @@ type THandleWebSocketConnectionDTO = {accountId: string;projectId: string;orgId: string;+ resourceId: string;resourceName: string;accountName: string;auditLogInfo: AuditLogInfo;@@ -177,7 +178,8 @@ export const pamWebAccessServiceFactory = ({actorName,auditLogInfo,mfaSessionId,- reason+ reason,+ resourceId: requestResourceId}: TIssueWebSocketTicketDTO) => {const account = await pamAccountDAL.findById(accountId);@@ -191,14 +193,19 @@ export const pamWebAccessServiceFactory = ({const trimmedReason = reason?.trim() || null;- if (!account.resourceId) {- throw new BadRequestError({ message: "Web access is only available for resource-backed accounts" });+ const effectiveResourceId = account.resourceId ?? requestResourceId;+ if (!effectiveResourceId) {+ throw new BadRequestError({ message: "A resourceId is required for web access" });}- const resource = await pamResourceDAL.findById(account.resourceId);+ const resource = await pamResourceDAL.findById(effectiveResourceId);if (!resource) {- throw new NotFoundError({ message: `Resource with ID '${account.resourceId}' not found` });+ throw new NotFoundError({ message: `Resource with ID '${effectiveResourceId}' not found` });+ }++ if (resource.projectId !== projectId) {+ throw new NotFoundError({ message: `Resource with ID '${effectiveResourceId}' not found` });}if (!SUPPORTED_WEB_ACCESS_RESOURCES.includes(resource.resourceType as PamResource)) {@@ -350,6 +357,7 @@ export const pamWebAccessServiceFactory = ({accountId,projectId,orgId,+ resourceId: resource.id,resourceName: resource.name,accountName: account.name,actorEmail,@@ -381,6 +389,7 @@ export const pamWebAccessServiceFactory = ({accountId,projectId,orgId,+ resourceId: ticketResourceId,resourceName,accountName,auditLogInfo,@@ -493,11 +502,12 @@ export const pamWebAccessServiceFactory = ({throw new BadRequestError({ message: "Invalid account or project" });}- if (!account.resourceId) {- throw new BadRequestError({ message: "Web access is only available for resource-backed accounts" });+ const effectiveResourceId = account.resourceId ?? ticketResourceId;+ if (!effectiveResourceId) {+ throw new BadRequestError({ message: "A resourceId is required for domain accounts" });}- const resource = await pamResourceDAL.findById(account.resourceId);+ const resource = await pamResourceDAL.findById(effectiveResourceId);if (!resource) {throw new BadRequestError({ message: "Resource not found" });}@@ -543,6 +553,8 @@ export const pamWebAccessServiceFactory = ({const user = await requestMemoize(requestMemoKeys.userFindById(userId), () => userDAL.findById(userId));const expiresAt = new Date(Date.now() + DEFAULT_WEB_SESSION_DURATION_MS);+ const isDomainAccount = !account.resourceId;+session = await pamSessionDAL.create({status: PamSessionStatus.Starting,accessMethod: "web",@@ -556,7 +568,8 @@ export const pamWebAccessServiceFactory = ({resourceName: resource.name,resourceType: resource.resourceType,accountId: account.id,- resourceId: resource.id,+ resourceId: isDomainAccount ? null : resource.id,+ selectedResourceId: isDomainAccount ? resource.id : null,userId,gatewayId: effectiveGatewayId,reason: accessReason?.trim() || nulldiff --git a/backend/src/ee/services/pam-web-access/pam-web-access-types.ts b/backend/src/ee/services/pam-web-access/pam-web-access-types.tsindex 4f800aebd9..b92b1332cd 100644--- a/backend/src/ee/services/pam-web-access/pam-web-access-types.ts+++ b/backend/src/ee/services/pam-web-access/pam-web-access-types.ts@@ -77,4 +77,5 @@ export type TIssueWebSocketTicketDTO = {auditLogInfo: AuditLogInfo;mfaSessionId?: string;reason?: string;+ resourceId?: string;};diff --git a/frontend/src/pages/pam/PamAccountAccessPage/PamAccountAccessPage.tsx b/frontend/src/pages/pam/PamAccountAccessPage/PamAccountAccessPage.tsxindex aa7ec86905..bdc53b141e 100644--- a/frontend/src/pages/pam/PamAccountAccessPage/PamAccountAccessPage.tsx+++ b/frontend/src/pages/pam/PamAccountAccessPage/PamAccountAccessPage.tsx@@ -2,7 +2,12 @@ import { useState } from "react";import { Helmet } from "react-helmet";import { useParams } from "@tanstack/react-router";-import { PamResourceType, TPamAccount, useGetPamAccountById } from "@app/hooks/api/pam";+import {+ PamResourceType,+ TPamAccount,+ useGetPamAccountById,+ useGetPamResourceById+} from "@app/hooks/api/pam";import { PamDataExplorerPage } from "@app/pages/pam/PamDataExplorerPage/PamDataExplorerPage";import { RdpContent } from "./RdpContent";@@ -106,9 +111,22 @@ const PageContent = () => {resourceId?: string;};- const { accountId, projectId, orgId } = params;+ const {+ accountId,+ projectId,+ orgId,+ resourceType: routeResourceType,+ resourceId: routeResourceId+ } = params;const { data: account, isPending } = useGetPamAccountById(accountId);+ const isDomainAccount = !!account && !account.resourceId;+ const { data: domainResource } = useGetPamResourceById(+ routeResourceType as PamResourceType,+ routeResourceId,+ { enabled: isDomainAccount && !!routeResourceType && !!routeResourceId }+ );+if (isPending) {return (<div className="flex h-screen w-screen items-center justify-center bg-[#0d1117] text-mineshaft-300">@@ -125,6 +143,8 @@ const PageContent = () => {);}+ const effectiveResourceType = account.resource?.resourceType ?? routeResourceType;+// SSH uses inline terminal prompts for reason — bypass the upfront ReasonGate so the// approval prompt and reason prompt render in the same terminal stream, in order.if (account.resource?.resourceType === PamResourceType.SSH) {@@ -137,8 +157,16 @@ const PageContent = () => {if (account.resource?.resourceType === PamResourceType.Postgres) {return <PamDataExplorerPage reason={reason} />;}- if (account.resource?.resourceType === PamResourceType.Windows) {- return <RdpContent account={account} projectId={projectId!} reason={reason} />;+ if (effectiveResourceType === PamResourceType.Windows) {+ return (+ <RdpContent+ account={account}+ projectId={projectId!}+ resourceId={account.resource?.id ?? routeResourceId ?? ""}+ resourceName={account.resource?.name ?? domainResource?.name ?? ""}+ reason={reason}+ />+ );}return (<TerminalContentdiff --git a/frontend/src/pages/pam/PamAccountAccessPage/RdpContent.tsx b/frontend/src/pages/pam/PamAccountAccessPage/RdpContent.tsxindex c611effdcc..ce9d296c98 100644--- a/frontend/src/pages/pam/PamAccountAccessPage/RdpContent.tsx+++ b/frontend/src/pages/pam/PamAccountAccessPage/RdpContent.tsx@@ -10,19 +10,26 @@ import { useRdpSession } from "./useRdpSession";type RdpContentProps = {account: TPamAccount;projectId: string;+ resourceId: string;+ resourceName: string;reason?: string;};-export const RdpContent = ({ account, projectId, reason }: RdpContentProps) => {+export const RdpContent = ({+ account,+ projectId,+ resourceId,+ resourceName,+ reason+}: RdpContentProps) => {const [sessionEnded, setSessionEnded] = useState(false);- const destination = account.resource?.name ?? "";-const { containerRef, isConnected, error, disconnect, reconnect } = useRdpSession({accountId: account.id,projectId,- resourceName: account.resource?.name ?? "",- destination,+ resourceId,+ resourceName,+ destination: resourceName,reason,onSessionEnd: () => setSessionEnded(true)});@@ -103,7 +110,7 @@ export const RdpContent = ({ account, projectId, reason }: RdpContentProps) => {<div className="flex items-center gap-4"><span><span className="text-mineshaft-400">Resource:</span>{" "}- <span className="text-mineshaft-300">{account.resource?.name}</span>+ <span className="text-mineshaft-300">{resourceName}</span></span><span className="text-mineshaft-500">|</span><span>diff --git a/frontend/src/pages/pam/PamAccountAccessPage/useRdpSession.ts b/frontend/src/pages/pam/PamAccountAccessPage/useRdpSession.tsindex b267a02502..a8ceaad17a 100644--- a/frontend/src/pages/pam/PamAccountAccessPage/useRdpSession.ts+++ b/frontend/src/pages/pam/PamAccountAccessPage/useRdpSession.ts@@ -78,6 +78,7 @@ const ensureRdpBackend = () => {type UseRdpSessionOptions = {accountId: string;projectId: string;+ resourceId: string;resourceName: string;destination: string;reason?: string;@@ -87,6 +88,7 @@ type UseRdpSessionOptions = {export const useRdpSession = ({accountId,projectId,+ resourceId,resourceName,destination,reason,@@ -140,7 +142,7 @@ export const useRdpSession = ({const { data } = await apiRequest.post<{ ticket: string }>(`/api/v1/pam/accounts/${accountId}/web-access-ticket`,- { projectId, reason }+ { projectId, reason, resourceId });if (!isCurrent()) return;const proxyAddress = buildProxyAddress(data.ticket);@@ -202,7 +204,16 @@ export const useRdpSession = ({containerRef.current.appendChild(el);elementRef.current = el;- }, [accountId, projectId, reason, destination, resourceName, buildProxyAddress, teardown]);+ }, [+ accountId,+ projectId,+ resourceId,+ reason,+ destination,+ resourceName,+ buildProxyAddress,+ teardown+ ]);const handleConnectError = useCallback((err: unknown) => {let message = "Failed to start RDP session";