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
feat(pam): windows server
x0322057af3b669bafb
diff --git a/backend/src/db/migrations/20260206001358_windows-server-pam-resource.ts b/backend/src/db/migrations/20260206001358_windows-server-pam-resource.tsnew file mode 100644index 0000000000..fbd371b771--- /dev/null+++ b/backend/src/db/migrations/20260206001358_windows-server-pam-resource.ts@@ -0,0 +1,46 @@+import { Knex } from "knex";++import { TableName } from "../schemas";++export async function up(knex: Knex): Promise<void> {+ // Add adServerResourceId to pam_resources (optional reference to another resource for AD Server linkage)+ if (await knex.schema.hasTable(TableName.PamResource)) {+ const hasAdServerResourceId = await knex.schema.hasColumn(TableName.PamResource, "adServerResourceId");+ if (!hasAdServerResourceId) {+ await knex.schema.alterTable(TableName.PamResource, (t) => {+ t.uuid("adServerResourceId").nullable();+ t.foreign("adServerResourceId").references("id").inTable(TableName.PamResource).onDelete("SET NULL");+ });+ }+ }++ // Add metadata (JSONB, not encrypted) to pam_accounts+ if (await knex.schema.hasTable(TableName.PamAccount)) {+ const hasMetadata = await knex.schema.hasColumn(TableName.PamAccount, "metadata");+ if (!hasMetadata) {+ await knex.schema.alterTable(TableName.PamAccount, (t) => {+ t.jsonb("metadata").nullable();+ });+ }+ }+}++export async function down(knex: Knex): Promise<void> {+ if (await knex.schema.hasTable(TableName.PamResource)) {+ const hasAdServerResourceId = await knex.schema.hasColumn(TableName.PamResource, "adServerResourceId");+ if (hasAdServerResourceId) {+ await knex.schema.alterTable(TableName.PamResource, (t) => {+ t.dropColumn("adServerResourceId");+ });+ }+ }++ if (await knex.schema.hasTable(TableName.PamAccount)) {+ const hasMetadata = await knex.schema.hasColumn(TableName.PamAccount, "metadata");+ if (hasMetadata) {+ await knex.schema.alterTable(TableName.PamAccount, (t) => {+ t.dropColumn("metadata");+ });+ }+ }+}diff --git a/backend/src/db/schemas/pam-accounts.ts b/backend/src/db/schemas/pam-accounts.tsindex 69d167bfe6..0dd6b39df2 100644--- a/backend/src/db/schemas/pam-accounts.ts+++ b/backend/src/db/schemas/pam-accounts.ts@@ -24,7 +24,8 @@ export const PamAccountsSchema = z.object({lastRotatedAt: z.date().nullable().optional(),rotationStatus: z.string().nullable().optional(),encryptedLastRotationMessage: zodBuffer.nullable().optional(),- requireMfa: z.boolean().default(false).nullable().optional()+ requireMfa: z.boolean().default(false).nullable().optional(),+ metadata: z.unknown().nullable().optional()});export type TPamAccounts = z.infer<typeof PamAccountsSchema>;diff --git a/backend/src/db/schemas/pam-resources.ts b/backend/src/db/schemas/pam-resources.tsindex bbd974e2f9..a1f2bfa7d8 100644--- a/backend/src/db/schemas/pam-resources.ts+++ b/backend/src/db/schemas/pam-resources.ts@@ -19,7 +19,8 @@ export const PamResourcesSchema = z.object({createdAt: z.date(),updatedAt: z.date(),encryptedRotationAccountCredentials: zodBuffer.nullable().optional(),- encryptedResourceMetadata: zodBuffer.nullable().optional()+ encryptedResourceMetadata: zodBuffer.nullable().optional(),+ adServerResourceId: z.string().uuid().nullable().optional()});export type TPamResources = z.infer<typeof PamResourcesSchema>;diff --git a/backend/src/ee/routes/v1/pam-account-routers/index.ts b/backend/src/ee/routes/v1/pam-account-routers/index.tsindex 1e86a94882..55182b418d 100644--- a/backend/src/ee/routes/v1/pam-account-routers/index.ts+++ b/backend/src/ee/routes/v1/pam-account-routers/index.ts@@ -29,6 +29,11 @@ import {SanitizedSSHAccountWithResourceSchema,UpdateSSHAccountSchema} from "@app/ee/services/pam-resource/ssh/ssh-resource-schemas";+import {+ CreateWindowsAccountSchema,+ SanitizedWindowsAccountWithResourceSchema,+ UpdateWindowsAccountSchema+} from "@app/ee/services/pam-resource/windows-server/windows-server-resource-schemas";import { registerPamAccountEndpoints } from "./pam-account-endpoints";@@ -86,5 +91,14 @@ export const PAM_ACCOUNT_REGISTER_ROUTER_MAP: Record<PamResource, (server: FasticreateAccountSchema: CreateAwsIamAccountSchema,updateAccountSchema: UpdateAwsIamAccountSchema});+ },+ [PamResource.Windows]: async (server: FastifyZodProvider) => {+ registerPamAccountEndpoints({+ server,+ resourceType: PamResource.Windows,+ accountResponseSchema: SanitizedWindowsAccountWithResourceSchema,+ createAccountSchema: CreateWindowsAccountSchema,+ updateAccountSchema: UpdateWindowsAccountSchema+ });}};diff --git a/backend/src/ee/routes/v1/pam-account-routers/pam-account-endpoints.ts b/backend/src/ee/routes/v1/pam-account-routers/pam-account-endpoints.tsindex 11adbc4bb7..cb5f2b0fab 100644--- a/backend/src/ee/routes/v1/pam-account-routers/pam-account-endpoints.ts+++ b/backend/src/ee/routes/v1/pam-account-routers/pam-account-endpoints.ts@@ -25,6 +25,7 @@ export const registerPamAccountEndpoints = <C extends TPamAccount>({rotationEnabled?: C["rotationEnabled"];rotationIntervalSeconds?: C["rotationIntervalSeconds"];requireMfa?: C["requireMfa"];+ metadata?: Record<string, unknown>;}>;updateAccountSchema: z.ZodType<{credentials?: C["credentials"];@@ -33,6 +34,7 @@ export const registerPamAccountEndpoints = <C extends TPamAccount>({rotationEnabled?: C["rotationEnabled"];rotationIntervalSeconds?: C["rotationIntervalSeconds"];requireMfa?: C["requireMfa"];+ metadata?: Record<string, unknown>;}>;accountResponseSchema: z.ZodTypeAny;}) => {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 ae146808bb..e868d1e514 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@@ -11,6 +11,7 @@ import { GatewayAccessResponseSchema } from "@app/ee/services/pam-resource/pam-rimport { SanitizedPostgresAccountWithResourceSchema } from "@app/ee/services/pam-resource/postgres/postgres-resource-schemas";import { SanitizedRedisAccountWithResourceSchema } from "@app/ee/services/pam-resource/redis/redis-resource-schemas";import { SanitizedSSHAccountWithResourceSchema } from "@app/ee/services/pam-resource/ssh/ssh-resource-schemas";+import { SanitizedWindowsAccountWithResourceSchema } from "@app/ee/services/pam-resource/windows-server/windows-server-resource-schemas";import { BadRequestError } from "@app/lib/errors";import { removeTrailingSlash } from "@app/lib/fn";import { ms } from "@app/lib/ms";@@ -26,7 +27,8 @@ const SanitizedAccountSchema = z.union([SanitizedPostgresAccountWithResourceSchema,SanitizedMySQLAccountWithResourceSchema,SanitizedRedisAccountWithResourceSchema,- SanitizedAwsIamAccountWithResourceSchema+ SanitizedAwsIamAccountWithResourceSchema,+ SanitizedWindowsAccountWithResourceSchema]);const ListPamAccountsResponseSchema = z.object({diff --git a/backend/src/ee/routes/v1/pam-resource-routers/index.ts b/backend/src/ee/routes/v1/pam-resource-routers/index.tsindex a5b041fb39..64c5e8f61d 100644--- a/backend/src/ee/routes/v1/pam-resource-routers/index.ts+++ b/backend/src/ee/routes/v1/pam-resource-routers/index.ts@@ -29,6 +29,11 @@ import {SanitizedSSHResourceSchema,UpdateSSHResourceSchema} from "@app/ee/services/pam-resource/ssh/ssh-resource-schemas";+import {+ CreateWindowsResourceSchema,+ SanitizedWindowsResourceSchema,+ UpdateWindowsResourceSchema+} from "@app/ee/services/pam-resource/windows-server/windows-server-resource-schemas";import {registerPamResourceEndpoints,@@ -92,5 +97,14 @@ export const PAM_RESOURCE_REGISTER_ROUTER_MAP: Record<PamResource, (server: FastcreateResourceSchema: CreateRedisResourceSchema,updateResourceSchema: UpdateRedisResourceSchema});+ },+ [PamResource.Windows]: async (server: FastifyZodProvider) => {+ registerPamResourceEndpoints({+ server,+ resourceType: PamResource.Windows,+ resourceResponseSchema: SanitizedWindowsResourceSchema,+ createResourceSchema: CreateWindowsResourceSchema,+ updateResourceSchema: UpdateWindowsResourceSchema+ });}};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.tsindex 7b4ac763c7..2de5eda10d 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@@ -26,6 +26,10 @@ import {SanitizedSSHResourceSchema,SSHResourceListItemSchema} from "@app/ee/services/pam-resource/ssh/ssh-resource-schemas";+import {+ SanitizedWindowsResourceSchema,+ WindowsResourceListItemSchema+} from "@app/ee/services/pam-resource/windows-server/windows-server-resource-schemas";import { OrderByDirection } from "@app/lib/types";import { readLimit } from "@app/server/config/rateLimiter";import { verifyAuth } from "@app/server/plugins/auth/verify-auth";@@ -37,7 +41,8 @@ const SanitizedResourceSchema = z.union([SanitizedSSHResourceSchema,SanitizedKubernetesResourceSchema,SanitizedAwsIamResourceSchema,- SanitizedRedisResourceSchema+ SanitizedRedisResourceSchema,+ SanitizedWindowsResourceSchema]);const ResourceOptionsSchema = z.discriminatedUnion("resource", [@@ -46,7 +51,8 @@ const ResourceOptionsSchema = z.discriminatedUnion("resource", [SSHResourceListItemSchema,KubernetesResourceListItemSchema,AwsIamResourceListItemSchema,- RedisResourceListItemSchema+ RedisResourceListItemSchema,+ WindowsResourceListItemSchema]);export const registerPamResourceRouter = async (server: FastifyZodProvider) => {diff --git a/backend/src/ee/services/pam-account/pam-account-service.ts b/backend/src/ee/services/pam-account/pam-account-service.tsindex 7634e7614c..113057552d 100644--- a/backend/src/ee/services/pam-account/pam-account-service.ts+++ b/backend/src/ee/services/pam-account/pam-account-service.ts@@ -127,7 +127,8 @@ export const pamAccountServiceFactory = ({folderId,rotationEnabled,rotationIntervalSeconds,- requireMfa+ requireMfa,+ metadata}: TCreateAccountDTO,actor: OrgServiceActor) => {@@ -209,7 +210,8 @@ export const pamAccountServiceFactory = ({folderId,rotationEnabled,rotationIntervalSeconds,- requireMfa+ requireMfa,+ metadata: metadata ?? null});return {@@ -240,7 +242,8 @@ export const pamAccountServiceFactory = ({name,rotationEnabled,rotationIntervalSeconds,- requireMfa+ requireMfa,+ metadata}: TUpdateAccountDTO,actor: OrgServiceActor) => {@@ -299,6 +302,10 @@ export const pamAccountServiceFactory = ({updateDoc.rotationIntervalSeconds = rotationIntervalSeconds;}+ if (metadata !== undefined) {+ updateDoc.metadata = metadata;+ }+if (credentials !== undefined) {const connectionDetails = await decryptResourceConnectionDetails({projectId: account.projectId,@@ -775,6 +782,10 @@ export const pamAccountServiceFactory = ({kmsService);+ // Temporarily disable access to Windows Server+ if (resourceType === PamResource.Windows)+ throw new BadRequestError({ message: `Windows resources cannot be accessed at this time` });+const user = await userDAL.findById(actor.id);if (!user) throw new NotFoundError({ message: `User with ID '${actor.id}' not found` });diff --git a/backend/src/ee/services/pam-account/pam-account-types.ts b/backend/src/ee/services/pam-account/pam-account-types.tsindex c7a1afae81..0ee59078fe 100644--- a/backend/src/ee/services/pam-account/pam-account-types.ts+++ b/backend/src/ee/services/pam-account/pam-account-types.ts@@ -9,6 +9,7 @@ export type TCreateAccountDTO = Pick<"name" | "description" | "credentials" | "folderId" | "resourceId" | "rotationIntervalSeconds" | "requireMfa"> & {rotationEnabled?: boolean;+ metadata?: Record<string, unknown>;};export type TUpdateAccountDTO = Partial<Omit<TCreateAccountDTO, "folderId" | "resourceId">> & {diff --git a/backend/src/ee/services/pam-resource/pam-resource-enums.ts b/backend/src/ee/services/pam-resource/pam-resource-enums.tsindex 07222342c8..4ca6005ed6 100644--- a/backend/src/ee/services/pam-resource/pam-resource-enums.ts+++ b/backend/src/ee/services/pam-resource/pam-resource-enums.ts@@ -4,7 +4,8 @@ export enum PamResource {SSH = "ssh",Kubernetes = "kubernetes",AwsIam = "aws-iam",- Redis = "redis"+ Redis = "redis",+ Windows = "windows"}export enum PamResourceOrderBy {diff --git a/backend/src/ee/services/pam-resource/pam-resource-factory.ts b/backend/src/ee/services/pam-resource/pam-resource-factory.tsindex 895f7702fc..6401130825 100644--- a/backend/src/ee/services/pam-resource/pam-resource-factory.ts+++ b/backend/src/ee/services/pam-resource/pam-resource-factory.ts@@ -5,6 +5,7 @@ import { TPamAccountCredentials, TPamResourceConnectionDetails, TPamResourceFactimport { redisResourceFactory } from "./redis/redis-resource-factory";import { sqlResourceFactory } from "./shared/sql/sql-resource-factory";import { sshResourceFactory } from "./ssh/ssh-resource-factory";+import { windowsResourceFactory } from "./windows-server/windows-server-resource-factory";type TPamResourceFactoryImplementation = TPamResourceFactory<TPamResourceConnectionDetails, TPamAccountCredentials>;@@ -14,5 +15,6 @@ export const PAM_RESOURCE_FACTORY_MAP: Record<PamResource, TPamResourceFactoryIm[PamResource.SSH]: sshResourceFactory as TPamResourceFactoryImplementation,[PamResource.Kubernetes]: kubernetesResourceFactory as TPamResourceFactoryImplementation,[PamResource.AwsIam]: awsIamResourceFactory as TPamResourceFactoryImplementation,- [PamResource.Redis]: redisResourceFactory as TPamResourceFactoryImplementation+ [PamResource.Redis]: redisResourceFactory as TPamResourceFactoryImplementation,+ [PamResource.Windows]: windowsResourceFactory as TPamResourceFactoryImplementation};diff --git a/backend/src/ee/services/pam-resource/pam-resource-fns.ts b/backend/src/ee/services/pam-resource/pam-resource-fns.tsindex f75a7b0da4..9b50e72277 100644--- a/backend/src/ee/services/pam-resource/pam-resource-fns.ts+++ b/backend/src/ee/services/pam-resource/pam-resource-fns.ts@@ -9,6 +9,7 @@ import { getMySQLResourceListItem } from "./mysql/mysql-resource-fns";import { TPamResource, TPamResourceConnectionDetails, TPamResourceMetadata } from "./pam-resource-types";import { getPostgresResourceListItem } from "./postgres/postgres-resource-fns";import { getRedisResourceListItem } from "./redis/redis-resource-fns";+import { getWindowsResourceListItem } from "./windows-server/windows-server-resource-fns";export const listResourceOptions = () => {return [@@ -16,7 +17,8 @@ export const listResourceOptions = () => {getMySQLResourceListItem(),getAwsIamResourceListItem(),getKubernetesResourceListItem(),- getRedisResourceListItem()+ getRedisResourceListItem(),+ getWindowsResourceListItem()].sort((a, b) => a.name.localeCompare(b.name));};diff --git a/backend/src/ee/services/pam-resource/pam-resource-types.ts b/backend/src/ee/services/pam-resource/pam-resource-types.tsindex 5cfa91d592..0968249bf4 100644--- a/backend/src/ee/services/pam-resource/pam-resource-types.ts+++ b/backend/src/ee/services/pam-resource/pam-resource-types.ts@@ -39,6 +39,12 @@ import {TSSHResourceConnectionDetails,TSSHResourceMetadata} from "./ssh/ssh-resource-types";+import {+ TWindowsAccount,+ TWindowsAccountCredentials,+ TWindowsResource,+ TWindowsResourceConnectionDetails+} from "./windows-server/windows-server-resource-types";// Resource typesexport type TPamResource =@@ -47,14 +53,16 @@ export type TPamResource =| TSSHResource| TAwsIamResource| TKubernetesResource- | TRedisResource;+ | TRedisResource+ | TWindowsResource;export type TPamResourceConnectionDetails =| TPostgresResourceConnectionDetails| TMySQLResourceConnectionDetails| TSSHResourceConnectionDetails| TKubernetesResourceConnectionDetails| TAwsIamResourceConnectionDetails- | TRedisResourceConnectionDetails;+ | TRedisResourceConnectionDetails+ | TWindowsResourceConnectionDetails;export type TPamResourceMetadata = TSSHResourceMetadata;// Account types@@ -64,7 +72,8 @@ export type TPamAccount =| TSSHAccount| TAwsIamAccount| TKubernetesAccount- | TRedisAccount;+ | TRedisAccount+ | TWindowsAccount;export type TPamAccountCredentials =| TPostgresAccountCredentials@@ -73,7 +82,8 @@ export type TPamAccountCredentials =| TSSHAccountCredentials| TKubernetesAccountCredentials| TAwsIamAccountCredentials- | TRedisAccountCredentials;+ | TRedisAccountCredentials+ | TWindowsAccountCredentials;// Resource DTOsexport type TCreateResourceDTO = Pick<TPamResource, "name" | "connectionDetails" | "resourceType" | "projectId"> & {diff --git a/backend/src/ee/services/pam-resource/windows-server/windows-server-resource-enums.ts b/backend/src/ee/services/pam-resource/windows-server/windows-server-resource-enums.tsnew file mode 100644index 0000000000..d7999084c7--- /dev/null+++ b/backend/src/ee/services/pam-resource/windows-server/windows-server-resource-enums.ts@@ -0,0 +1,8 @@+export enum WindowsProtocol {+ RDP = "rdp"+}++export enum WindowsAccountType {+ User = "user",+ Service = "service"+}diff --git a/backend/src/ee/services/pam-resource/windows-server/windows-server-resource-factory.ts b/backend/src/ee/services/pam-resource/windows-server/windows-server-resource-factory.tsnew file mode 100644index 0000000000..b1ed782847--- /dev/null+++ b/backend/src/ee/services/pam-resource/windows-server/windows-server-resource-factory.ts@@ -0,0 +1,192 @@+import net from "node:net";++import axios from "axios";++import { BadRequestError } from "@app/lib/errors";+import { GatewayProxyProtocol } from "@app/lib/gateway";+import { withGatewayV2Proxy } from "@app/lib/gateway-v2/gateway-v2";+import { logger } from "@app/lib/logger";++import { verifyHostInputValidity } from "../../dynamic-secret/dynamic-secret-fns";+import { TGatewayV2ServiceFactory } from "../../gateway-v2/gateway-v2-service";+import { PamResource } from "../pam-resource-enums";+import {+ TPamResourceFactory,+ TPamResourceFactoryRotateAccountCredentials,+ TPamResourceFactoryValidateAccountCredentials+} from "../pam-resource-types";+import { TWindowsAccountCredentials, TWindowsResourceConnectionDetails } from "./windows-server-resource-types";++const EXTERNAL_REQUEST_TIMEOUT = 10 * 1000;+const WINRM_HTTP_PORT = 5985;++const executeWithGateway = async <T>(+ config: {+ connectionDetails: TWindowsResourceConnectionDetails;+ resourceType: PamResource;+ gatewayId: string;+ targetPortOverride?: number;+ },+ gatewayV2Service: Pick<TGatewayV2ServiceFactory, "getPlatformConnectionDetailsByGatewayId">,+ operation: (proxyPort: number) => Promise<T>+): Promise<T> => {+ const { connectionDetails, gatewayId, targetPortOverride } = config;+ const [targetHost] = await verifyHostInputValidity({+ host: connectionDetails.hostname,+ isGateway: true,+ isDynamicSecret: false+ });+ const platformConnectionDetails = await gatewayV2Service.getPlatformConnectionDetailsByGatewayId({+ gatewayId,+ targetHost,+ targetPort: targetPortOverride ?? connectionDetails.port+ });++ if (!platformConnectionDetails) {+ throw new BadRequestError({ message: "Unable to connect to gateway, no platform connection details found" });+ }++ return withGatewayV2Proxy(+ async (proxyPort) => {+ return operation(proxyPort);+ },+ {+ protocol: GatewayProxyProtocol.Tcp,+ relayHost: platformConnectionDetails.relayHost,+ gateway: platformConnectionDetails.gateway,+ relay: platformConnectionDetails.relay+ }+ );+};++export const windowsResourceFactory: TPamResourceFactory<+ TWindowsResourceConnectionDetails,+ TWindowsAccountCredentials+> = (resourceType, connectionDetails, gatewayId, gatewayV2Service) => {+ const validateConnection = async () => {+ if (!gatewayId) {+ throw new BadRequestError({ message: "Gateway ID is required" });+ }++ try {+ await executeWithGateway({ connectionDetails, gatewayId, resourceType }, gatewayV2Service, async (proxyPort) => {+ return new Promise<void>((resolve, reject) => {+ const socket = new net.Socket();+ let settled = false;++ const finish = (error?: Error) => {+ if (settled) return;+ settled = true;+ socket.destroy();+ if (error) reject(error);+ else resolve();+ };++ socket.setTimeout(EXTERNAL_REQUEST_TIMEOUT);+ socket.on("timeout", () => finish(new Error("Connection timeout")));+ socket.on("error", (err) => finish(err));+ socket.on("close", () => finish(new Error("Connection closed before RDP handshake completed")));++ socket.on("connect", () => {+ // Send a minimal RDP X.224 Connection Request to verify the server speaks RDP.+ // TPKT header (4 bytes) + X.224 CR (7 bytes) + RDP Negotiation Request (8 bytes) = 19 bytes+ // prettier-ignore+ socket.write(Buffer.from([+ 0x03, 0x00, 0x00, 0x13, // TPKT: version 3, length 19+ 0x0e, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, // X.224 Connection Request+ 0x01, 0x00, 0x08, 0x00, 0x01, 0x00, 0x00, 0x00 // RDP Neg Request: TLS+ ]));+ });++ socket.on("data", (data: Buffer) => {+ // An RDP server responds with X.224 Connection Confirm:+ // byte 0 = 0x03 (TPKT version), byte 5 = 0xD0 (CC code)+ if (data.length >= 7 && data[0] === 0x03 && data[5] === 0xd0) {+ logger.info("[Windows Server Resource Factory] RDP handshake successful");+ finish();+ } else {+ finish(new Error("Server is not an RDP server"));+ }+ });++ socket.connect(proxyPort, "localhost");+ });+ });+ } catch (error) {+ throw new BadRequestError({+ message: `Unable to validate connection to ${resourceType}: ${(error as Error).message || String(error)}`+ });+ }++ return connectionDetails;+ };++ const validateAccountCredentials: TPamResourceFactoryValidateAccountCredentials<TWindowsAccountCredentials> = async (+ credentials+ ) => {+ if (!gatewayId) {+ throw new BadRequestError({ message: "Gateway ID is required" });+ }++ try {+ const statusCode = await executeWithGateway(+ { connectionDetails, gatewayId, resourceType, targetPortOverride: WINRM_HTTP_PORT },+ gatewayV2Service,+ async (proxyPort) => {+ const resp = await axios.post(`http://localhost:${proxyPort}/wsman`, "", {+ headers: { "Content-Type": "application/soap+xml;charset=UTF-8" },+ auth: { username: credentials.username, password: credentials.password },+ timeout: EXTERNAL_REQUEST_TIMEOUT,+ validateStatus: () => true+ });+ return resp.status;+ }+ );++ if (statusCode === 401) {+ throw new BadRequestError({+ message:+ "Account credentials invalid: username or password is incorrect, or the account does not have WinRM access (only administrators can authenticate via WinRM by default)"+ });+ }+ } catch (error) {+ if (error instanceof BadRequestError) throw error;++ const errMsg = error instanceof Error ? error.message : String(error);+ throw new BadRequestError({+ message: `Unable to validate account credentials via WinRM (port 5985): ${errMsg}. Ensure WinRM is enabled (run 'winrm quickconfig' on the server) and that port 5985 is open.`+ });+ }++ return credentials;+ };++ const rotateAccountCredentials: TPamResourceFactoryRotateAccountCredentials<+ TWindowsAccountCredentials+ > = async () => {+ throw new BadRequestError({+ message: "Credential rotation is not yet supported for Windows Server resources"+ });+ };++ const handleOverwritePreventionForCensoredValues = async (+ updatedAccountCredentials: TWindowsAccountCredentials,+ currentCredentials: TWindowsAccountCredentials+ ) => {+ if (updatedAccountCredentials.password === "__INFISICAL_UNCHANGED__") {+ return {+ ...updatedAccountCredentials,+ password: currentCredentials.password+ };+ }++ return updatedAccountCredentials;+ };++ return {+ validateConnection,+ validateAccountCredentials,+ rotateAccountCredentials,+ handleOverwritePreventionForCensoredValues+ };+};diff --git a/backend/src/ee/services/pam-resource/windows-server/windows-server-resource-fns.ts b/backend/src/ee/services/pam-resource/windows-server/windows-server-resource-fns.tsnew file mode 100644index 0000000000..9394ec18f5--- /dev/null+++ b/backend/src/ee/services/pam-resource/windows-server/windows-server-resource-fns.ts@@ -0,0 +1,8 @@+import { WindowsResourceListItemSchema } from "./windows-server-resource-schemas";++export const getWindowsResourceListItem = () => {+ return {+ name: WindowsResourceListItemSchema.shape.name.value,+ resource: WindowsResourceListItemSchema.shape.resource.value+ };+};diff --git a/backend/src/ee/services/pam-resource/windows-server/windows-server-resource-schemas.ts b/backend/src/ee/services/pam-resource/windows-server/windows-server-resource-schemas.tsnew file mode 100644index 0000000000..5ad72f5ca2--- /dev/null+++ b/backend/src/ee/services/pam-resource/windows-server/windows-server-resource-schemas.ts@@ -0,0 +1,93 @@+import { z } from "zod";++import { PamResource } from "../pam-resource-enums";+import {+ BaseCreateGatewayPamResourceSchema,+ BaseCreatePamAccountSchema,+ BasePamAccountSchema,+ BasePamAccountSchemaWithResource,+ BasePamResourceSchema,+ BaseUpdateGatewayPamResourceSchema,+ BaseUpdatePamAccountSchema+} from "../pam-resource-schemas";+import { WindowsAccountType, WindowsProtocol } from "./windows-server-resource-enums";++// Resources+const BaseWindowsResourceSchema = BasePamResourceSchema.extend({+ resourceType: z.literal(PamResource.Windows)+});++export const WindowsResourceListItemSchema = z.object({+ name: z.literal("Windows Server"),+ resource: z.literal(PamResource.Windows)+});++export const WindowsResourceConnectionDetailsSchema = z.object({+ protocol: z.literal(WindowsProtocol.RDP),+ hostname: z.string().trim().min(1).max(255),+ port: z.coerce.number()+});++// Credentials (username + password for RDP)+export const WindowsAccountCredentialsSchema = z.object({+ username: z.string().trim().min(1).max(255),+ password: z.string().trim().min(1).max(255)+});++// Account metadata+export const WindowsAccountMetadataSchema = z.object({+ accountType: z.nativeEnum(WindowsAccountType)+});++export const WindowsResourceSchema = BaseWindowsResourceSchema.extend({+ connectionDetails: WindowsResourceConnectionDetailsSchema,+ rotationAccountCredentials: WindowsAccountCredentialsSchema.nullable().optional()+});++export const SanitizedWindowsResourceSchema = BaseWindowsResourceSchema.extend({+ connectionDetails: WindowsResourceConnectionDetailsSchema,+ rotationAccountCredentials: z+ .object({+ username: z.string()+ })+ .nullable()+ .optional()+});++export const CreateWindowsResourceSchema = BaseCreateGatewayPamResourceSchema.extend({+ connectionDetails: WindowsResourceConnectionDetailsSchema,+ rotationAccountCredentials: WindowsAccountCredentialsSchema.nullable().optional()+});++export const UpdateWindowsResourceSchema = BaseUpdateGatewayPamResourceSchema.extend({+ connectionDetails: WindowsResourceConnectionDetailsSchema.optional(),+ rotationAccountCredentials: WindowsAccountCredentialsSchema.nullable().optional()+});++// Accounts+export const WindowsAccountSchema = BasePamAccountSchema.extend({+ credentials: WindowsAccountCredentialsSchema,+ metadata: WindowsAccountMetadataSchema+});++export const CreateWindowsAccountSchema = BaseCreatePamAccountSchema.extend({+ credentials: WindowsAccountCredentialsSchema,+ metadata: WindowsAccountMetadataSchema+});++export const UpdateWindowsAccountSchema = BaseUpdatePamAccountSchema.extend({+ credentials: WindowsAccountCredentialsSchema.optional(),+ metadata: WindowsAccountMetadataSchema.optional()+});++export const SanitizedWindowsAccountWithResourceSchema = BasePamAccountSchemaWithResource.extend({+ credentials: z.object({+ username: z.string()+ }),+ metadata: WindowsAccountMetadataSchema+});++// Sessions+export const WindowsSessionCredentialsSchema = WindowsResourceConnectionDetailsSchema.and(+ WindowsAccountCredentialsSchema+);diff --git a/backend/src/ee/services/pam-resource/windows-server/windows-server-resource-types.ts b/backend/src/ee/services/pam-resource/windows-server/windows-server-resource-types.tsnew file mode 100644index 0000000000..b03168fa04--- /dev/null+++ b/backend/src/ee/services/pam-resource/windows-server/windows-server-resource-types.ts@@ -0,0 +1,18 @@+import { z } from "zod";++import {+ WindowsAccountCredentialsSchema,+ WindowsAccountMetadataSchema,+ WindowsAccountSchema,+ WindowsResourceConnectionDetailsSchema,+ WindowsResourceSchema+} from "./windows-server-resource-schemas";++// Resources+export type TWindowsResource = z.infer<typeof WindowsResourceSchema>;+export type TWindowsResourceConnectionDetails = z.infer<typeof WindowsResourceConnectionDetailsSchema>;++// Accounts+export type TWindowsAccount = z.infer<typeof WindowsAccountSchema>;+export type TWindowsAccountCredentials = z.infer<typeof WindowsAccountCredentialsSchema>;+export type TWindowsAccountMetadata = z.infer<typeof WindowsAccountMetadataSchema>;diff --git a/frontend/src/hooks/api/pam/enums.ts b/frontend/src/hooks/api/pam/enums.tsindex c6dfcd70c1..4c05f5818a 100644--- a/frontend/src/hooks/api/pam/enums.ts+++ b/frontend/src/hooks/api/pam/enums.ts@@ -17,7 +17,8 @@ export enum PamResourceType {Elasticsearch = "elasticsearch",Snowflake = "snowflake",DynamoDB = "dynamodb",- AwsIam = "aws-iam"+ AwsIam = "aws-iam",+ Windows = "windows"}export enum PamResourceOrderBy {diff --git a/frontend/src/hooks/api/pam/maps.ts b/frontend/src/hooks/api/pam/maps.tsindex e42eb77488..178bbc2ad6 100644--- a/frontend/src/hooks/api/pam/maps.ts+++ b/frontend/src/hooks/api/pam/maps.ts@@ -21,5 +21,6 @@ export const PAM_RESOURCE_TYPE_MAP: Record<[PamResourceType.Elasticsearch]: { name: "Elasticsearch", image: "Elastic.png" },[PamResourceType.Snowflake]: { name: "Snowflake", image: "Snowflake.png" },[PamResourceType.DynamoDB]: { name: "DynamoDB", image: "DynamoDB.png", size: 55 },- [PamResourceType.AwsIam]: { name: "AWS IAM", image: "Amazon Web Services.png" }+ [PamResourceType.AwsIam]: { name: "AWS IAM", image: "Amazon Web Services.png" },+ [PamResourceType.Windows]: { name: "Windows Server", image: "Windows.png" }};diff --git a/frontend/src/hooks/api/pam/types/index.ts b/frontend/src/hooks/api/pam/types/index.tsindex f8b14e7962..c7faebb178 100644--- a/frontend/src/hooks/api/pam/types/index.ts+++ b/frontend/src/hooks/api/pam/types/index.ts@@ -12,6 +12,7 @@ import { TMySQLAccount, TMySQLResource } from "./mysql-resource";import { TPostgresAccount, TPostgresResource } from "./postgres-resource";import { TRedisAccount, TRedisResource } from "./redis-resource";import { TSSHAccount, TSSHResource } from "./ssh-resource";+import { TWindowsAccount, TWindowsResource } from "./windows-server-resource";export * from "./aws-iam-resource";export * from "./kubernetes-resource";@@ -19,6 +20,7 @@ export * from "./mysql-resource";export * from "./postgres-resource";export * from "./redis-resource";export * from "./ssh-resource";+export * from "./windows-server-resource";export type TPamResource =| TPostgresResource@@ -26,7 +28,8 @@ export type TPamResource =| TRedisResource| TSSHResource| TAwsIamResource- | TKubernetesResource;+ | TKubernetesResource+ | TWindowsResource;export type TPamAccount =| TPostgresAccount@@ -34,7 +37,8 @@ export type TPamAccount =| TRedisAccount| TSSHAccount| TAwsIamAccount- | TKubernetesAccount;+ | TKubernetesAccount+ | TWindowsAccount;export type TPamFolder = {id: string;@@ -150,6 +154,7 @@ export type TCreatePamAccountDTO = Pick<"name" | "description" | "credentials" | "projectId" | "resourceId" | "folderId" | "requireMfa"> & {resourceType: PamResourceType;+ metadata?: Record<string, unknown>;};export type TUpdatePamAccountDTO = Partial<@@ -157,6 +162,7 @@ export type TUpdatePamAccountDTO = Partial<> & {accountId: string;resourceType: PamResourceType;+ metadata?: Record<string, unknown>;};export type TDeletePamAccountDTO = {diff --git a/frontend/src/hooks/api/pam/types/windows-server-resource.ts b/frontend/src/hooks/api/pam/types/windows-server-resource.tsnew file mode 100644index 0000000000..1ac17cc7e7--- /dev/null+++ b/frontend/src/hooks/api/pam/types/windows-server-resource.ts@@ -0,0 +1,41 @@+import { PamResourceType } from "../enums";+import { TBasePamAccount } from "./base-account";+import { TBasePamResource } from "./base-resource";++export enum WindowsProtocol {+ RDP = "rdp"+}++export enum WindowsAccountType {+ User = "user",+ Service = "service"+}++export type TWindowsConnectionDetails = {+ protocol: WindowsProtocol.RDP;+ hostname: string;+ port: number;+};++export type TWindowsCredentials = {+ username: string;+ password: string;+};++export type TWindowsAccountMetadata = {+ accountType: WindowsAccountType;+};++// Resources+export type TWindowsResource = TBasePamResource & {+ resourceType: PamResourceType.Windows;+} & {+ connectionDetails: TWindowsConnectionDetails;+ rotationAccountCredentials?: TWindowsCredentials | null;+};++// Accounts+export type TWindowsAccount = TBasePamAccount & {+ credentials: TWindowsCredentials;+ metadata: TWindowsAccountMetadata;+};diff --git a/frontend/src/pages/pam/PamAccountByIDPage/PamAccountByIDPage.tsx b/frontend/src/pages/pam/PamAccountByIDPage/PamAccountByIDPage.tsxindex 1705398b08..e25ce8b7de 100644--- a/frontend/src/pages/pam/PamAccountByIDPage/PamAccountByIDPage.tsx+++ b/frontend/src/pages/pam/PamAccountByIDPage/PamAccountByIDPage.tsx@@ -147,15 +147,18 @@ const PageContent = () => {</div></div><div className="flex items-center gap-3">- <ProjectPermissionCan- I={ProjectPermissionPamAccountActions.Access}- a={ProjectPermissionSub.PamAccounts}- >- <Button variant="neutral" onClick={handleAccess} isPending={isAwsAccessPending}>- <LogInIcon />- Access- </Button>- </ProjectPermissionCan>+ {/* Windows Server accounts cannot be accessed temporarily */}+ {account.resource.resourceType !== PamResourceType.Windows && (+ <ProjectPermissionCan+ I={ProjectPermissionPamAccountActions.Access}+ a={ProjectPermissionSub.PamAccounts}+ >+ <Button variant="neutral" onClick={handleAccess} isPending={isAwsAccessPending}>+ <LogInIcon />+ Access+ </Button>+ </ProjectPermissionCan>+ )}<UnstableDropdownMenu><UnstableDropdownMenuTrigger asChild><Button variant="outline" size="sm">diff --git a/frontend/src/pages/pam/PamAccountByIDPage/components/PamAccountCredentialsSection.tsx b/frontend/src/pages/pam/PamAccountByIDPage/components/PamAccountCredentialsSection.tsxindex 50989701f6..cb539c1aca 100644--- a/frontend/src/pages/pam/PamAccountByIDPage/components/PamAccountCredentialsSection.tsx+++ b/frontend/src/pages/pam/PamAccountByIDPage/components/PamAccountCredentialsSection.tsx@@ -11,7 +11,7 @@ import {} from "@app/components/v3";import { ProjectPermissionSub } from "@app/context";import { ProjectPermissionPamAccountActions } from "@app/context/ProjectPermissionContext/types";-import { PamResourceType, TPamAccount } from "@app/hooks/api/pam";+import { PamResourceType, TPamAccount, TWindowsCredentials } from "@app/hooks/api/pam";import { TAwsIamCredentials } from "@app/hooks/api/pam/types/aws-iam-resource";import { TBaseSqlCredentials } from "@app/hooks/api/pam/types/shared/sql-resource";import { SSHAuthMethod, TSSHCredentials } from "@app/hooks/api/pam/types/ssh-resource";@@ -72,6 +72,10 @@ const AwsIamCredentialsContent = ({ credentials }: { credentials: TAwsIamCredent</>);+const WindowsCredentialsContent = ({ credentials }: { credentials: TWindowsCredentials }) => {+ return <CopyableField label="Username" value={credentials.username} />;+};+const CredentialsContent = ({ account }: { account: TPamAccount }) => {const { resourceType } = account.resource;@@ -84,6 +88,8 @@ const CredentialsContent = ({ account }: { account: TPamAccount }) => {return <SSHCredentialsContent credentials={account.credentials as TSSHCredentials} />;case PamResourceType.AwsIam:return <AwsIamCredentialsContent credentials={account.credentials as TAwsIamCredentials} />;+ case PamResourceType.Windows:+ return <WindowsCredentialsContent credentials={account.credentials as TWindowsCredentials} />;default:return null;}diff --git a/frontend/src/pages/pam/PamAccountByIDPage/components/PamAccountResourcesSection.tsx b/frontend/src/pages/pam/PamAccountByIDPage/components/PamAccountResourcesSection.tsxindex dbe8b710fa..6d87d19362 100644--- a/frontend/src/pages/pam/PamAccountByIDPage/components/PamAccountResourcesSection.tsx+++ b/frontend/src/pages/pam/PamAccountByIDPage/components/PamAccountResourcesSection.tsx@@ -1,6 +1,7 @@import { MonitorIcon } from "lucide-react";+import { twMerge } from "tailwind-merge";-import { TPamAccount } from "@app/hooks/api/pam";+import { PamResourceType, TPamAccount } from "@app/hooks/api/pam";type Props = {account: TPamAccount;@@ -43,7 +44,13 @@ export const PamAccountResourcesSection = ({ account, onAccessResource }: Props)<p className="text-sm text-muted">Resources this account can access</p></div><div className="p-4">- <div className="grid grid-cols-1 gap-4 md:grid-cols-2">+ <div+ className={twMerge(+ "grid grid-cols-1 gap-4 md:grid-cols-2",+ // Temporarily disable connecting to Windows Server accounts+ resource.resourceType === PamResourceType.Windows && "pointer-events-none opacity-60"+ )}+ ><ResourceCard name={resource.name} resourceId={resource.id} onAccess={onAccessResource} /></div></div>diff --git a/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/PamAccountForm.tsx b/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/PamAccountForm.tsxindex 631f7f7651..74174415b2 100644--- a/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/PamAccountForm.tsx+++ b/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/PamAccountForm.tsx@@ -14,6 +14,7 @@ import { MySQLAccountForm } from "./MySQLAccountForm";import { PostgresAccountForm } from "./PostgresAccountForm";import { RedisAccountForm } from "./RedisAccountForm";import { SshAccountForm } from "./SshAccountForm";+import { WindowsAccountForm } from "./WindowsAccountForm";type FormProps = {onComplete: (account: TPamAccount) => void;@@ -40,14 +41,21 @@ const CreateForm = ({const createPamAccount = useCreatePamAccount();const onSubmit = async (- formData: DiscriminativePick<TPamAccount, "name" | "description" | "credentials" | "requireMfa">+ formData: DiscriminativePick<+ TPamAccount,+ "name" | "description" | "credentials" | "requireMfa"+ > & {+ metadata?: Record<string, unknown>;+ }) => {+ const { metadata, ...rest } = formData;const account = await createPamAccount.mutateAsync({- ...formData,+ ...rest,folderId,resourceId,resourceType,- projectId+ projectId,+ metadata});createNotification({text: "Successfully created account",@@ -97,6 +105,14 @@ const CreateForm = ({resourceType={resourceType}/>);+ case PamResourceType.Windows:+ return (+ <WindowsAccountForm+ onSubmit={onSubmit}+ resourceId={resourceId}+ resourceType={resourceType}+ />+ );default:throw new Error(`Unhandled resource: ${resourceType}`);}@@ -106,12 +122,19 @@ const UpdateForm = ({ account, onComplete }: UpdateFormProps) => {const updatePamAccount = useUpdatePamAccount();const onSubmit = async (- formData: DiscriminativePick<TPamAccount, "name" | "description" | "credentials" | "requireMfa">+ formData: DiscriminativePick<+ TPamAccount,+ "name" | "description" | "credentials" | "requireMfa"+ > & {+ metadata?: Record<string, unknown>;+ }) => {+ const { metadata, ...rest } = formData;const updatedAccount = await updatePamAccount.mutateAsync({accountId: account.id,resourceType: account.resource.resourceType,- ...formData+ ...rest,+ metadata});createNotification({text: "Successfully updated account",@@ -138,6 +161,8 @@ const UpdateForm = ({ account, onComplete }: UpdateFormProps) => {return <KubernetesAccountForm account={account as any} onSubmit={onSubmit} />;case PamResourceType.AwsIam:return <AwsIamAccountForm account={account as any} onSubmit={onSubmit} />;+ case PamResourceType.Windows:+ return <WindowsAccountForm account={account as any} onSubmit={onSubmit} />;default:throw new Error(`Unhandled resource: ${account.resource.resourceType}`);}diff --git a/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/WindowsAccountForm.tsx b/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/WindowsAccountForm.tsxnew file mode 100644index 0000000000..0d6bc1fef9--- /dev/null+++ b/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/WindowsAccountForm.tsx@@ -0,0 +1,164 @@+import { useState } from "react";+import { Controller, FormProvider, useForm } from "react-hook-form";+import { zodResolver } from "@hookform/resolvers/zod";+import { z } from "zod";++import { Button, FormControl, Input, ModalClose, Select, SelectItem } from "@app/components/v2";+import { PamResourceType, TWindowsAccount } from "@app/hooks/api/pam";+import { UNCHANGED_PASSWORD_SENTINEL } from "@app/hooks/api/pam/constants";+import { WindowsAccountType } from "@app/hooks/api/pam/types/windows-server-resource";++import { GenericAccountFields, genericAccountFieldsSchema } from "./GenericAccountFields";+import { RequireMfaField } from "./RequireMfaField";++type Props = {+ account?: TWindowsAccount;+ resourceId?: string;+ resourceType?: PamResourceType;+ onSubmit: (formData: FormData) => Promise<void>;+};++const formSchema = genericAccountFieldsSchema.extend({+ credentials: z.object({+ username: z.string().trim().min(1, "Username is required"),+ password: z.string().trim().min(1, "Password is required")+ }),+ metadata: z.object({+ accountType: z.nativeEnum(WindowsAccountType)+ }),+ rotationEnabled: z.boolean().default(false),+ requireMfa: z.boolean().nullable().optional()+});++type FormData = z.infer<typeof formSchema>;++export const WindowsAccountForm = ({ account, onSubmit }: Props) => {+ const isUpdate = Boolean(account);+ const [showPassword, setShowPassword] = useState(false);++ const form = useForm<FormData>({+ resolver: zodResolver(formSchema),+ defaultValues: account+ ? {+ ...account,+ credentials: {+ ...account.credentials,+ password: UNCHANGED_PASSWORD_SENTINEL+ }+ }+ : {+ name: "",+ description: "",+ requireMfa: false,+ rotationEnabled: false,+ credentials: {+ username: "",+ password: ""+ },+ metadata: {+ accountType: WindowsAccountType.User+ }+ }+ });++ const {+ control,+ handleSubmit,+ formState: { isSubmitting, isDirty }+ } = form;++ return (+ <FormProvider {...form}>+ <form onSubmit={handleSubmit(onSubmit)}>+ <GenericAccountFields />+ <div className="mb-4 rounded-sm border border-mineshaft-600 bg-mineshaft-700/70 p-3">+ <Controller+ name="metadata.accountType"+ control={control}+ render={({ field: { value, onChange }, fieldState: { error } }) => (+ <FormControl+ className="mb-3"+ isError={Boolean(error?.message)}+ errorText={error?.message}+ label="Account Type"+ >+ <Select+ value={value}+ onValueChange={onChange}+ className="w-full border border-mineshaft-500"+ >+ <SelectItem value={WindowsAccountType.User}>User Account</SelectItem>+ <SelectItem value={WindowsAccountType.Service}>Service Account</SelectItem>+ </Select>+ </FormControl>+ )}+ />++ <Controller+ name="credentials.username"+ control={control}+ render={({ field, fieldState: { error } }) => (+ <FormControl+ className="mb-3"+ errorText={error?.message}+ isError={Boolean(error?.message)}+ label="Username"+ >+ <Input {...field} autoComplete="off" />+ </FormControl>+ )}+ />++ <Controller+ name="credentials.password"+ control={control}+ render={({ field, fieldState: { error } }) => (+ <FormControl+ className="mb-0"+ errorText={error?.message}+ isError={Boolean(error?.message)}+ label="Password"+ >+ <Input+ {...field}+ type={showPassword ? "text" : "password"}+ autoComplete="new-password"+ onFocus={() => {+ if (isUpdate && field.value === UNCHANGED_PASSWORD_SENTINEL) {+ field.onChange("");+ }+ setShowPassword(true);+ }}+ onBlur={() => {+ if (isUpdate && field.value === "") {+ field.onChange(UNCHANGED_PASSWORD_SENTINEL);+ }+ setShowPassword(false);+ }}+ />+ </FormControl>+ )}+ />+ </div>+ <RequireMfaField />+ <div className="mt-6 flex items-center">+ <Button+ className="mr-4"+ size="sm"+ type="submit"+ colorSchema="secondary"+ isLoading={isSubmitting}+ isDisabled={isSubmitting || !isDirty}+ >+ {isUpdate ? "Update Account" : "Create Account"}+ </Button>+ <ModalClose asChild>+ <Button colorSchema="secondary" variant="plain">+ Cancel+ </Button>+ </ModalClose>+ </div>+ </form>+ </FormProvider>+ );+};diff --git a/frontend/src/pages/pam/PamResourceByIDPage/components/PamResourceAccountsSection.tsx b/frontend/src/pages/pam/PamResourceByIDPage/components/PamResourceAccountsSection.tsxindex 3942e147f8..41d238c5f3 100644--- a/frontend/src/pages/pam/PamResourceByIDPage/components/PamResourceAccountsSection.tsx+++ b/frontend/src/pages/pam/PamResourceByIDPage/components/PamResourceAccountsSection.tsx@@ -263,24 +263,27 @@ export const PamResourceAccountsSection = ({ resource }: Props) => {</UnstableTableCell><UnstableTableCell><div className="flex items-center gap-2">- <ProjectPermissionCan- I={ProjectPermissionPamAccountActions.Access}- a={ProjectPermissionSub.PamAccounts}- >- <Button- variant="ghost"- size="xs"- onClick={(e) => {- e.stopPropagation();- accessAccount(account);- }}- isPending={loadingAccountId === account.id}- isDisabled={loadingAccountId === account.id}+ {/* Temporarily disable accessing Windows Server accounts */}+ {resource.resourceType !== PamResourceType.Windows && (+ <ProjectPermissionCan+ I={ProjectPermissionPamAccountActions.Access}+ a={ProjectPermissionSub.PamAccounts}>- <LogInIcon />- Connect- </Button>- </ProjectPermissionCan>+ <Button+ variant="ghost"+ size="xs"+ onClick={(e) => {+ e.stopPropagation();+ accessAccount(account);+ }}+ isPending={loadingAccountId === account.id}+ isDisabled={loadingAccountId === account.id}+ >+ <LogInIcon />+ Connect+ </Button>+ </ProjectPermissionCan>+ )}<UnstableDropdownMenu><UnstableDropdownMenuTrigger asChild><UnstableIconButton variant="ghost" size="xs">diff --git a/frontend/src/pages/pam/PamResourceByIDPage/components/PamResourceConnectionSection.tsx b/frontend/src/pages/pam/PamResourceByIDPage/components/PamResourceConnectionSection.tsxindex ce6cbf6546..89a2ab8fc0 100644--- a/frontend/src/pages/pam/PamResourceByIDPage/components/PamResourceConnectionSection.tsx+++ b/frontend/src/pages/pam/PamResourceByIDPage/components/PamResourceConnectionSection.tsx@@ -126,6 +126,27 @@ const AwsIamConnectionDetails = ({</Detail>);+const WindowsConnectionDetails = ({+ connectionDetails+}: {+ connectionDetails: { protocol: string; hostname: string; port: number };+}) => (+ <>+ <Detail>+ <DetailLabel>Protocol</DetailLabel>+ <DetailValue>{connectionDetails.protocol.toUpperCase()}</DetailValue>+ </Detail>+ <Detail>+ <DetailLabel>Hostname</DetailLabel>+ <DetailValue>{connectionDetails.hostname}</DetailValue>+ </Detail>+ <Detail>+ <DetailLabel>Port</DetailLabel>+ <DetailValue>{connectionDetails.port}</DetailValue>+ </Detail>+ </>+);+const ConnectionDetailsContent = ({ resource }: Props) => {switch (resource.resourceType) {case PamResourceType.Postgres:@@ -139,6 +160,8 @@ const ConnectionDetailsContent = ({ resource }: Props) => {return <KubernetesConnectionDetails connectionDetails={resource.connectionDetails} />;case PamResourceType.AwsIam:return <AwsIamConnectionDetails connectionDetails={resource.connectionDetails} />;+ case PamResourceType.Windows:+ return <WindowsConnectionDetails connectionDetails={resource.connectionDetails} />;default:return null;}diff --git a/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/PamResourceForm.tsx b/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/PamResourceForm.tsxindex d652f92299..d53c30754a 100644--- a/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/PamResourceForm.tsx+++ b/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/PamResourceForm.tsx@@ -15,6 +15,7 @@ import { MySQLResourceForm } from "./MySQLResourceForm";import { PostgresResourceForm } from "./PostgresResourceForm";import { RedisResourceForm } from "./RedisResourceForm";import { SSHResourceForm } from "./SSHResourceForm";+import { WindowsResourceForm } from "./WindowsResourceForm";type FormProps = {onComplete: (resource: TPamResource) => void;@@ -63,6 +64,8 @@ const CreateForm = ({ resourceType, onComplete, projectId }: CreateFormProps) =>return <KubernetesResourceForm onSubmit={onSubmit} />;case PamResourceType.AwsIam:return <AwsIamResourceForm onSubmit={onSubmit} />;+ case PamResourceType.Windows:+ return <WindowsResourceForm onSubmit={onSubmit} />;default:throw new Error(`Unhandled resource: ${resourceType}`);}@@ -99,6 +102,8 @@ const UpdateForm = ({ resource, onComplete }: UpdateFormProps) => {return <KubernetesResourceForm resource={resource} onSubmit={onSubmit} />;case PamResourceType.AwsIam:return <AwsIamResourceForm resource={resource} onSubmit={onSubmit} />;+ case PamResourceType.Windows:+ return <WindowsResourceForm resource={resource} onSubmit={onSubmit} />;default:throw new Error(`Unhandled resource: ${(resource as any).resourceType}`);}diff --git a/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/WindowsResourceForm.tsx b/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/WindowsResourceForm.tsxnew file mode 100644index 0000000000..cfe242f2e0--- /dev/null+++ b/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/WindowsResourceForm.tsx@@ -0,0 +1,104 @@+import { Controller, FormProvider, useForm } from "react-hook-form";+import { zodResolver } from "@hookform/resolvers/zod";+import { z } from "zod";++import { Button, FormControl, Input, ModalClose } from "@app/components/v2";+import { PamResourceType, TWindowsResource } from "@app/hooks/api/pam";+import { WindowsProtocol } from "@app/hooks/api/pam/types/windows-server-resource";++import { GenericResourceFields, genericResourceFieldsSchema } from "./GenericResourceFields";++type Props = {+ resource?: TWindowsResource;+ onSubmit: (formData: FormData) => Promise<void>;+};++const formSchema = genericResourceFieldsSchema.extend({+ resourceType: z.literal(PamResourceType.Windows),+ connectionDetails: z.object({+ protocol: z.literal(WindowsProtocol.RDP),+ hostname: z.string().trim().min(1, "Hostname is required"),+ port: z.coerce.number().int().min(1).max(65535)+ })+});++type FormData = z.infer<typeof formSchema>;++export const WindowsResourceForm = ({ resource, onSubmit }: Props) => {+ const isUpdate = Boolean(resource);++ const form = useForm<FormData>({+ resolver: zodResolver(formSchema),+ defaultValues: resource ?? {+ resourceType: PamResourceType.Windows,+ connectionDetails: {+ protocol: WindowsProtocol.RDP,+ hostname: "",+ port: 3389+ }+ }+ });++ const {+ control,+ handleSubmit,+ formState: { isSubmitting, isDirty }+ } = form;++ return (+ <FormProvider {...form}>+ <form onSubmit={handleSubmit(onSubmit)}>+ <GenericResourceFields />+ <div className="mb-4 rounded-sm border border-mineshaft-600 bg-mineshaft-700/70 p-3 pb-0">+ <div className="mt-[0.675rem] flex items-start gap-2">+ <Controller+ name="connectionDetails.hostname"+ control={control}+ render={({ field, fieldState: { error } }) => (+ <FormControl+ className="flex-1"+ errorText={error?.message}+ isError={Boolean(error?.message)}+ label="Hostname"+ >+ <Input placeholder="example.com or 192.168.1.1" {...field} />+ </FormControl>+ )}+ />+ <Controller+ name="connectionDetails.port"+ control={control}+ render={({ field, fieldState: { error } }) => (+ <FormControl+ className="w-28"+ errorText={error?.message}+ isError={Boolean(error?.message)}+ label="Port"+ >+ <Input type="number" {...field} />+ </FormControl>+ )}+ />+ </div>+ </div>+ <div className="mt-6 flex items-center">+ <Button+ className="mr-4"+ size="sm"+ type="submit"+ colorSchema="secondary"+ isLoading={isSubmitting}+ isDisabled={isSubmitting || !isDirty}+ >+ {isUpdate ? "Update Details" : "Create Resource"}+ </Button>+ <ModalClose asChild>+ <Button colorSchema="secondary" variant="plain">+ Cancel+ </Button>+ </ModalClose>+ </div>+ </form>+ </FormProvider>+ );+};