Skip to content

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

feat(pam): add browser-based RDP client, session recording, and docs

bernie-g9134bda15270
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 2781a98712..0fded91401 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
@@ -772,10 +772,26 @@ export const registerPamAccountRouter = async (server: FastifyZodProvider) => {
}
},
wsHandler: async (connection: WebSocket, req) => {
+ // WASM sends frames before ticket validation finishes; buffer them
+ const preAuthMessages: { data: Buffer; isBinary: boolean }[] = [];
+ const preAuthHandler = (raw: Buffer | ArrayBuffer | Buffer[], isBinary: boolean) => {
+ let buf: Buffer;
+ if (Buffer.isBuffer(raw)) {
+ buf = raw;
+ } else if (Array.isArray(raw)) {
+ buf = Buffer.concat(raw);
+ } else {
+ buf = Buffer.from(raw);
+ }
+ preAuthMessages.push({ data: buf, isBinary });
+ };
+ connection.on("message", preAuthHandler);
+
try {
const ticketValue = req.query.ticket;
const separatorIndex = ticketValue.indexOf(":");
if (separatorIndex === -1) {
+ connection.off("message", preAuthHandler);
connection.close(4001, "Invalid or expired ticket");
return;
}
@@ -790,6 +806,7 @@ export const registerPamAccountRouter = async (server: FastifyZodProvider) => {
});
if (!tokenRecord?.payload) {
+ connection.off("message", preAuthHandler);
connection.close(4001, "Invalid or expired ticket");
return;
}
@@ -817,6 +834,7 @@ export const registerPamAccountRouter = async (server: FastifyZodProvider) => {
.parse(JSON.parse(tokenRecord.payload));
if (payload.accountId !== req.params.accountId) {
+ connection.off("message", preAuthHandler);
connection.close(4001, "Invalid or expired ticket");
return;
}
@@ -834,9 +852,12 @@ export const registerPamAccountRouter = async (server: FastifyZodProvider) => {
userId,
actorIp: req.realIp ?? "",
actorUserAgent: req.headers["user-agent"] ?? "",
- reason: payload.reason
+ reason: payload.reason,
+ preAuthMessages,
+ preAuthHandler
});
} catch (err) {
+ connection.off("message", preAuthHandler);
logger.error(err, "WebSocket ticket validation failed");
connection.close(4001, "Invalid or expired ticket");
}
diff --git a/backend/src/ee/routes/v1/pam-session-router.ts b/backend/src/ee/routes/v1/pam-session-router.ts
index bbd78ba559..da6607518d 100644
--- a/backend/src/ee/routes/v1/pam-session-router.ts
+++ b/backend/src/ee/routes/v1/pam-session-router.ts
@@ -395,6 +395,7 @@ export const registerPamSessionRouter = async (server: FastifyZodProvider) => {
config: {
rateLimit: writeLimit
},
+ bodyLimit: 64 * 1024 * 1024,
schema: {
description: "Upload a PAM session event batch",
params: z.object({
diff --git a/backend/src/ee/services/pam-web-access/pam-postgres-session-handler.test.ts b/backend/src/ee/services/pam-web-access/pam-postgres-session-handler.test.ts
index 8d724124e6..51e1317ccd 100644
--- a/backend/src/ee/services/pam-web-access/pam-postgres-session-handler.test.ts
+++ b/backend/src/ee/services/pam-web-access/pam-postgres-session-handler.test.ts
@@ -108,6 +108,8 @@ function createMockContext(): TSessionContext & { sentMessages: TWebSocketServer
sendSessionEnd: vi.fn(),
isNearSessionExpiry: vi.fn().mockReturnValue(false),
onCleanup: vi.fn(),
+ earlyMessages: [],
+ releaseEarlyBuffer: vi.fn(),
sentMessages
};
}
diff --git a/backend/src/ee/services/pam-web-access/pam-rdp-session-handler.ts b/backend/src/ee/services/pam-web-access/pam-rdp-session-handler.ts
new file mode 100644
index 0000000000..548270d8ca
--- /dev/null
+++ b/backend/src/ee/services/pam-web-access/pam-rdp-session-handler.ts
@@ -0,0 +1,106 @@
+import net from "node:net";
+
+import { logger } from "@app/lib/logger";
+
+import { TSessionContext, TSessionHandlerResult } from "./pam-web-access-types";
+
+const RDP_TCP_CONNECT_TIMEOUT_MS = 30_000;
+
+const wsRawToBuffer = (raw: Buffer | ArrayBuffer | Buffer[]): Buffer => {
+ if (Buffer.isBuffer(raw)) return raw;
+ if (Array.isArray(raw)) return Buffer.concat(raw);
+ return Buffer.from(raw);
+};
+
+export const handleRdpSession = async (ctx: TSessionContext): Promise<TSessionHandlerResult> => {
+ const { socket, relayPort, sessionId, onCleanup, earlyMessages, releaseEarlyBuffer } = ctx;
+
+ const tcpSocket = new net.Socket();
+ let cleanedUp = false;
+
+ const teardown = () => {
+ if (cleanedUp) return;
+ cleanedUp = true;
+ try {
+ tcpSocket.destroy();
+ } catch (err) {
+ logger.debug(err, "rdp session: error destroying tcp socket");
+ }
+ };
+
+ return new Promise<TSessionHandlerResult>((resolve, reject) => {
+ const connectTimeout = setTimeout(() => {
+ logger.error({ sessionId }, "rdp session: relay connect timed out");
+ teardown();
+ reject(new Error("RDP relay connection timed out"));
+ }, RDP_TCP_CONNECT_TIMEOUT_MS);
+
+ tcpSocket.once("connect", () => {
+ clearTimeout(connectTimeout);
+
+ releaseEarlyBuffer();
+ for (const msg of earlyMessages) {
+ if (!msg.isBinary) continue;
+ if (tcpSocket.writable) {
+ tcpSocket.write(msg.data);
+ }
+ }
+
+ socket.on("message", (raw: Buffer | ArrayBuffer | Buffer[], isBinary: boolean) => {
+ if (cleanedUp || tcpSocket.destroyed || !tcpSocket.writable) return;
+ if (!isBinary) return;
+ const buf = wsRawToBuffer(raw);
+ if (buf.length === 0) return;
+ try {
+ tcpSocket.write(buf);
+ } catch {
+ teardown();
+ }
+ });
+
+ tcpSocket.on("data", (chunk: Buffer) => {
+ if (cleanedUp || socket.readyState !== socket.OPEN) return;
+ socket.send(chunk, { binary: true }, (err) => {
+ if (err) {
+ logger.error(err, "rdp session: ws send failed");
+ teardown();
+ }
+ });
+ });
+
+ tcpSocket.on("close", () => {
+ if (cleanedUp) return;
+ logger.info({ sessionId }, "rdp session: tcp socket closed");
+ onCleanup();
+ try {
+ socket.close();
+ } catch (err) {
+ logger.debug(err, "rdp session: error closing ws after tcp close");
+ }
+ });
+
+ tcpSocket.on("error", (err) => {
+ logger.error(err, "rdp session: tcp socket error");
+ if (!cleanedUp) {
+ onCleanup();
+ }
+ teardown();
+ });
+
+ resolve({
+ cleanup: async () => {
+ teardown();
+ }
+ });
+ });
+
+ tcpSocket.once("error", (err) => {
+ clearTimeout(connectTimeout);
+ logger.error(err, "rdp session: failed to connect to relay");
+ teardown();
+ reject(err);
+ });
+
+ tcpSocket.connect(relayPort, "127.0.0.1");
+ });
+};
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.ts
index 97c4cc294c..26265fac52 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
@@ -50,12 +50,14 @@ import { TSSHAccountCredentials, TSSHResourceConnectionDetails } from "../pam-re
import { TPamSessionDALFactory } from "../pam-session/pam-session-dal";
import { PamSessionStatus } from "../pam-session/pam-session-enums";
import { handlePostgresSession } from "./pam-postgres-session-handler";
+import { handleRdpSession } from "./pam-rdp-session-handler";
import { handleRedisSession } from "./pam-redis-session-handler";
import { handleSSHSession } from "./pam-ssh-session-handler";
import {
DEFAULT_WEB_SESSION_DURATION_MS,
MAX_WEB_SESSIONS_PER_USER,
SessionEndReason,
+ TEarlyBufferedMsg,
TerminalServerMessageType,
TIssueWebSocketTicketDTO,
TSessionContext,
@@ -66,7 +68,7 @@ import {
WS_PING_INTERVAL_MS
} from "./pam-web-access-types";
-const SUPPORTED_WEB_ACCESS_RESOURCES = [PamResource.Postgres, PamResource.SSH, PamResource.Redis];
+const SUPPORTED_WEB_ACCESS_RESOURCES = [PamResource.Postgres, PamResource.SSH, PamResource.Redis, PamResource.Windows];
type TPamWebAccessServiceFactoryDep = {
pamAccountDAL: Pick<TPamAccountDALFactory, "findById" | "findMetadataByAccountIds">;
@@ -107,6 +109,8 @@ type THandleWebSocketConnectionDTO = {
actorIp: string;
actorUserAgent: string;
reason?: string | null;
+ preAuthMessages: TEarlyBufferedMsg[];
+ preAuthHandler: (raw: Buffer | ArrayBuffer | Buffer[], isBinary: boolean) => void;
};
export const pamWebAccessServiceFactory = ({
pamAccountDAL,
@@ -142,11 +146,7 @@ export const pamWebAccessServiceFactory = ({
sendMessage(socket, { type: TerminalServerMessageType.SessionEnd, reason });
};
- /**
- * Send a session_end message and close the socket only after the message has been flushed.
- * This avoids the race where socket.close() sends a close frame before the session_end
- * data frame reaches the client.
- */
+ // Flushes the session_end frame before sending the WS close frame
const sendSessionEndAndClose = (socket: WebSocket, reason: SessionEndReason): void => {
try {
if (socket.readyState === socket.OPEN) {
@@ -202,6 +202,13 @@ export const pamWebAccessServiceFactory = ({
});
}
+ const activeWebSessionCount = await pamSessionDAL.countActiveWebSessions(actor.id, projectId);
+ if (activeWebSessionCount >= MAX_WEB_SESSIONS_PER_USER) {
+ throw new BadRequestError({
+ message: `You have reached the maximum of ${MAX_WEB_SESSIONS_PER_USER} active web access sessions. Close an existing session and try again.`
+ });
+ }
+
// Approval policy check
const approvalPolicy = APPROVAL_POLICY_FACTORY_MAP[ApprovalPolicyType.PamAccess](ApprovalPolicyType.PamAccess);
@@ -232,7 +239,6 @@ export const pamWebAccessServiceFactory = ({
});
}
- // If there isn't a policy in place, continue with checking permission
const { permission } = await permissionService.getProjectPermission({
actor: actor.type,
actorId: actor.id,
@@ -255,8 +261,7 @@ export const pamWebAccessServiceFactory = ({
);
}
- // Reason check is intentionally placed after the approval/permission gates so
- // its distinct error code does not leak policy configuration to unauthorized actors.
+ // After auth gates so error code doesn't leak policy config to unauthorized actors
if (account.policyId) {
const policy = await pamAccountPolicyDAL.findById(account.policyId);
const policyRules = (policy?.rules ?? {}) as TPolicyRules;
@@ -283,8 +288,7 @@ export const pamWebAccessServiceFactory = ({
);
if (!org) throw new NotFoundError({ message: `Organization with ID '${project.orgId}' not found` });
- // Determine which MFA method to use
- // Priority: org-enforced > user-selected > email as fallback
+ // Priority: org-enforced > user-selected > email fallback
const orgMfaMethod = org.enforceMfa ? (org.selectedMfaMethod as MfaMethod | null) : undefined;
const userMfaMethod = actorUser.isMfaEnabled ? (actorUser.selectedMfaMethod as MfaMethod | null) : undefined;
const mfaMethod = (orgMfaMethod ?? userMfaMethod ?? MfaMethod.EMAIL) as MfaMethod;
@@ -365,8 +369,15 @@ export const pamWebAccessServiceFactory = ({
actorName,
actorIp,
actorUserAgent,
- reason: accessReason
+ reason: accessReason,
+ preAuthMessages,
+ preAuthHandler
}: THandleWebSocketConnectionDTO): Promise<void> => {
+ const earlyMessages: TEarlyBufferedMsg[] = preAuthMessages;
+ const releaseEarlyBuffer = () => {
+ socket.off("message", preAuthHandler);
+ };
+
let session: { id: string } | null = null;
let cleanedUp = false;
let handlerResult: TSessionHandlerResult | null = null;
@@ -381,8 +392,6 @@ export const pamWebAccessServiceFactory = ({
let idleTimer: ReturnType<typeof setTimeout> | null = null;
const cleanup = async () => {
- // Each operation is individually idempotent — null checks skip already-cleaned resources,
- // and finally blocks ensure references are cleared even if an operation throws.
if (expiryTimer) {
clearTimeout(expiryTimer);
expiryTimer = null;
@@ -396,7 +405,6 @@ export const pamWebAccessServiceFactory = ({
idleTimer = null;
}
- // Handler cleanup (closes protocol client through the tunnel)
if (handlerResult) {
try {
await handlerResult.cleanup();
@@ -407,7 +415,7 @@ export const pamWebAccessServiceFactory = ({
}
}
- // Close relay tunnel (MUST come after handler cleanup)
+ // Must come after handler cleanup
if (relayServer) {
try {
await relayServer.cleanup();
@@ -418,9 +426,18 @@ export const pamWebAccessServiceFactory = ({
}
}
- // Best-effort ALPN session cancellation (fire-and-forget).
- // Triggers gateway-side cleanup: log upload, and session end via API.
- // If this fails, the scheduled queue job will expire the session at expiresAt time.
+ if (session) {
+ try {
+ await pamSessionDAL.updateById(session.id, {
+ status: PamSessionStatus.Ended,
+ endedAt: new Date()
+ });
+ } catch (err) {
+ logger.debug(err, "Error marking session ended in cleanup");
+ }
+ }
+
+ // Best-effort: triggers gateway-side cleanup (fire-and-forget)
if (relayCerts) {
const certs = relayCerts;
relayCerts = null;
@@ -554,18 +571,17 @@ export const pamWebAccessServiceFactory = ({
};
// 5. START TUNNEL
+ const tunnelProtocol =
+ resource.resourceType === PamResource.Windows ? GatewayProxyProtocol.PamRdpBrowser : GatewayProxyProtocol.Pam;
relayServer = await setupRelayServer({
- protocol: GatewayProxyProtocol.Pam,
+ protocol: tunnelProtocol,
relayHost: certs.relayHost,
relay: certs.relay,
gateway: certs.gateway,
longLived: true
});
- // Tunnel drop detection
- // The gateway cert expires on the gateway's clock, which may be slightly
- // ahead of ours (clock skew). A 30s tolerance lets us correctly attribute
- // tunnel teardowns near session end as normal completion rather than errors.
+ // 30s tolerance for clock skew between us and gateway
const isNearSessionExpiry = () => Date.now() >= expiresAt.getTime() - 30_000;
// Bound message helpers for handlers
@@ -586,7 +602,9 @@ export const pamWebAccessServiceFactory = ({
sendMessage: boundSendMessage,
sendSessionEnd: boundSendSessionEnd,
isNearSessionExpiry,
- onCleanup: handlerCleanup
+ onCleanup: handlerCleanup,
+ earlyMessages,
+ releaseEarlyBuffer
};
// 6. CONNECT TO RESOURCE (dispatch by type)
@@ -605,6 +623,8 @@ export const pamWebAccessServiceFactory = ({
connectionDetails: resourceConnectionDetails as TRedisResourceConnectionDetails,
credentials: accountCredentials as TRedisAccountCredentials
});
+ } else if (resource.resourceType === PamResource.Windows) {
+ handlerResult = await handleRdpSession(ctx);
}
// 7. ACTIVATE SESSION
@@ -645,7 +665,6 @@ export const pamWebAccessServiceFactory = ({
resetIdleTimer();
- // WebSocket keep-alive to survive ALB idle timeout (default 60s)
let isAlive = true;
socket.on("pong", () => {
diff --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.ts
index 3e9f487afe..3e84271496 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
@@ -48,6 +48,8 @@ export const WS_PING_INTERVAL_MS = 30000;
// only when the tab has been hidden/backgrounded for the full window.
export const WS_IDLE_TIMEOUT_MS = 10 * 60 * 1000;
+export type TEarlyBufferedMsg = { data: Buffer; isBinary: boolean };
+
export type TSessionContext = {
socket: WebSocket;
relayPort: number;
@@ -57,6 +59,11 @@ export type TSessionContext = {
sendSessionEnd: (reason: SessionEndReason) => void;
isNearSessionExpiry: () => boolean;
onCleanup: () => void;
+ /** Frames received before the handler took over. Drain after the relay
+ * is up; the protocol-agnostic handler (RDP) replays them. */
+ earlyMessages: TEarlyBufferedMsg[];
+ /** Detach the early-buffer listener so the handler can install its own. */
+ releaseEarlyBuffer: () => void;
};
export type TSessionHandlerResult = {
diff --git a/backend/src/lib/gateway-v2/gateway-v2.ts b/backend/src/lib/gateway-v2/gateway-v2.ts
index 3a5a7fcc96..4964528a2b 100644
--- a/backend/src/lib/gateway-v2/gateway-v2.ts
+++ b/backend/src/lib/gateway-v2/gateway-v2.ts
@@ -89,6 +89,7 @@ export const createGatewayConnection = async (
[GatewayProxyProtocol.Tcp]: "infisical-tcp-proxy",
[GatewayProxyProtocol.Ping]: "infisical-ping",
[GatewayProxyProtocol.Pam]: "infisical-pam-proxy",
+ [GatewayProxyProtocol.PamRdpBrowser]: "infisical-pam-rdp-browser",
[GatewayProxyProtocol.PamSessionCancellation]: "infisical-pam-session-cancellation"
};
@@ -205,25 +206,23 @@ export const setupRelayServer = async ({
}
}
- // Bidirectional data forwarding
- clientConn.pipe(gatewayConn);
- gatewayConn.pipe(clientConn);
-
- // Handle connection closure
- clientConn.on("close", () => {
+ const destroyAll = () => {
+ clientConn.destroy();
relayConn.destroy();
gatewayConn.destroy();
- });
+ };
- relayConn.on("close", () => {
- clientConn.destroy();
- gatewayConn.destroy();
- });
+ clientConn.on("error", () => destroyAll());
+ relayConn.on("error", () => destroyAll());
+ gatewayConn.on("error", () => destroyAll());
- gatewayConn.on("close", () => {
- clientConn.destroy();
- relayConn.destroy();
- });
+ // Bidirectional data forwarding
+ clientConn.pipe(gatewayConn);
+ gatewayConn.pipe(clientConn);
+
+ clientConn.on("close", destroyAll);
+ relayConn.on("close", destroyAll);
+ gatewayConn.on("close", destroyAll);
} catch (err) {
const errorMsg = err instanceof Error ? err.message : String(err);
relayErrorMsg.push(errorMsg);
diff --git a/backend/src/lib/gateway/types.ts b/backend/src/lib/gateway/types.ts
index 4b821db872..f4bfc27f40 100644
--- a/backend/src/lib/gateway/types.ts
+++ b/backend/src/lib/gateway/types.ts
@@ -9,6 +9,7 @@ export enum GatewayProxyProtocol {
Tcp = "tcp",
Ping = "ping",
Pam = "pam",
+ PamRdpBrowser = "pam-rdp-browser",
PamSessionCancellation = "pam-session-cancellation"
}
diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml
index 65aaa73a87..860668396b 100644
--- a/docker-compose.dev.yml
+++ b/docker-compose.dev.yml
@@ -166,6 +166,7 @@ services:
volumes:
- ./frontend/src:/app/src/ # mounted whole src to avoid missing reload on new files
- ./frontend/public:/app/public
+ - ./frontend/index.html:/app/index.html
env_file: .env
pgadmin:
diff --git a/docs/docs.json b/docs/docs.json
index 162235f515..bed56369a2 100644
--- a/docs/docs.json
+++ b/docs/docs.json
@@ -947,7 +947,8 @@
"documentation/platform/pam/product-reference/web-access/overview",
"documentation/platform/pam/product-reference/web-access/postgresql",
"documentation/platform/pam/product-reference/web-access/redis",
- "documentation/platform/pam/product-reference/web-access/ssh"
+ "documentation/platform/pam/product-reference/web-access/ssh",
+ "documentation/platform/pam/product-reference/web-access/windows-rdp"
]
}
]
diff --git a/docs/documentation/platform/pam/getting-started/resources/windows-server.mdx b/docs/documentation/platform/pam/getting-started/resources/windows-server.mdx
index ebd27935c0..69c6e77ab6 100644
--- a/docs/documentation/platform/pam/getting-started/resources/windows-server.mdx
+++ b/docs/documentation/platform/pam/getting-started/resources/windows-server.mdx
@@ -123,6 +123,13 @@ A PAM Account represents a specific Windows user account on the server. You can
</Step>
</Steps>
+## Access Windows Server
+
+You can connect to a Windows Server account using either the browser-based RDP client or the Infisical CLI.
+
+- **Web Access**: Connect directly from your browser with a full graphical desktop session. See [Windows RDP Web Access](/documentation/platform/pam/product-reference/web-access/windows-rdp) for details.
+- **CLI Access**: Run `infisical pam rdp access` to start a local RDP proxy that launches your native RDP client (mstsc, Microsoft Remote Desktop, or FreeRDP). Credentials are injected automatically.
+
## Domain Join
Windows Server resources can be associated with an [Active Directory](/documentation/platform/pam/getting-started/resources/active-directory) resource to represent domain membership. This is useful for organizing your infrastructure and understanding which servers belong to which AD domain.
diff --git a/docs/documentation/platform/pam/product-reference/session-recording.mdx b/docs/documentation/platform/pam/product-reference/session-recording.mdx
index 79270be678..11c19b0ba9 100644
--- a/docs/documentation/platform/pam/product-reference/session-recording.mdx
+++ b/docs/documentation/platform/pam/product-reference/session-recording.mdx
@@ -23,6 +23,9 @@ The content captured during a session depends on the type of resource being acce
<Accordion title="SSH Sessions">
Infisical captures all commands executed and their corresponding responses, including timestamps for each action.
</Accordion>
+ <Accordion title="Windows RDP Sessions">
+ Infisical captures keyboard input, mouse events, and screen frames with timestamps for each action.
+ </Accordion>
</AccordionGroup>
## Viewing Recordings
diff --git a/docs/documentation/platform/pam/product-reference/web-access/overview.mdx b/docs/documentation/platform/pam/product-reference/web-access/overview.mdx
index 1d6f52be5b..f5412e5950 100644
--- a/docs/documentation/platform/pam/product-reference/web-access/overview.mdx
+++ b/docs/documentation/platform/pam/product-reference/web-access/overview.mdx
@@ -7,7 +7,7 @@ description: "Access PAM-managed resources directly from your browser."
Infisical PAM Web Access provides a browser-based portal for interacting with your infrastructure directly from your browser via the Infisical dashboard — no client tools or CLI required.
<Info>
- Web Access currently supports **PostgreSQL** databases (with visual table browsing, inline editing, and a SQL query runner), **Redis** servers, and **SSH** servers.
+ Web Access currently supports **PostgreSQL** databases (with visual table browsing, inline editing, and a SQL query runner), **Redis** servers, **SSH** servers, and **Windows** servers via RDP.
</Info>
## How It Works
@@ -54,4 +54,7 @@ Sessions that exceed the idle timeout or max duration are automatically terminat
<Card title="SSH" icon="terminal" href="/documentation/platform/pam/product-reference/web-access/ssh">
Full interactive shell session via browser-based terminal.
</Card>
+ <Card title="Windows RDP" icon="desktop" href="/documentation/platform/pam/product-reference/web-access/windows-rdp">
+ Full graphical remote desktop session via browser-based RDP client.
+ </Card>
</CardGroup>
diff --git a/docs/documentation/platform/pam/product-reference/web-access/windows-rdp.mdx b/docs/documentation/platform/pam/product-reference/web-access/windows-rdp.mdx
new file mode 100644
index 0000000000..0113554f59
--- /dev/null
+++ b/docs/documentation/platform/pam/product-reference/web-access/windows-rdp.mdx
@@ -0,0 +1,70 @@
+---
+title: "Windows RDP Web Access"
+sidebarTitle: "Windows RDP"
+description: "Connect to Windows servers via RDP directly from your browser."
+---
+
+Infisical PAM supports two ways to connect to a Windows server via RDP:
+
+- **Browser**: Connect directly from the Infisical dashboard with a full graphical desktop session. No RDP client installation required.
+- **Native RDP Client**: Use the Infisical CLI to start a local RDP proxy that launches your native RDP client (mstsc, Microsoft Remote Desktop, or FreeRDP). Run `infisical pam rdp access` to start a session.
+
+In both cases, credentials are injected automatically from the PAM account configuration. You never need to enter or see them.
+
+## Connecting via Browser
+
+<Steps>
+ <Step title="Navigate to Account">
+ Go to the **Resources** tab in your PAM project, open the Windows Server resource, and find the account you want to access. Click the **Connect** button next to the account.
+
+ ![Account Connect Button](/images/pam/product-reference/web-access/rdp-account-connect-button.png)
+
+ Alternatively, if you are on the account page, click the **Access** button.
+
+ ![Account Page Access Button](/images/pam/product-reference/web-access/rdp-account-page-access-button.png)
+ </Step>
+
+ <Step title="Connect in Browser">
+ In the connect modal, click **Connect in Browser**. A new tab opens and begins establishing the RDP session. A loading indicator is displayed while Infisical sets up the secure tunnel through the Gateway to your Windows server.
+
+ ![Connect in Browser](/images/pam/product-reference/web-access/rdp-connect-in-browser.png)
+ </Step>
+
+ <Step title="Interact with the Desktop">
+ Once connected, you have a full graphical desktop session. Keyboard input, mouse clicks, and scrolling all work as expected.
+
+ ![Connected Desktop](/images/pam/product-reference/web-access/rdp-connected-desktop.png)
+ </Step>
+
+ <Step title="End Session">
+ Click the **Disconnect** button in the status bar at the bottom of the screen. You can reconnect from the same page using the **Reconnect** button.
+ </Step>
+</Steps>
+
+## Session Recording
+
+RDP sessions are recorded by the Gateway as a full video capture of the remote desktop, including keyboard input, mouse events, and screen frames with timestamps. Administrators can play back the recording from the **Sessions** page in the PAM project to review exactly what the user saw and did.
+
+See [Session Recording](/documentation/platform/pam/product-reference/session-recording) for details on how recordings are captured, uploaded, and stored.
+
+RDP session recordings require external S3 storage to be configured. See [External Storage](/documentation/platform/pam/product-reference/external-storage) for setup instructions.
+
+## Active Directory
+
+Windows Server resources can be associated with an Active Directory domain. When a server is domain-joined, accounts from the AD domain can be used to access the server through RDP web access. The Gateway injects the domain credentials (including the domain name) into the RDP connection automatically.
+
+See [Windows Server - Domain Join](/documentation/platform/pam/getting-started/resources/windows-server#domain-join) and [Active Directory](/documentation/platform/pam/getting-started/resources/active-directory) for setup instructions.
+
+## FAQ
+
+<AccordionGroup>
+ <Accordion title="What RDP features are supported in the browser?">
+ Keyboard input (including shortcuts like Ctrl+Alt+Del and Alt+Tab), mouse interaction, and screen display with automatic scaling are supported. Clipboard sharing, file/drive redirection, audio redirection, and printer redirection are not currently supported.
+ </Accordion>
+ <Accordion title="What happens if my connection drops?">
+ If your browser tab closes or the network connection drops, the session ends. Click **Reconnect** to start a new session. Sessions cannot be resumed after a disconnect, so any unsaved work on the remote desktop will be lost.
+ </Accordion>
+ <Accordion title="Does the session stay active if I switch to another tab?">
+ The session continues running in the background, but it will automatically close after 10 minutes of inactivity. Switch back to the tab periodically to keep the session alive.
+ </Accordion>
+</AccordionGroup>
diff --git a/docs/images/pam/product-reference/web-access/rdp-account-connect-button.png b/docs/images/pam/product-reference/web-access/rdp-account-connect-button.png
new file mode 100644
index 0000000000..38a286d689
Binary files /dev/null and b/docs/images/pam/product-reference/web-access/rdp-account-connect-button.png differ
diff --git a/docs/images/pam/product-reference/web-access/rdp-account-page-access-button.png b/docs/images/pam/product-reference/web-access/rdp-account-page-access-button.png
new file mode 100644
index 0000000000..2a004ed01f
Binary files /dev/null and b/docs/images/pam/product-reference/web-access/rdp-account-page-access-button.png differ
diff --git a/docs/images/pam/product-reference/web-access/rdp-connect-in-browser.png b/docs/images/pam/product-reference/web-access/rdp-connect-in-browser.png
new file mode 100644
index 0000000000..ed24f579b8
Binary files /dev/null and b/docs/images/pam/product-reference/web-access/rdp-connect-in-browser.png differ
diff --git a/docs/images/pam/product-reference/web-access/rdp-connected-desktop.png b/docs/images/pam/product-reference/web-access/rdp-connected-desktop.png
new file mode 100644
index 0000000000..0d24e97195
Binary files /dev/null and b/docs/images/pam/product-reference/web-access/rdp-connected-desktop.png differ
diff --git a/frontend/index.html b/frontend/index.html
index 38ccb729bd..0336350989 100644
--- a/frontend/index.html
+++ b/frontend/index.html
@@ -12,8 +12,8 @@
style-src 'self' 'unsafe-inline' https://hcaptcha.com https://*.hcaptcha.com https://tags.srv.stackadapt.com;
child-src https://api.stripe.com;
frame-src https://js.stripe.com/ https://api.stripe.com https://www.youtube.com/ https://hcaptcha.com https://*.hcaptcha.com https://www.googletagmanager.com;
- connect-src 'self' wss://nexus-websocket-a.intercom.io https://api-iam.intercom.io https://api.heroku.com/ https://id.heroku.com/oauth/authorize https://id.heroku.com/oauth/token https://checkout.stripe.com https://app.posthog.com https://*.posthog.com https://api.stripe.com https://api.pwnedpasswords.com http://127.0.0.1:* https://hcaptcha.com https://*.hcaptcha.com https://www.googletagmanager.com https://www.google-analytics.com https://region1.google-analytics.com https://analytics.google.com https://stats.g.doubleclick.net https://googleads.g.doubleclick.net https://forms.hscollectedforms.net https://forms.hubspot.com https://api.hubapi.com https://*.ads.linkedin.com https://tags.srv.stackadapt.com https://api.unifyintent.com https://pixel-config.reddit.com https://cdn.jsdelivr.net/npm/@lottiefiles/[email protected]/dist/dotlottie-player.wasm https://*.s3.amazonaws.com https://*.s3.us-east-1.amazonaws.com https://*.s3.us-east-2.amazonaws.com https://*.s3.us-west-1.amazonaws.com https://*.s3.us-west-2.amazonaws.com https://*.s3.af-south-1.amazonaws.com https://*.s3.ap-east-1.amazonaws.com https://*.s3.ap-south-1.amazonaws.com https://*.s3.ap-south-2.amazonaws.com https://*.s3.ap-southeast-1.amazonaws.com https://*.s3.ap-southeast-2.amazonaws.com https://*.s3.ap-southeast-3.amazonaws.com https://*.s3.ap-southeast-4.amazonaws.com https://*.s3.ap-northeast-1.amazonaws.com https://*.s3.ap-northeast-2.amazonaws.com https://*.s3.ap-northeast-3.amazonaws.com https://*.s3.ca-central-1.amazonaws.com https://*.s3.eu-central-1.amazonaws.com https://*.s3.eu-central-2.amazonaws.com https://*.s3.eu-west-1.amazonaws.com https://*.s3.eu-west-2.amazonaws.com https://*.s3.eu-west-3.amazonaws.com https://*.s3.eu-south-1.amazonaws.com https://*.s3.eu-south-2.amazonaws.com https://*.s3.eu-north-1.amazonaws.com https://*.s3.me-south-1.amazonaws.com https://*.s3.me-central-1.amazonaws.com https://*.s3.sa-east-1.amazonaws.com https://*.s3.us-gov-east-1.amazonaws.com https://*.s3.us-gov-west-1.amazonaws.com;
- img-src 'self' https://static.intercomassets.com https://js.intercomcdn.com https://downloads.intercomcdn.com https://*.stripe.com https://i.ytimg.com/ data: https://images.ctfassets.net https://www.googletagmanager.com https://www.google-analytics.com https://www.google.com https://googleads.g.doubleclick.net https://www.googleadservices.com https://track.hubspot.com https://forms.hubspot.com https://forms.hsforms.com https://alb.reddit.com https://*.ads.linkedin.com;
+ connect-src 'self' data: wss://nexus-websocket-a.intercom.io https://api-iam.intercom.io https://api.heroku.com/ https://id.heroku.com/oauth/authorize https://id.heroku.com/oauth/token https://checkout.stripe.com https://app.posthog.com https://*.posthog.com https://api.stripe.com https://api.pwnedpasswords.com http://127.0.0.1:* https://hcaptcha.com https://*.hcaptcha.com https://www.googletagmanager.com https://www.google-analytics.com https://region1.google-analytics.com https://analytics.google.com https://stats.g.doubleclick.net https://googleads.g.doubleclick.net https://forms.hscollectedforms.net https://forms.hubspot.com https://api.hubapi.com https://*.ads.linkedin.com https://tags.srv.stackadapt.com https://api.unifyintent.com https://pixel-config.reddit.com https://cdn.jsdelivr.net/npm/@lottiefiles/[email protected]/dist/dotlottie-player.wasm https://*.s3.amazonaws.com https://*.s3.us-east-1.amazonaws.com https://*.s3.us-east-2.amazonaws.com https://*.s3.us-west-1.amazonaws.com https://*.s3.us-west-2.amazonaws.com https://*.s3.af-south-1.amazonaws.com https://*.s3.ap-east-1.amazonaws.com https://*.s3.ap-south-1.amazonaws.com https://*.s3.ap-south-2.amazonaws.com https://*.s3.ap-southeast-1.amazonaws.com https://*.s3.ap-southeast-2.amazonaws.com https://*.s3.ap-southeast-3.amazonaws.com https://*.s3.ap-southeast-4.amazonaws.com https://*.s3.ap-northeast-1.amazonaws.com https://*.s3.ap-northeast-2.amazonaws.com https://*.s3.ap-northeast-3.amazonaws.com https://*.s3.ca-central-1.amazonaws.com https://*.s3.eu-central-1.amazonaws.com https://*.s3.eu-central-2.amazonaws.com https://*.s3.eu-west-1.amazonaws.com https://*.s3.eu-west-2.amazonaws.com https://*.s3.eu-west-3.amazonaws.com https://*.s3.eu-south-1.amazonaws.com https://*.s3.eu-south-2.amazonaws.com https://*.s3.eu-north-1.amazonaws.com https://*.s3.me-south-1.amazonaws.com https://*.s3.me-central-1.amazonaws.com https://*.s3.sa-east-1.amazonaws.com https://*.s3.us-gov-east-1.amazonaws.com https://*.s3.us-gov-west-1.amazonaws.com;
+ img-src 'self' https://static.intercomassets.com https://js.intercomcdn.com https://downloads.intercomcdn.com https://*.stripe.com https://i.ytimg.com/ data: https://www.googletagmanager.com https://www.google-analytics.com https://www.google.com https://googleads.g.doubleclick.net https://www.googleadservices.com https://track.hubspot.com https://forms.hubspot.com https://forms.hsforms.com https://alb.reddit.com https://*.ads.linkedin.com;
media-src 'self' https://js.intercomcdn.com;
font-src 'self' https://fonts.intercomcdn.com/ https://fonts.gstatic.com;
"
diff --git a/frontend/package-lock.json b/frontend/package-lock.json
index 014233e40d..66f2456ca6 100644
--- a/frontend/package-lock.json
+++ b/frontend/package-lock.json
@@ -16,6 +16,8 @@
"@codemirror/state": "^6.6.0",
"@codemirror/view": "^6.41.0",
"@dagrejs/dagre": "^1.1.4",
+ "@devolutions/iron-remote-desktop": "^0.10.1",
+ "@devolutions/iron-remote-desktop-rdp": "^0.6.1",
"@dnd-kit/core": "^6.3.1",
"@dnd-kit/modifiers": "^9.0.0",
"@dnd-kit/react": "^0.3.0",
@@ -612,6 +614,16 @@
"integrity": "sha512-P5LUNhtbj6YfI3iJjw5EL9eUAG6OitD0W3fWQcpQjDRc/QIsL0tRNuO1PcDvPccWL1fSTXXdE1ds+l95DV/OFA==",
"license": "MIT"
},
+ "node_modules/@devolutions/iron-remote-desktop": {
+ "version": "0.10.1",
+ "resolved": "https://registry.npmjs.org/@devolutions/iron-remote-desktop/-/iron-remote-desktop-0.10.1.tgz",
+ "integrity": "sha512-VwY71hnlxnVc/ueZ8IYwV12VPcAvbI5fVa/HpKY1fDcok91QydbUsvMkdg4UPckqe2eDDKRXzeJntwf9db5xaA=="
+ },
+ "node_modules/@devolutions/iron-remote-desktop-rdp": {
+ "version": "0.6.1",
+ "resolved": "https://registry.npmjs.org/@devolutions/iron-remote-desktop-rdp/-/iron-remote-desktop-rdp-0.6.1.tgz",
+ "integrity": "sha512-f5QgznYioXqEeGSZXoTdmGHH9VVIzGRjFuL745B5VRCyGolrromxmQeHO9Gxy5zDAvl9z4/FL26SqDrm/f47aw=="
+ },
"node_modules/@dnd-kit/abstract": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/@dnd-kit/abstract/-/abstract-0.3.0.tgz",
diff --git a/frontend/package.json b/frontend/package.json
index 503b93165a..cf0c274919 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -44,6 +44,8 @@
"@codemirror/state": "^6.6.0",
"@codemirror/view": "^6.41.0",
"@dagrejs/dagre": "^1.1.4",
+ "@devolutions/iron-remote-desktop": "^0.10.1",
+ "@devolutions/iron-remote-desktop-rdp": "^0.6.1",
"@dnd-kit/core": "^6.3.1",
"@dnd-kit/modifiers": "^9.0.0",
"@dnd-kit/react": "^0.3.0",
diff --git a/frontend/src/pages/pam/PamAccountAccessPage/PamAccountAccessPage.tsx b/frontend/src/pages/pam/PamAccountAccessPage/PamAccountAccessPage.tsx
index 0d9fa7a016..aa7ec86905 100644
--- a/frontend/src/pages/pam/PamAccountAccessPage/PamAccountAccessPage.tsx
+++ b/frontend/src/pages/pam/PamAccountAccessPage/PamAccountAccessPage.tsx
@@ -5,6 +5,7 @@ import { useParams } from "@tanstack/react-router";
import { PamResourceType, TPamAccount, useGetPamAccountById } from "@app/hooks/api/pam";
import { PamDataExplorerPage } from "@app/pages/pam/PamDataExplorerPage/PamDataExplorerPage";
+import { RdpContent } from "./RdpContent";
import { ReasonGate } from "./ReasonGate";
import { useWebAccessSession } from "./useWebAccessSession";
@@ -136,6 +137,9 @@ 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} />;
+ }
return (
<TerminalContent
account={account}
diff --git a/frontend/src/pages/pam/PamAccountAccessPage/RdpContent.tsx b/frontend/src/pages/pam/PamAccountAccessPage/RdpContent.tsx
new file mode 100644
index 0000000000..603f396562
--- /dev/null
+++ b/frontend/src/pages/pam/PamAccountAccessPage/RdpContent.tsx
@@ -0,0 +1,126 @@
+import { useState } from "react";
+import { faCircleXmark, faPlugCircleXmark } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+
+import { ContentLoader } from "@app/components/v2";
+import { TPamAccount } from "@app/hooks/api/pam";
+
+import { useRdpSession } from "./useRdpSession";
+
+type RdpContentProps = {
+ account: TPamAccount;
+ projectId: string;
+ reason?: string;
+};
+
+export const RdpContent = ({ account, projectId, 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,
+ reason,
+ onSessionEnd: () => setSessionEnded(true)
+ });
+
+ const handleReconnect = () => {
+ setSessionEnded(false);
+ reconnect();
+ };
+
+ const isConnecting = !isConnected && !error && !sessionEnded;
+
+ let statusLabel = "Connecting";
+ let statusDotClass = "bg-yellow-500";
+ if (isConnected) {
+ statusLabel = "Connected";
+ statusDotClass = "bg-green-500";
+ } else if (error) {
+ statusLabel = `Error: ${error}`;
+ statusDotClass = "bg-red-500";
+ } else if (sessionEnded) {
+ statusLabel = "Disconnected";
+ statusDotClass = "bg-mineshaft-400";
+ }
+
+ return (
+ <div className="flex h-dvh w-screen flex-col bg-[#0d1117]">
+ <div ref={containerRef} className="relative min-h-0 flex-1 overflow-hidden">
+ {isConnecting && (
+ <ContentLoader
+ text="Connecting to remote desktop..."
+ className="absolute inset-0 z-10 h-full"
+ />
+ )}
+ {error && (
+ <div className="absolute inset-0 z-10 flex flex-col items-center justify-center gap-4">
+ <FontAwesomeIcon icon={faPlugCircleXmark} size="3x" className="text-red-500/80" />
+ <div className="flex flex-col items-center gap-1">
+ <p className="text-sm font-medium text-mineshaft-200">Connection failed</p>
+ <p className="max-w-md text-center text-xs text-mineshaft-400">{error}</p>
+ </div>
+ <button
+ type="button"
+ onClick={handleReconnect}
+ className="mt-2 rounded border border-mineshaft-500 px-4 py-1.5 text-xs text-mineshaft-300 transition-colors hover:border-green-700 hover:text-green-400"
+ >
+ Reconnect
+ </button>
+ </div>
+ )}
+ {sessionEnded && !error && (
+ <div className="absolute inset-0 z-10 flex flex-col items-center justify-center gap-4">
+ <FontAwesomeIcon icon={faCircleXmark} size="3x" className="text-mineshaft-400" />
+ <p className="text-sm text-mineshaft-300">Session ended</p>
+ <button
+ type="button"
+ onClick={handleReconnect}
+ className="mt-2 rounded border border-mineshaft-500 px-4 py-1.5 text-xs text-mineshaft-300 transition-colors hover:border-green-700 hover:text-green-400"
+ >
+ Reconnect
+ </button>
+ </div>
+ )}
+ </div>
+ <div className="flex h-[33px] shrink-0 items-center justify-between border-t border-mineshaft-600 bg-mineshaft-800 px-3 text-xs">
+ <span className="flex items-center gap-1.5">
+ <span className={`inline-block size-2 rounded-full ${statusDotClass}`} />
+ <span className="text-mineshaft-300">{statusLabel}</span>
+ {isConnected && (
+ <button
+ type="button"
+ onClick={disconnect}
+ className="ml-2 text-mineshaft-400 hover:text-red-400"
+ >
+ Disconnect
+ </button>
+ )}
+ {(sessionEnded || error) && (
+ <button
+ type="button"
+ onClick={handleReconnect}
+ className="ml-2 text-mineshaft-400 hover:text-green-400"
+ >
+ Reconnect
+ </button>
+ )}
+ </span>
+ <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>
+ <span className="text-mineshaft-500">|</span>
+ <span>
+ <span className="text-mineshaft-400">Account:</span>{" "}
+ <span className="text-mineshaft-300">{account.name}</span>
+ </span>
+ </div>
+ </div>
+ </div>
+ );
+};
diff --git a/frontend/src/pages/pam/PamAccountAccessPage/useRdpSession.ts b/frontend/src/pages/pam/PamAccountAccessPage/useRdpSession.ts
new file mode 100644
index 0000000000..d2cee137d1
--- /dev/null
+++ b/frontend/src/pages/pam/PamAccountAccessPage/useRdpSession.ts
@@ -0,0 +1,223 @@
+import { useCallback, useEffect, useRef, useState } from "react";
+import type { UserInteraction } from "@devolutions/iron-remote-desktop";
+import { Backend, init as initRdpBackend } from "@devolutions/iron-remote-desktop-rdp";
+import axios from "axios";
+
+import { createNotification } from "@app/components/notifications";
+import { apiRequest } from "@app/config/request";
+
+import "@devolutions/iron-remote-desktop";
+
+// Fixed credentials expected by the gateway acceptor's NLA exchange
+const BROWSER_ACCEPTOR_USERNAME = "infisical";
+const BROWSER_ACCEPTOR_PASSWORD = "infisical";
+
+// Must match backend connector_config defaults
+const DEFAULT_DESKTOP_SIZE = { width: 1920, height: 1080 };
+
+const STATUS_BAR_HEIGHT = 33;
+
+// WASM reads window.innerHeight for fit scaling, not the container
+const innerHeightDescriptor = Object.getOwnPropertyDescriptor(window, "innerHeight") ??
+ Object.getOwnPropertyDescriptor(Window.prototype, "innerHeight");
+let innerHeightOverrideCount = 0;
+
+function applyInnerHeightOverride() {
+ if (innerHeightOverrideCount === 0 && innerHeightDescriptor?.get) {
+ Object.defineProperty(window, "innerHeight", {
+ configurable: true,
+ get() {
+ return (innerHeightDescriptor.get!.call(window) as number) - STATUS_BAR_HEIGHT;
+ }
+ });
+ }
+ innerHeightOverrideCount += 1;
+}
+
+function removeInnerHeightOverride() {
+ innerHeightOverrideCount -= 1;
+ if (innerHeightOverrideCount === 0 && innerHeightDescriptor) {
+ Object.defineProperty(window, "innerHeight", innerHeightDescriptor);
+ }
+}
+
+// Loads IronRDP WASM; must run exactly once per page load
+let rdpBackendInitialized: Promise<void> | null = null;
+const ensureRdpBackend = () => {
+ if (!rdpBackendInitialized) {
+ rdpBackendInitialized = initRdpBackend("INFO");
+ }
+ return rdpBackendInitialized;
+};
+
+type UseRdpSessionOptions = {
+ accountId: string;
+ projectId: string;
+ resourceName: string;
+ destination: string;
+ reason?: string;
+ onSessionEnd?: () => void;
+};
+
+export const useRdpSession = ({
+ accountId,
+ projectId,
+ resourceName,
+ destination,
+ reason,
+ onSessionEnd
+}: UseRdpSessionOptions) => {
+ const containerRef = useRef<HTMLDivElement | null>(null);
+ const elementRef = useRef<HTMLElement | null>(null);
+ const userInteractionRef = useRef<UserInteraction | null>(null);
+ const [isConnected, setIsConnected] = useState(false);
+ const [error, setError] = useState<string | null>(null);
+ const onSessionEndRef = useRef(onSessionEnd);
+ useEffect(() => {
+ onSessionEndRef.current = onSessionEnd;
+ }, [onSessionEnd]);
+
+ const buildProxyAddress = useCallback(
+ (ticket: string) => {
+ const { protocol, host } = window.location;
+ const wsProtocol = protocol === "https:" ? "wss:" : "ws:";
+ return `${wsProtocol}//${host}/api/v1/pam/accounts/${accountId}/web-access?ticket=${encodeURIComponent(ticket)}`;
+ },
+ [accountId]
+ );
+
+ const teardown = useCallback(() => {
+ try {
+ userInteractionRef.current?.shutdown();
+ } catch {
+ // can throw if called before connect resolves
+ }
+ userInteractionRef.current = null;
+ if (elementRef.current && elementRef.current.parentElement) {
+ elementRef.current.parentElement.removeChild(elementRef.current);
+ }
+ elementRef.current = null;
+ setIsConnected(false);
+ }, []);
+
+ const generationRef = useRef(0);
+
+ const connect = useCallback(async () => {
+ if (!containerRef.current) return;
+ teardown();
+ setError(null);
+ generationRef.current += 1;
+ const gen = generationRef.current;
+ const isCurrent = () => gen === generationRef.current;
+
+ await ensureRdpBackend();
+ if (!isCurrent()) return;
+
+ const { data } = await apiRequest.post<{ ticket: string }>(
+ `/api/v1/pam/accounts/${accountId}/web-access-ticket`,
+ { projectId, reason }
+ );
+ if (!isCurrent()) return;
+ const proxyAddress = buildProxyAddress(data.ticket);
+
+ const el = document.createElement("iron-remote-desktop");
+ (el as unknown as { module: typeof Backend }).module = Backend;
+ el.setAttribute("scale", "fit");
+ el.setAttribute("flexcenter", "true");
+
+ el.style.width = "100%";
+ el.style.height = "100%";
+
+ el.addEventListener("ready", (event) => {
+ if (!isCurrent()) return;
+ const ui = (event as CustomEvent<{ irgUserInteraction: UserInteraction }>).detail
+ .irgUserInteraction;
+ userInteractionRef.current = ui;
+ ui.setEnableClipboard(false);
+
+ const config = ui
+ .configBuilder()
+ .withUsername(BROWSER_ACCEPTOR_USERNAME)
+ .withPassword(BROWSER_ACCEPTOR_PASSWORD)
+ .withDestination(destination || resourceName)
+ .withProxyAddress(proxyAddress)
+ .withAuthToken("infisical")
+ .withDesktopSize(DEFAULT_DESKTOP_SIZE)
+ .build();
+
+ ui.connect(config)
+ .then(async (sessionInfo) => {
+ if (!isCurrent()) return;
+ setIsConnected(true);
+ ui.setVisibility(true);
+ await sessionInfo.run();
+ })
+ .catch((err) => {
+ const ironErr = err as {
+ backtrace?: () => string;
+ kind?: () => unknown;
+ };
+ const kind = ironErr.kind?.();
+ // eslint-disable-next-line no-console
+ console.error("RDP session failed:", kind, ironErr.backtrace?.() ?? err);
+ if (!isCurrent()) return;
+ const detail = typeof kind === "string" ? kind : String(err);
+ setError(detail);
+ createNotification({
+ type: "error",
+ text: `RDP connection failed: ${detail}`
+ });
+ })
+ .finally(() => {
+ if (!isCurrent()) return;
+ setIsConnected(false);
+ onSessionEndRef.current?.();
+ });
+ });
+
+ containerRef.current.appendChild(el);
+ elementRef.current = el;
+ }, [accountId, projectId, reason, destination, resourceName, buildProxyAddress, teardown]);
+
+ const handleConnectError = useCallback((err: unknown) => {
+ let message = "Failed to start RDP session";
+ if (axios.isAxiosError(err)) {
+ const apiMessage = (err.response?.data as { message?: string } | undefined)?.message;
+ if (apiMessage) message = apiMessage;
+ } else if (err instanceof Error && err.message) {
+ message = err.message;
+ }
+ setError(message);
+ createNotification({ type: "error", text: message });
+ setIsConnected(false);
+ onSessionEndRef.current?.();
+ }, []);
+
+ useEffect(() => {
+ applyInnerHeightOverride();
+ connect().catch(handleConnectError);
+ return () => {
+ generationRef.current += 1;
+ teardown();
+ removeInnerHeightOverride();
+ };
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, []);
+
+ const disconnect = useCallback(() => {
+ teardown();
+ onSessionEndRef.current?.();
+ }, [teardown]);
+
+ const reconnect = useCallback(() => {
+ connect().catch(handleConnectError);
+ }, [connect, handleConnectError]);
+
+ return {
+ containerRef,
+ isConnected,
+ error,
+ disconnect,
+ reconnect
+ };
+};
diff --git a/frontend/src/pages/pam/PamAccountsPage/components/PamAccessAccountModal.tsx b/frontend/src/pages/pam/PamAccountsPage/components/PamAccessAccountModal.tsx
index 152e9bfa9d..e584d36758 100644
--- a/frontend/src/pages/pam/PamAccountsPage/components/PamAccessAccountModal.tsx
+++ b/frontend/src/pages/pam/PamAccountsPage/components/PamAccessAccountModal.tsx
@@ -133,7 +133,8 @@ export const PamAccessAccountModal = ({
const showWebAccess =
targetResource?.resourceType === PamResourceType.Postgres ||
targetResource?.resourceType === PamResourceType.SSH ||
- targetResource?.resourceType === PamResourceType.Redis;
+ targetResource?.resourceType === PamResourceType.Redis ||
+ targetResource?.resourceType === PamResourceType.Windows;
return (
<Modal isOpen={isOpen} onOpenChange={onOpenChange}>
diff --git a/nginx/default.conf b/nginx/default.conf
index b6209e9af2..b17831706d 100644
--- a/nginx/default.conf
+++ b/nginx/default.conf
@@ -28,6 +28,21 @@ server {
proxy_cookie_path / "/; HttpOnly; SameSite=strict";
}
+ location ~ ^/api/v1/pam/sessions/[^/]+/event-batches$ {
+ client_max_body_size 100M;
+
+ proxy_set_header X-Real-IP $remote_addr;
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+
+ proxy_set_header Host $http_host;
+ proxy_set_header X-NginX-Proxy true;
+
+ proxy_pass http://backend:4000;
+ proxy_redirect off;
+
+ proxy_cookie_path / "/; HttpOnly; SameSite=strict";
+ }
+
location ~ ^/(api|secret-scanning/webhooks) {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
diff --git a/nginx/default.dev.conf b/nginx/default.dev.conf
index 7d306d5c58..66f144cbf1 100644
--- a/nginx/default.dev.conf
+++ b/nginx/default.dev.conf
@@ -35,6 +35,21 @@ server {
proxy_cookie_path / "/; SameSite=strict";
}
+ location ~ ^/api/v1/pam/sessions/[^/]+/event-batches$ {
+ client_max_body_size 100M;
+
+ proxy_set_header X-Real-IP $remote_addr;
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+
+ proxy_set_header Host $http_host;
+ proxy_set_header X-NginX-Proxy true;
+
+ proxy_pass http://api;
+ proxy_redirect off;
+
+ proxy_cookie_path / "/; SameSite=strict";
+ }
+
location ~ ^/(api|secret-scanning/webhooks) {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;