Skip to content

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

fix(ldap-auth): add optional fields for LDAP URL, bind DN, and search base; enforce bind password requirement on URL changes

Victor Hugo dos Santosc294b72f14c5
diff --git a/backend/src/ee/services/identity-auth-template/identity-auth-template-schemas.ts b/backend/src/ee/services/identity-auth-template/identity-auth-template-schemas.ts
index e48ea9908a..bdafa57f96 100644
--- a/backend/src/ee/services/identity-auth-template/identity-auth-template-schemas.ts
+++ b/backend/src/ee/services/identity-auth-template/identity-auth-template-schemas.ts
@@ -123,6 +123,9 @@ export const ldapTemplateFieldsResponseSchema = ldapTemplateFieldsSchema
.omit({ bindPass: true })
.partial()
.extend({
+ url: z.string().optional(),
+ bindDN: z.string().optional(),
+ searchBase: z.string().optional(),
hasBindPass: z.boolean().describe("Whether a bind password is stored for this template")
});
diff --git a/backend/src/ee/services/identity-auth-template/identity-auth-template-service.ts b/backend/src/ee/services/identity-auth-template/identity-auth-template-service.ts
index 64a97139ee..f17a5fb041 100644
--- a/backend/src/ee/services/identity-auth-template/identity-auth-template-service.ts
+++ b/backend/src/ee/services/identity-auth-template/identity-auth-template-service.ts
@@ -518,6 +518,18 @@ export const identityAuthTemplateServiceFactory = ({
kubernetesPropagationData.gatewayPoolId = effectiveGatewayColumns.gatewayPoolId;
}
+ if (fieldPatch && template.authMethod === IdentityAuthTemplateMethod.LDAP) {
+ const merged = mergedTemplateFields as TLdapTemplateFields;
+ const current = currentTemplateFields as TLdapTemplateFields;
+
+ if (merged.url?.trim() !== current.url?.trim() && !("bindPass" in fieldPatch)) {
+ throw new BadRequestError({
+ message:
+ "Changing an LDAP auth template's URL requires supplying bindPass. The stored bind password cannot be read back, and the new URL is applied to every identity linked to this template."
+ });
+ }
+ }
+
let oidcPropagationData: TIdentityOidcAuthsUpdate | undefined;
if (fieldPatch && template.authMethod === IdentityAuthTemplateMethod.OIDC) {
const merged = mergedTemplateFields as TOidcTemplateFields;