Skip to content

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

refactor(ldap-auth): remove bindPass from API and UI components; enforce UUID validation for identityId

Victor Hugo dos Santosada5d6f42bbf
diff --git a/backend/CLAUDE.md b/backend/CLAUDE.md
index e85c5fda08..28bde0525d 100644
--- a/backend/CLAUDE.md
+++ b/backend/CLAUDE.md
@@ -226,9 +226,8 @@ judgment. Two adjustments to that rule, both small enough to enumerate:
body: `POST /v1/identities/search`, `POST /v2/identities/search`, `POST /v2/identities/search/count`,
and the two `memberships/details` routes. All five check a CASL read ability.
- **A read that hands back credential material loses it**, because the point of closing administration is
- that a third-party application should not end up holding the org's secrets. Six routes:
+ that a third-party application should not end up holding the org's secrets. Five routes:
`GET /v1/sso/oidc/config` (`clientSecret`), `GET /v1/ldap/config` (`bindPass`),
- `GET /v1/auth/ldap-auth/identities/:identityId` (`bindPass`),
`GET /v1/workspace/:projectId/kms/backup` (the project's KMS backup blob), and Slack
`GET /install` / `GET /reinstall`, which gate on `OrgPermissionActions.Create` and exist only to start
an install. Everything else reads through a sanitized schema — `sanitizedClientSecretSchema` returns a
diff --git a/backend/src/server/routes/v1/identity-ldap-auth-router.ts b/backend/src/server/routes/v1/identity-ldap-auth-router.ts
index cbf6fa2484..e20984f636 100644
--- a/backend/src/server/routes/v1/identity-ldap-auth-router.ts
+++ b/backend/src/server/routes/v1/identity-ldap-auth-router.ts
@@ -296,7 +296,7 @@ export const registerIdentityLdapAuthRouter = async (server: FastifyZodProvider)
}
],
params: z.object({
- identityId: z.string().trim().describe(LDAP_AUTH.ATTACH.identityId)
+ identityId: z.string().trim().uuid("Identity ID must be a valid UUID").describe(LDAP_AUTH.ATTACH.identityId)
}),
body: z.union([
// Template-based configuration
@@ -503,7 +503,7 @@ export const registerIdentityLdapAuthRouter = async (server: FastifyZodProvider)
}
],
params: z.object({
- identityId: z.string().trim().describe(LDAP_AUTH.UPDATE.identityId)
+ identityId: z.string().trim().uuid("Identity ID must be a valid UUID").describe(LDAP_AUTH.UPDATE.identityId)
}),
body: z
.object({
@@ -641,7 +641,7 @@ export const registerIdentityLdapAuthRouter = async (server: FastifyZodProvider)
}
],
params: z.object({
- identityId: z.string().trim().describe(LDAP_AUTH.RETRIEVE.identityId)
+ identityId: z.string().trim().uuid("Identity ID must be a valid UUID").describe(LDAP_AUTH.RETRIEVE.identityId)
}),
response: {
200: z.object({
@@ -651,7 +651,6 @@ export const registerIdentityLdapAuthRouter = async (server: FastifyZodProvider)
encryptedLdapCaCertificate: true
}).extend({
bindDN: z.string(),
- bindPass: z.string(),
ldapCaCertificate: z.string().optional(),
templateId: z.string().optional().nullable()
})
@@ -700,7 +699,7 @@ export const registerIdentityLdapAuthRouter = async (server: FastifyZodProvider)
}
],
params: z.object({
- identityId: z.string().trim().describe(LDAP_AUTH.REVOKE.identityId)
+ identityId: z.string().trim().uuid("Identity ID must be a valid UUID").describe(LDAP_AUTH.REVOKE.identityId)
}),
response: {
200: z.object({
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 868d30acf0..84ca377be8 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
@@ -786,12 +786,11 @@ export const identityLdapAuthServiceFactory = ({
});
const bindDN = decryptor({ cipherTextBlob: ldapIdentityAuth.encryptedBindDN }).toString();
- const bindPass = decryptor({ cipherTextBlob: ldapIdentityAuth.encryptedBindPass }).toString();
const ldapCaCertificate = ldapIdentityAuth.encryptedLdapCaCertificate
? decryptor({ cipherTextBlob: ldapIdentityAuth.encryptedLdapCaCertificate }).toString()
: undefined;
- return { ...ldapIdentityAuth, orgId: identityMembershipOrg.scopeOrgId, bindDN, bindPass, ldapCaCertificate };
+ return { ...ldapIdentityAuth, orgId: identityMembershipOrg.scopeOrgId, bindDN, ldapCaCertificate };
};
const revokeIdentityLdapAuth = async ({
diff --git a/frontend/src/hooks/api/identities/types.ts b/frontend/src/hooks/api/identities/types.ts
index 8375d14a9e..fef64133b8 100644
--- a/frontend/src/hooks/api/identities/types.ts
+++ b/frontend/src/hooks/api/identities/types.ts
@@ -728,7 +728,6 @@ export type IdentityLdapAuth = {
url?: string;
bindDN?: string;
templateId?: string;
- bindPass?: string;
searchBase?: string;
searchFilter: string;
ldapCaCertificate?: string;
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 a208110082..5ce58cc1f5 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) =>
+const buildSchema = (maxAccessTokenTTL: number, isUpdate: boolean) =>
z
.object({
scope: z.enum(["template", "custom"]),
@@ -177,7 +177,7 @@ const buildSchema = (maxAccessTokenTTL: number) =>
path: ["bindDN"]
});
}
- if (!data.bindPass) {
+ if (!isUpdate && !data.bindPass) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: "Bind Pass is required when using custom scope",
@@ -250,7 +250,10 @@ export const IdentityLdapAuthForm = ({
enabled: isUpdate
});
- const resolver = useMemo(() => zodResolver(buildSchema(maxAccessTokenTTL)), [maxAccessTokenTTL]);
+ const resolver = useMemo(
+ () => zodResolver(buildSchema(maxAccessTokenTTL, Boolean(isUpdate))),
+ [maxAccessTokenTTL, isUpdate]
+ );
const {
control,
@@ -342,7 +345,7 @@ export const IdentityLdapAuthForm = ({
templateId: data.templateId || "",
url: data.url || "",
bindDN: data.bindDN || "",
- bindPass: data.bindPass || "",
+ bindPass: "",
searchBase: data.searchBase || "",
searchFilter: data.searchFilter,
ldapCaCertificate: data.ldapCaCertificate || undefined,
@@ -454,7 +457,7 @@ export const IdentityLdapAuthForm = ({
...basePayload,
url: submissionUrl,
bindDN: submissionBindDN,
- bindPass: submissionBindPass,
+ ...(submissionBindPass ? { bindPass: submissionBindPass } : {}),
searchBase: submissionSearchBase
};
@@ -552,7 +555,7 @@ export const IdentityLdapAuthForm = ({
clearErrors("templateId");
setValue("url", data?.url || "");
setValue("bindDN", data?.bindDN || "");
- setValue("bindPass", data?.bindPass || "");
+ setValue("bindPass", "");
setValue("searchBase", data?.searchBase || "");
setValue("ldapCaCertificate", data?.ldapCaCertificate || "");
return;
@@ -656,6 +659,11 @@ export const IdentityLdapAuthForm = ({
disabled={scope === "template"}
isError={Boolean(error)}
/>
+ {isUpdate && scope !== "template" && (
+ <FieldDescription>
+ Leave blank to keep the current password. Type a new value to rotate it.
+ </FieldDescription>
+ )}
<FieldError>{error?.message}</FieldError>
</Field>
)}
diff --git a/frontend/src/views/IdentityAuthMethods/content/IdentityLdapAuthContent.tsx b/frontend/src/views/IdentityAuthMethods/content/IdentityLdapAuthContent.tsx
index ba1a697a3f..4b1d2132c8 100644
--- a/frontend/src/views/IdentityAuthMethods/content/IdentityLdapAuthContent.tsx
+++ b/frontend/src/views/IdentityAuthMethods/content/IdentityLdapAuthContent.tsx
@@ -55,19 +55,6 @@ export const IdentityLdapAuthContent = ({
/>
<IdentityAuthFieldDisplay label="LDAP URL">{data.url}</IdentityAuthFieldDisplay>
<IdentityAuthFieldDisplay label="Bind DN">{data.bindDN}</IdentityAuthFieldDisplay>
- <IdentityAuthFieldDisplay label="Bind Pass">
- <Tooltip>
- <TooltipTrigger asChild>
- <Badge variant="neutral">
- <EyeIcon />
- Reveal
- </Badge>
- </TooltipTrigger>
- <TooltipContent side="right" className="max-w-xl p-2">
- <p className="rounded-sm bg-container p-2 break-words">{data.bindPass}</p>
- </TooltipContent>
- </Tooltip>
- </IdentityAuthFieldDisplay>
<IdentityAuthFieldDisplay label="Search Base / DN">
{data.searchBase}
</IdentityAuthFieldDisplay>