Skip to content

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

winrm https, ca, and reject unauthorized config for windows server rotation

x032205ac4484fbf6b8
diff --git a/backend/src/ee/services/pam-resource/active-directory/active-directory-resource-factory.ts b/backend/src/ee/services/pam-resource/active-directory/active-directory-resource-factory.ts
index 110deb6123..8b53c8a153 100644
--- a/backend/src/ee/services/pam-resource/active-directory/active-directory-resource-factory.ts
+++ b/backend/src/ee/services/pam-resource/active-directory/active-directory-resource-factory.ts
@@ -69,6 +69,22 @@ export const activeDirectoryResourceFactory: TPamResourceFactory<
TActiveDirectoryAccountCredentials,
TPamResourceInternalMetadata
> = (resourceType, connectionDetails, gatewayId, gatewayV2Service) => {
+ const ldapProtocol = connectionDetails.useLdaps ? "ldaps" : "ldap";
+
+ const buildLdapTlsOptions = () => {
+ if (!connectionDetails.useLdaps) return {};
+ return {
+ tlsOptions: {
+ rejectUnauthorized: connectionDetails.ldapRejectUnauthorized ?? false,
+ ...(connectionDetails.ldapCaCert && {
+ ca: [connectionDetails.ldapCaCert],
+ servername: connectionDetails.dcAddress,
+ checkServerIdentity: () => undefined
+ })
+ }
+ };
+ };
+
const validateConnection = async () => {
if (!gatewayId) throw new BadRequestError({ message: "Gateway is required for connection validation" });
@@ -76,9 +92,10 @@ export const activeDirectoryResourceFactory: TPamResourceFactory<
await executeWithGateway({ connectionDetails, gatewayId, resourceType }, gatewayV2Service, async (proxyPort) => {
return new Promise<void>((resolve, reject) => {
const client = ldapjs.createClient({
- url: `ldap://localhost:${proxyPort}`,
+ url: `${ldapProtocol}://localhost:${proxyPort}`,
connectTimeout: EXTERNAL_REQUEST_TIMEOUT,
- timeout: EXTERNAL_REQUEST_TIMEOUT
+ timeout: EXTERNAL_REQUEST_TIMEOUT,
+ ...buildLdapTlsOptions()
});
client.on("error", (err: Error) => {
@@ -122,41 +139,35 @@ export const activeDirectoryResourceFactory: TPamResourceFactory<
if (!gatewayId) throw new BadRequestError({ message: "Gateway is required for credential validation" });
try {
- await executeWithGateway(
- { connectionDetails, gatewayId, resourceType, targetPortOverride: 636 },
- gatewayV2Service,
- async (proxyPort) => {
- return new Promise<void>((resolve, reject) => {
- const bindDn = `${credentials.username}@${connectionDetails.domain}`;
-
- const client = ldapjs.createClient({
- url: `ldaps://localhost:${proxyPort}`,
- connectTimeout: EXTERNAL_REQUEST_TIMEOUT,
- timeout: EXTERNAL_REQUEST_TIMEOUT,
- tlsOptions: {
- rejectUnauthorized: false
- }
- });
+ await executeWithGateway({ connectionDetails, gatewayId, resourceType }, gatewayV2Service, async (proxyPort) => {
+ return new Promise<void>((resolve, reject) => {
+ const bindDn = `${credentials.username}@${connectionDetails.domain}`;
- client.on("error", (err: Error) => {
- client.unbind();
- reject(err);
- });
+ const client = ldapjs.createClient({
+ url: `${ldapProtocol}://localhost:${proxyPort}`,
+ connectTimeout: EXTERNAL_REQUEST_TIMEOUT,
+ timeout: EXTERNAL_REQUEST_TIMEOUT,
+ ...buildLdapTlsOptions()
+ });
- client.bind(bindDn, credentials.password, (err) => {
- if (err) {
- client.unbind();
- logger.warn(err, "[Active Directory Resource Factory] LDAP bind failed during credential validation");
- reject(new Error(`LDAP bind failed: ${err.message}`));
- } else {
- logger.info("[Active Directory Resource Factory] LDAP credential validation successful");
- client.unbind();
- resolve();
- }
- });
+ client.on("error", (err: Error) => {
+ client.unbind();
+ reject(err);
+ });
+
+ client.bind(bindDn, credentials.password, (err) => {
+ if (err) {
+ client.unbind();
+ logger.warn(err, "[Active Directory Resource Factory] LDAP bind failed during credential validation");
+ reject(new Error(`LDAP bind failed: ${err.message}`));
+ } else {
+ logger.info("[Active Directory Resource Factory] LDAP credential validation successful");
+ client.unbind();
+ resolve();
+ }
});
- }
- );
+ });
+ });
} catch (error) {
throw new BadRequestError({
message: `Unable to validate credentials for ${resourceType}: ${(error as Error).message || String(error)}`
@@ -173,98 +184,97 @@ export const activeDirectoryResourceFactory: TPamResourceFactory<
const newPassword = generatePassword();
- // AD requires LDAPS (port 636) for unicodePwd changes
- await executeWithGateway(
- { connectionDetails, gatewayId, resourceType, targetPortOverride: 636 },
- gatewayV2Service,
- async (proxyPort) => {
- return new Promise<void>((resolve, reject) => {
- const client = ldapjs.createClient({
- url: `ldaps://localhost:${proxyPort}`,
- connectTimeout: EXTERNAL_REQUEST_TIMEOUT,
- timeout: EXTERNAL_REQUEST_TIMEOUT,
- tlsOptions: {
- rejectUnauthorized: false
- }
- });
+ if (!connectionDetails.useLdaps) {
+ throw new BadRequestError({
+ message: "LDAPS must be enabled on this Active Directory resource to perform password rotation"
+ });
+ }
- client.on("error", (err: Error) => {
+ await executeWithGateway({ connectionDetails, gatewayId, resourceType }, gatewayV2Service, async (proxyPort) => {
+ return new Promise<void>((resolve, reject) => {
+ const client = ldapjs.createClient({
+ url: `ldaps://localhost:${proxyPort}`,
+ connectTimeout: EXTERNAL_REQUEST_TIMEOUT,
+ timeout: EXTERNAL_REQUEST_TIMEOUT,
+ ...buildLdapTlsOptions()
+ });
+
+ client.on("error", (err: Error) => {
+ client.unbind();
+ reject(err);
+ });
+
+ // Bind as rotation account (admin)
+ const bindDn = `${rotationAccountCredentials.username}@${connectionDetails.domain}`;
+ client.bind(bindDn, rotationAccountCredentials.password, (bindErr) => {
+ if (bindErr) {
client.unbind();
- reject(err);
- });
+ reject(new Error(`Rotation account bind failed: ${bindErr.message}`));
+ return;
+ }
- // Bind as rotation account (admin)
- const bindDn = `${rotationAccountCredentials.username}@${connectionDetails.domain}`;
- client.bind(bindDn, rotationAccountCredentials.password, (bindErr) => {
- if (bindErr) {
- client.unbind();
- reject(new Error(`Rotation account bind failed: ${bindErr.message}`));
- return;
- }
+ // Search for target user's DN by sAMAccountName
+ const searchBase = connectionDetails.domain
+ .split(".")
+ .map((dc) => `DC=${dc}`)
+ .join(",");
+
+ client.search(
+ searchBase,
+ {
+ filter: new ldapjs.EqualityFilter({ attribute: "sAMAccountName", value: currentCredentials.username }),
+ scope: "sub",
+ attributes: ["dn"]
+ },
+ (searchErr, searchRes) => {
+ if (searchErr) {
+ client.unbind();
+ reject(new Error(`LDAP search failed: ${searchErr.message}`));
+ return;
+ }
+
+ let userDn: string | null = null;
+
+ searchRes.on("searchEntry", (entry) => {
+ userDn = entry.objectName;
+ });
- // Search for target user's DN by sAMAccountName
- const searchBase = connectionDetails.domain
- .split(".")
- .map((dc) => `DC=${dc}`)
- .join(",");
-
- client.search(
- searchBase,
- {
- filter: new ldapjs.EqualityFilter({ attribute: "sAMAccountName", value: currentCredentials.username }),
- scope: "sub",
- attributes: ["dn"]
- },
- (searchErr, searchRes) => {
- if (searchErr) {
+ searchRes.on("error", (err) => {
+ client.unbind();
+ reject(new Error(`LDAP search error: ${err.message}`));
+ });
+
+ searchRes.on("end", () => {
+ if (!userDn) {
client.unbind();
- reject(new Error(`LDAP search failed: ${searchErr.message}`));
+ reject(new Error(`User '${currentCredentials.username}' not found in AD`));
return;
}
- let userDn: string | null = null;
-
- searchRes.on("searchEntry", (entry) => {
- userDn = entry.objectName;
+ // Admin reset: use "replace" operation on unicodePwd
+ const encodedPassword = Buffer.from(`"${newPassword}"`, "utf16le");
+ const change = new ldapjs.Change({
+ operation: "replace",
+ modification: { type: "unicodePwd", values: [encodedPassword] }
});
- searchRes.on("error", (err) => {
+ client.modify(userDn, change, (modifyErr) => {
client.unbind();
- reject(new Error(`LDAP search error: ${err.message}`));
- });
-
- searchRes.on("end", () => {
- if (!userDn) {
- client.unbind();
- reject(new Error(`User '${currentCredentials.username}' not found in AD`));
- return;
+ if (modifyErr) {
+ reject(new Error(`AD password reset failed: ${modifyErr.message}`));
+ } else {
+ logger.info(
+ `[AD Rotation] Password rotated for ${currentCredentials.username} on ${connectionDetails.domain}`
+ );
+ resolve();
}
-
- // Admin reset: use "replace" operation on unicodePwd
- const encodedPassword = Buffer.from(`"${newPassword}"`, "utf16le");
- const change = new ldapjs.Change({
- operation: "replace",
- modification: { type: "unicodePwd", values: [encodedPassword] }
- });
-
- client.modify(userDn, change, (modifyErr) => {
- client.unbind();
- if (modifyErr) {
- reject(new Error(`AD password reset failed: ${modifyErr.message}`));
- } else {
- logger.info(
- `[AD Rotation] Password rotated for ${currentCredentials.username} on ${connectionDetails.domain}`
- );
- resolve();
- }
- });
});
- }
- );
- });
+ });
+ }
+ );
});
- }
- );
+ });
+ });
return { username: currentCredentials.username, password: newPassword };
};
diff --git a/backend/src/ee/services/pam-resource/active-directory/active-directory-resource-schemas.ts b/backend/src/ee/services/pam-resource/active-directory/active-directory-resource-schemas.ts
index 3fbca12d26..6bfa872ebd 100644
--- a/backend/src/ee/services/pam-resource/active-directory/active-directory-resource-schemas.ts
+++ b/backend/src/ee/services/pam-resource/active-directory/active-directory-resource-schemas.ts
@@ -25,7 +25,14 @@ export const ActiveDirectoryResourceListItemSchema = z.object({
export const ActiveDirectoryResourceConnectionDetailsSchema = z.object({
domain: z.string().trim().min(1).max(255),
dcAddress: z.string().trim().min(1).max(255),
- port: z.coerce.number().int().min(1).max(65535)
+ port: z.coerce.number().int().min(1).max(65535),
+ useLdaps: z.boolean().optional(),
+ ldapRejectUnauthorized: z.boolean().optional(),
+ ldapCaCert: z
+ .string()
+ .trim()
+ .transform((val) => val || undefined)
+ .optional()
});
// Credentials (username + password for AD)
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.ts
index 3b62a64c97..bf1b8adde0 100644
--- 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.ts
@@ -125,7 +125,7 @@ export const windowsResourceFactory: TPamResourceFactory<
});
} catch (error) {
throw new BadRequestError({
- message: `Unable to validate connection to ${resourceType}: ${(error as Error).message || String(error)}`
+ message: `Unable to validate connection to windows: ${(error as Error).message || String(error)}`
});
}
@@ -150,8 +150,11 @@ export const windowsResourceFactory: TPamResourceFactory<
const escapedNewPassword = escapePowershellSingleQuote(newPassword);
const escapedUsername = escapePowershellSingleQuote(currentCredentials.username);
+ const winrmPort = connectionDetails.winrmPort ?? WINRM_DEFAULT_HTTP_PORT;
+ const useWinrmHttps = connectionDetails.useWinrmHttps ?? false;
+
await executeWithGateway(
- { connectionDetails, gatewayId, resourceType, targetPortOverride: WINRM_DEFAULT_HTTP_PORT },
+ { connectionDetails, gatewayId, resourceType, targetPortOverride: winrmPort },
gatewayV2Service,
async (proxyPort) => {
const script = [
@@ -164,7 +167,10 @@ export const windowsResourceFactory: TPamResourceFactory<
"localhost",
rotationAccountCredentials.username,
rotationAccountCredentials.password,
- proxyPort
+ proxyPort,
+ useWinrmHttps,
+ useWinrmHttps ? (connectionDetails.winrmRejectUnauthorized ?? false) : undefined,
+ connectionDetails.winrmCaCert
);
logger.info(
@@ -192,7 +198,10 @@ export const windowsResourceFactory: TPamResourceFactory<
ctx,
gatewayV2Service,
rotationCredentials: rotationAccountCredentials,
- gatewayId
+ gatewayId,
+ winrmPort: connectionDetails.winrmPort,
+ useWinrmHttps: connectionDetails.useWinrmHttps,
+ winrmCaCert: connectionDetails.winrmCaCert
});
};
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.ts
index bf6b4c8f52..6de30c11bb 100644
--- 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.ts
@@ -25,7 +25,17 @@ export const WindowsResourceListItemSchema = z.object({
export const WindowsResourceConnectionDetailsSchema = z.object({
protocol: z.literal(WindowsProtocol.RDP),
hostname: z.string().trim().min(1).max(255),
- port: z.coerce.number().int().min(1).max(65535)
+ port: z.coerce.number().int().min(1).max(65535),
+
+ // WinRM config — used for rotation only, configured in the rotation policy modal
+ winrmPort: z.coerce.number().int().min(1).max(65535).optional(),
+ useWinrmHttps: z.boolean().optional(),
+ winrmRejectUnauthorized: z.boolean().optional(),
+ winrmCaCert: z
+ .string()
+ .trim()
+ .transform((val) => val || undefined)
+ .optional()
});
// Credentials (username + password for RDP)
diff --git a/frontend/src/hooks/api/pam/types/active-directory-resource.ts b/frontend/src/hooks/api/pam/types/active-directory-resource.ts
index 88df2122ae..c3bd43ed98 100644
--- a/frontend/src/hooks/api/pam/types/active-directory-resource.ts
+++ b/frontend/src/hooks/api/pam/types/active-directory-resource.ts
@@ -11,6 +11,9 @@ export type TActiveDirectoryConnectionDetails = {
domain: string;
dcAddress: string;
port: number;
+ useLdaps?: boolean;
+ ldapRejectUnauthorized?: boolean;
+ ldapCaCert?: string;
};
export type TActiveDirectoryCredentials = {
diff --git a/frontend/src/pages/pam/PamResourceByIDPage/components/PamRotationPolicyModal.tsx b/frontend/src/pages/pam/PamResourceByIDPage/components/PamRotationPolicyModal.tsx
index 4f5a8e7e1f..3c57c7592d 100644
--- a/frontend/src/pages/pam/PamResourceByIDPage/components/PamRotationPolicyModal.tsx
+++ b/frontend/src/pages/pam/PamResourceByIDPage/components/PamRotationPolicyModal.tsx
@@ -1,14 +1,44 @@
import { useCallback, useEffect, useState } from "react";
import { Controller, useForm } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";
-import { ArrowDownIcon, ArrowUpIcon, EyeIcon, EyeOffIcon, PlusIcon, TrashIcon } from "lucide-react";
+import {
+ ArrowDownIcon,
+ ArrowUpIcon,
+ EyeIcon,
+ EyeOffIcon,
+ InfoIcon,
+ PlusIcon,
+ TrashIcon,
+ TriangleAlertIcon
+} from "lucide-react";
import { twMerge } from "tailwind-merge";
import { z } from "zod";
import { createNotification } from "@app/components/notifications";
import { FormControl, Input, Modal, ModalContent } from "@app/components/v2";
-import { Button, Label, Switch, UnstableIconButton } from "@app/components/v3";
-import { TPamResource, TPamRotationRule, useUpdatePamResource } from "@app/hooks/api/pam";
+import {
+ Button,
+ Field,
+ FieldContent,
+ FieldLabel,
+ Label,
+ Switch,
+ TextArea,
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger,
+ UnstableAlert,
+ UnstableAlertDescription,
+ UnstableAlertTitle,
+ UnstableIconButton,
+ UnstableInput
+} from "@app/components/v3";
+import {
+ PamResourceType,
+ TPamResource,
+ TPamRotationRule,
+ useUpdatePamResource
+} from "@app/hooks/api/pam";
import { UNCHANGED_PASSWORD_SENTINEL } from "@app/hooks/api/pam/constants";
import {
useCreatePamRotationRule,
@@ -211,6 +241,21 @@ export const PamRotationPolicyModal = ({ isOpen, onOpenChange, resource }: Props
const [showPassword, setShowPassword] = useState(false);
const [isSaving, setIsSaving] = useState(false);
+ // WinRM config for Windows Server resources (stored in connectionDetails)
+ const isWindowsResource = resource.resourceType === PamResourceType.Windows;
+ const connDetails = resource.connectionDetails as {
+ winrmPort?: number;
+ useWinrmHttps?: boolean;
+ winrmRejectUnauthorized?: boolean;
+ winrmCaCert?: string;
+ };
+ const [winrmPort, setWinrmPort] = useState(connDetails.winrmPort ?? 5985);
+ const [useWinrmHttps, setUseWinrmHttps] = useState(connDetails.useWinrmHttps ?? false);
+ const [winrmRejectUnauthorized, setWinrmRejectUnauthorized] = useState(
+ connDetails.winrmRejectUnauthorized ?? true
+ );
+ const [winrmCaCert, setWinrmCaCert] = useState(connDetails.winrmCaCert ?? "");
+
// Local working copy of rules — only persisted on save
const [localRules, setLocalRules] = useState<LocalRule[]>([]);
const [deletedRuleIds, setDeletedRuleIds] = useState<string[]>([]);
@@ -245,7 +290,11 @@ export const PamRotationPolicyModal = ({ isOpen, onOpenChange, resource }: Props
password: hasRotationCredentials ? UNCHANGED_PASSWORD_SENTINEL : ""
});
setShowPassword(false);
- }, [rules, resource, hasRotationCredentials, resetCred]);
+ setWinrmPort(connDetails.winrmPort ?? 5985);
+ setUseWinrmHttps(connDetails.useWinrmHttps ?? false);
+ setWinrmRejectUnauthorized(connDetails.winrmRejectUnauthorized ?? true);
+ setWinrmCaCert(connDetails.winrmCaCert ?? "");
+ }, [rules, resource, hasRotationCredentials, resetCred, connDetails]);
useEffect(() => {
if (isOpen) {
@@ -301,16 +350,34 @@ export const PamRotationPolicyModal = ({ isOpen, onOpenChange, resource }: Props
const handleSave = async (credData: CredentialsFormData) => {
setIsSaving(true);
try {
- // Save credentials if changed (send null to remove)
+ // Save credentials and WinRM config if changed
+ const clearingCredentials =
+ isCredDirty && credData.username === "" && credData.password === "";
+ const updatePayload: Record<string, unknown> = {
+ resourceId: resource.id,
+ resourceType: resource.resourceType
+ };
+
if (isCredDirty) {
- const clearingCredentials = credData.username === "" && credData.password === "";
- await updateResource.mutateAsync({
- resourceId: resource.id,
- resourceType: resource.resourceType,
- rotationAccountCredentials: clearingCredentials
- ? null
- : { username: credData.username, password: credData.password }
- });
+ updatePayload.rotationAccountCredentials = clearingCredentials
+ ? null
+ : { username: credData.username, password: credData.password };
+ }
+
+ if (isWindowsResource) {
+ updatePayload.connectionDetails = {
+ ...(resource.connectionDetails as Record<string, unknown>),
+ winrmPort,
+ useWinrmHttps,
+ winrmRejectUnauthorized,
+ winrmCaCert: winrmCaCert || undefined
+ };
+ }
+
+ if (isCredDirty || isWindowsResource) {
+ await updateResource.mutateAsync(
+ updatePayload as Parameters<typeof updateResource.mutateAsync>[0]
+ );
}
// Delete removed rules (sequential to avoid race conditions)
@@ -396,6 +463,18 @@ export const PamRotationPolicyModal = ({ isOpen, onOpenChange, resource }: Props
subTitle="Configure automatic password rotation for accounts under this resource."
>
<div className="flex flex-col gap-6">
+ {resource.resourceType === PamResourceType.ActiveDirectory &&
+ !(resource.connectionDetails as { useLdaps?: boolean }).useLdaps && (
+ <UnstableAlert variant="info">
+ <TriangleAlertIcon />
+ <UnstableAlertTitle>LDAPS Required for Rotation</UnstableAlertTitle>
+ <UnstableAlertDescription>
+ Active Directory requires LDAPS (TLS) to change passwords. Enable LDAPS in the
+ resource connection settings before configuring rotation.
+ </UnstableAlertDescription>
+ </UnstableAlert>
+ )}
+
{/* Section: Rotation Credentials */}
<div>
<h4 className="mb-1 text-sm font-semibold">Rotation Credentials</h4>
@@ -462,6 +541,83 @@ export const PamRotationPolicyModal = ({ isOpen, onOpenChange, resource }: Props
)}
</div>
+ {/* Section: WinRM Config (Windows Server only) */}
+ {isWindowsResource && (
+ <div className="flex flex-col gap-3">
+ <div>
+ <h4 className="text-sm font-semibold">WinRM Configuration</h4>
+ <p className="text-xs text-mineshaft-400">
+ WinRM is used to execute password rotation commands on the Windows machine
+ </p>
+ </div>
+
+ <Field>
+ <FieldLabel>
+ Port
+ <Tooltip>
+ <TooltipTrigger>
+ <InfoIcon className="mb-0.5 inline-block size-3 text-accent" />
+ </TooltipTrigger>
+ <TooltipContent>
+ The WinRM port on this machine. Default is 5985 for HTTP or 5986 for HTTPS
+ </TooltipContent>
+ </Tooltip>
+ </FieldLabel>
+ <FieldContent>
+ <UnstableInput
+ type="number"
+ value={winrmPort}
+ onChange={(e) => setWinrmPort(Number(e.target.value))}
+ placeholder="5985"
+ />
+ </FieldContent>
+ </Field>
+
+ <Field orientation="horizontal">
+ <FieldLabel>Enable HTTPS</FieldLabel>
+ <Switch
+ variant="project"
+ checked={useWinrmHttps}
+ onCheckedChange={setUseWinrmHttps}
+ />
+ </Field>
+
+ <Field>
+ <FieldLabel>CA Certificate</FieldLabel>
+ <FieldContent>
+ <TextArea
+ value={winrmCaCert}
+ onChange={(e) => setWinrmCaCert(e.target.value)}
+ className="max-h-32"
+ disabled={!useWinrmHttps}
+ placeholder="-----BEGIN CERTIFICATE-----..."
+ />
+ </FieldContent>
+ </Field>
+
+ <Field orientation="horizontal">
+ <FieldLabel>
+ Reject Unauthorized
+ <Tooltip>
+ <TooltipTrigger>
+ <InfoIcon className="mb-0.5 inline-block size-3 text-accent" />
+ </TooltipTrigger>
+ <TooltipContent>
+ If enabled, Infisical will only connect if the machine has a valid, trusted
+ TLS certificate
+ </TooltipContent>
+ </Tooltip>
+ </FieldLabel>
+ <Switch
+ variant="project"
+ disabled={!useWinrmHttps}
+ checked={useWinrmHttps ? winrmRejectUnauthorized : false}
+ onCheckedChange={setWinrmRejectUnauthorized}
+ />
+ </Field>
+ </div>
+ )}
+
{/* Section: Rotation Rules */}
<div>
<div className="mb-3 flex items-center justify-between">
diff --git a/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/ActiveDirectoryResourceForm.tsx b/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/ActiveDirectoryResourceForm.tsx
index 6a79f21fe8..9a51018ec7 100644
--- a/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/ActiveDirectoryResourceForm.tsx
+++ b/frontend/src/pages/pam/PamResourcesPage/components/PamResourceForm/ActiveDirectoryResourceForm.tsx
@@ -1,5 +1,6 @@
-import { Controller, FormProvider, useForm } from "react-hook-form";
+import { Controller, FormProvider, useForm, useWatch } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";
+import { InfoIcon } from "lucide-react";
import { z } from "zod";
import {
@@ -8,7 +9,13 @@ import {
FieldContent,
FieldError,
FieldLabel,
+ Label,
SheetFooter,
+ Switch,
+ TextArea,
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger,
UnstableInput
} from "@app/components/v3";
import { PamResourceType, TActiveDirectoryResource } from "@app/hooks/api/pam";
@@ -27,7 +34,14 @@ const formSchema = genericResourceFieldsSchema.extend({
connectionDetails: z.object({
domain: z.string().trim().min(1, "Domain is required"),
dcAddress: z.string().trim().min(1, "DC address is required"),
- port: z.coerce.number().int().min(1).max(65535)
+ port: z.coerce.number().int().min(1).max(65535),
+ useLdaps: z.boolean().default(false),
+ ldapRejectUnauthorized: z.boolean().default(true),
+ ldapCaCert: z
+ .string()
+ .trim()
+ .transform((val) => val || undefined)
+ .optional()
})
});
@@ -41,7 +55,13 @@ export const ActiveDirectoryResourceForm = ({ resource, onSubmit, closeSheet }:
defaultValues: resource
? {
...resource,
- gateway: resource.gatewayId ? { id: resource.gatewayId, name: "" } : undefined
+ gateway: resource.gatewayId ? { id: resource.gatewayId, name: "" } : undefined,
+ connectionDetails: {
+ ...resource.connectionDetails,
+ useLdaps: resource.connectionDetails.useLdaps ?? false,
+ ldapRejectUnauthorized: resource.connectionDetails.ldapRejectUnauthorized ?? true,
+ ldapCaCert: resource.connectionDetails.ldapCaCert ?? ""
+ }
}
: {
resourceType: PamResourceType.ActiveDirectory,
@@ -49,7 +69,10 @@ export const ActiveDirectoryResourceForm = ({ resource, onSubmit, closeSheet }:
connectionDetails: {
domain: "",
dcAddress: "",
- port: 389
+ port: 389,
+ useLdaps: false,
+ ldapRejectUnauthorized: true,
+ ldapCaCert: ""
}
}
});
@@ -60,6 +83,8 @@ export const ActiveDirectoryResourceForm = ({ resource, onSubmit, closeSheet }:
formState: { isSubmitting, isDirty }
} = form;
+ const useLdaps = useWatch({ control, name: "connectionDetails.useLdaps" });
+
return (
<FormProvider {...form}>
<form
@@ -117,6 +142,72 @@ export const ActiveDirectoryResourceForm = ({ resource, onSubmit, closeSheet }:
)}
/>
</div>
+ <div className="flex flex-col gap-3">
+ <Label>LDAP</Label>
+
+ <Controller
+ name="connectionDetails.useLdaps"
+ control={control}
+ render={({ field, fieldState: { error } }) => (
+ <Field orientation="horizontal">
+ <FieldLabel>Enable LDAPS</FieldLabel>
+ <Switch
+ variant="project"
+ checked={field.value}
+ onCheckedChange={field.onChange}
+ />
+ <FieldError errors={[error]} />
+ </Field>
+ )}
+ />
+
+ <Controller
+ name="connectionDetails.ldapCaCert"
+ control={control}
+ render={({ field, fieldState: { error } }) => (
+ <Field>
+ <FieldLabel>CA Certificate</FieldLabel>
+ <FieldContent>
+ <TextArea
+ {...field}
+ className="max-h-32"
+ disabled={!useLdaps}
+ placeholder="-----BEGIN CERTIFICATE-----..."
+ />
+ <FieldError errors={[error]} />
+ </FieldContent>
+ </Field>
+ )}
+ />
+
+ <Controller
+ name="connectionDetails.ldapRejectUnauthorized"
+ control={control}
+ render={({ field, fieldState: { error } }) => (
+ <Field orientation="horizontal">
+ <FieldLabel>
+ Reject Unauthorized
+ <Tooltip>
+ <TooltipTrigger>
+ <InfoIcon className="mb-0.5 inline-block size-3 text-accent" />
+ </TooltipTrigger>
+ <TooltipContent>
+ If enabled, Infisical will only connect to the Domain Controller if it has a
+ valid, trusted TLS certificate
+ </TooltipContent>
+ </Tooltip>
+ </FieldLabel>
+ <Switch
+ variant="project"
+ disabled={!useLdaps}
+ checked={useLdaps ? field.value : false}
+ onCheckedChange={field.onChange}
+ />
+ <FieldError errors={[error]} />
+ </Field>
+ )}
+ />
+ </div>
<MetadataFields />
</div>
<SheetFooter className="shrink-0 border-t">