Skip to content

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

fix(ldap-auth): enforce bind password requirement when changing LDAP URL

Victor Hugo dos Santose6adde716338
diff --git a/backend/src/services/identity-ldap-auth/identity-ldap-auth-service.ts b/backend/src/services/identity-ldap-auth/identity-ldap-auth-service.ts
index 5ec50ff6bc..572a11acbe 100644
--- a/backend/src/services/identity-ldap-auth/identity-ldap-auth-service.ts
+++ b/backend/src/services/identity-ldap-auth/identity-ldap-auth-service.ts
@@ -687,6 +687,13 @@ export const identityLdapAuthServiceFactory = ({
};
}
+ if (!template && config.url && config.url !== identityLdapAuth.url && !config.bindPass) {
+ throw new BadRequestError({
+ message:
+ "Changing the LDAP URL requires supplying bindPass, because the stored bind password cannot be read back. Send the bind password for the new server with this change."
+ });
+ }
+
let encryptedBindPass: Buffer | undefined;
if (config.bindPass) {
const { cipherTextBlob: bindPassCiphertext } = encryptor({
diff --git a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityLdapAuthForm.tsx b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityLdapAuthForm.tsx
index a10ec1caf5..6c0ac68d60 100644
--- a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityLdapAuthForm.tsx
+++ b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityLdapAuthForm.tsx
@@ -72,7 +72,7 @@ import { AccessTokenTtlFields } from "./shared/AccessTokenTtlFields";
import { TrustedIpsField } from "./shared/TrustedIpsField";
import { IDENTITY_AUTH_FORM_ID, IdentityFormTab } from "./types";
-const buildSchema = (maxAccessTokenTTL: number, isUpdate: boolean) =>
+const buildSchema = (maxAccessTokenTTL: number, isUpdate: boolean, currentUrl?: string) =>
z
.object({
scope: z.enum(["template", "custom"]),
@@ -177,10 +177,12 @@ const buildSchema = (maxAccessTokenTTL: number, isUpdate: boolean) =>
path: ["bindDN"]
});
}
- if (!isUpdate && !data.bindPass) {
+ if (!data.bindPass && (!isUpdate || data.url !== currentUrl)) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
- message: "Bind Pass is required when using custom scope",
+ message: isUpdate
+ ? "Bind Pass is required when the LDAP URL changes"
+ : "Bind Pass is required when using custom scope",
path: ["bindPass"]
});
}
@@ -253,8 +255,8 @@ export const IdentityLdapAuthForm = ({
});
const resolver = useMemo(
- () => zodResolver(buildSchema(maxAccessTokenTTL, Boolean(isUpdate))),
- [maxAccessTokenTTL, isUpdate]
+ () => zodResolver(buildSchema(maxAccessTokenTTL, Boolean(isUpdate), data?.url)),
+ [maxAccessTokenTTL, isUpdate, data?.url]
);
const {
@@ -288,6 +290,10 @@ export const IdentityLdapAuthForm = ({
const scope = watch("scope");
const templateId = watch("templateId");
+ const urlValue = watch("url");
+ const hasUrlChanged = Boolean(
+ isUpdate && scope !== "template" && data?.url && urlValue !== data.url
+ );
const configurationOptions = useMemo<ConfigurationOption[]>(
() => [
@@ -668,7 +674,9 @@ export const IdentityLdapAuthForm = ({
/>
{isUpdate && scope !== "template" && (
<FieldDescription>
- Leave blank to keep the current password. Type a new value to rotate it.
+ {hasUrlChanged
+ ? "The LDAP URL changed, so the bind password must be re-entered."
+ : "Leave blank to keep the current password. Type a new value to rotate it."}
</FieldDescription>
)}
<FieldError>{error?.message}</FieldError>