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
make the option more explicit
Thiago Araujo da Silvabb8507f9093c
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.tsxindex 12603cb6c2..768044057a 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@@ -2,7 +2,15 @@ import { useEffect, useMemo, useState } from "react";import { Controller, useFieldArray, useForm } from "react-hook-form";import { zodResolver } from "@hookform/resolvers/zod";import { useParams } from "@tanstack/react-router";-import { HelpCircleIcon, InfoIcon, PlusIcon, TriangleAlertIcon, XIcon } from "lucide-react";+import {+ HelpCircleIcon,+ InfoIcon,+ PlusIcon,+ TriangleAlertIcon,+ UserRoundCheckIcon,+ UsersRoundIcon,+ XIcon+} from "lucide-react";import ms from "ms";import { z } from "zod";@@ -13,11 +21,16 @@ import {AlertTitle,Button,Field,+ FieldContent,+ FieldDescription,FieldError,FieldGroup,FieldLabel,+ FieldTitle,IconButton,Input,+ RadioGroup,+ RadioGroupItem,Select,SelectContent,SelectItem,@@ -77,6 +90,7 @@ const buildSchema = (maxAccessTokenTTL: number) =>.string().optional().transform((val) => val || undefined),+ userAccess: z.enum(["restricted", "all"]),allowedFields: z.object({key: z.string().trim(),@@ -113,22 +127,32 @@ const buildSchema = (maxAccessTokenTTL: number) =>.superRefine((data, ctx) => {superRefineLockout(data, ctx);- data.allowedFields?.forEach((field, index) => {- if (!field.key) {- ctx.addIssue({- code: z.ZodIssueCode.custom,- message: "Attribute key is required",- path: ["allowedFields", index, "key"]- });- }- if (!field.value) {+ if (data.userAccess === "restricted") {+ if (!data.allowedFields || data.allowedFields.length === 0) {ctx.addIssue({code: z.ZodIssueCode.custom,- message: "Attribute value is required",- path: ["allowedFields", index, "value"]+ message: "Add at least one required attribute, or allow any directory user",+ path: ["allowedFields"]});}- });++ data.allowedFields?.forEach((field, index) => {+ if (!field.key) {+ ctx.addIssue({+ code: z.ZodIssueCode.custom,+ message: "Attribute key is required",+ path: ["allowedFields", index, "key"]+ });+ }+ if (!field.value) {+ ctx.addIssue({+ code: z.ZodIssueCode.custom,+ message: "Attribute value is required",+ path: ["allowedFields", index, "value"]+ });+ }+ });+ }// Validation based on scopeif (data.scope === "template") {@@ -242,6 +266,8 @@ export const IdentityLdapAuthForm = ({bindPass: "",searchBase: "",searchFilter: "(uid={{username}})",+ userAccess: "restricted",+ allowedFields: [{ key: "", value: "" }],accessTokenTTL: "2592000",accessTokenMaxTTL: "2592000",accessTokenNumUsesLimit: "",@@ -262,9 +288,12 @@ export const IdentityLdapAuthForm = ({const {fields: allowedFieldsFields,append: appendAllowedField,- remove: removeAllowedField+ remove: removeAllowedField,+ replace: replaceAllowedFields} = useFieldArray({ control, name: "allowedFields" });+ const userAccess = watch("userAccess");+// Helper function to determine scope based on existing dataconst determineScope = (authData: any) => {// If templateId exists in the data, it's template scope@@ -291,6 +320,7 @@ export const IdentityLdapAuthForm = ({searchBase: data.searchBase || "",searchFilter: data.searchFilter,ldapCaCertificate: data.ldapCaCertificate || undefined,+ userAccess: data.allowedFields && data.allowedFields.length > 0 ? "restricted" : "all",allowedFields: data.allowedFields || [],accessTokenTTL: String(data.accessTokenTTL),accessTokenMaxTTL: String(data.accessTokenMaxTTL),@@ -317,7 +347,8 @@ export const IdentityLdapAuthForm = ({searchBase: "",searchFilter: "(uid={{username}})",ldapCaCertificate: undefined,- allowedFields: [],+ userAccess: "restricted",+ allowedFields: [{ key: "", value: "" }],accessTokenTTL: "2592000",accessTokenMaxTTL: "2592000",accessTokenNumUsesLimit: "",@@ -352,6 +383,7 @@ export const IdentityLdapAuthForm = ({searchBase: submissionSearchBase,searchFilter,ldapCaCertificate,+ userAccess: submissionUserAccess,allowedFields,accessTokenTTL,accessTokenMaxTTL,@@ -369,12 +401,15 @@ export const IdentityLdapAuthForm = ({const lockoutCounterResetSeconds =ms(`${lockoutCounterResetValue}${lockoutCounterResetUnit}`) / 1000;+ // "Allow any directory user" clears the attribute restriction entirely.+ const submissionAllowedFields = submissionUserAccess === "all" ? [] : allowedFields;+const basePayload = {...(projectId ? { projectId } : { organizationId: orgId }),identityId,searchFilter,ldapCaCertificate,- allowedFields,+ allowedFields: submissionAllowedFields,accessTokenTTL: Number(accessTokenTTL),accessTokenMaxTTL: Number(accessTokenMaxTTL),accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit || "0"),@@ -664,123 +699,177 @@ export const IdentityLdapAuthForm = ({)}/>- <div className="flex flex-col gap-3">- <FieldLabel className="inline-flex items-center gap-1.5">- Authorized User Attributes- <Tooltip>- <TooltipTrigger asChild>- <HelpCircleIcon className="size-3.5 text-muted" />- </TooltipTrigger>- <TooltipContent className="max-w-md">- <div className="max-h-[300px] space-y-4 overflow-y-auto text-sm">- <p>- Restrict which directory users may authenticate as this identity by listing- the LDAP attributes their entry must match. Only users whose entry matches- every attribute below are authorized.- </p>- <p>- If no attributes are specified, every user in the configured LDAP directory- will be able to authenticate as this identity.- </p>- <p>- You can allow multiple values for an attribute by separating them with a- comma.- </p>- <div className="space-y-2">- <p>Example:</p>- <p className="text-xs text-muted">- 'uid' → 'user1,user2,user3'- <br />- 'mail' → '[email protected]'- </p>- </div>- <p>- The above example would allow users with the UID user1, user2, or user3 to- authenticate but only if their emails also match [email protected]- </p>- </div>- </TooltipContent>- </Tooltip>- </FieldLabel>- {allowedFieldsFields.length > 0 && (- <p className="-mt-1 text-xs text-muted">- Remove all attributes to allow every directory user to authenticate as this- identity.- </p>- )}- {allowedFieldsFields.map(({ id }, index) => (- <div className="flex items-start gap-2" key={id}>- <Controller- control={control}- name={`allowedFields.${index}.key`}- render={({ field, fieldState: { error } }) => (- <Field className="flex-1">- <Input- id={`allowedField-key-${index}`}- value={field.value}- onChange={(e) => field.onChange(e)}- placeholder="uid"- isError={Boolean(error)}- />- <FieldError>{error?.message}</FieldError>+ <Controller+ control={control}+ name="userAccess"+ render={({ field: { value, onChange } }) => (+ <Field>+ <FieldLabel className="inline-flex items-center gap-1.5">+ User access+ <Tooltip>+ <TooltipTrigger asChild>+ <HelpCircleIcon className="size-3.5 text-muted" />+ </TooltipTrigger>+ <TooltipContent className="max-w-xs text-sm">+ Choose whether only directory users matching the required attributes may+ authenticate as this identity, or any user who can bind to the directory.+ </TooltipContent>+ </Tooltip>+ </FieldLabel>+ <FieldDescription>+ Choose which directory users may assume this identity.+ </FieldDescription>+ <RadioGroup+ className="grid grid-cols-2 gap-3"+ value={value}+ onValueChange={(next) => {+ onChange(next);+ if (next === "restricted" && allowedFieldsFields.length === 0) {+ replaceAllowedFields([{ key: "", value: "" }]);+ }+ }}+ >+ <FieldLabel htmlFor="user-access-restricted" variant="org">+ <Field orientation="horizontal">+ <FieldContent>+ <FieldTitle>+ <UserRoundCheckIcon />+ Restrict+ </FieldTitle>+ <FieldDescription>Match on the attributes</FieldDescription>+ </FieldContent>+ <RadioGroupItem value="restricted" id="user-access-restricted" /></Field>- )}- />- <Controller- control={control}- name={`allowedFields.${index}.value`}- render={({ field, fieldState: { error } }) => (- <Field className="flex-1">- <Input- id={`allowedField-value-${index}`}- value={field.value}- onChange={(e) => field.onChange(e)}- placeholder="userid1,userid2,userid3"- isError={Boolean(error)}- />- <FieldError>{error?.message}</FieldError>+ </FieldLabel>+ <FieldLabel htmlFor="user-access-all" variant="org">+ <Field orientation="horizontal">+ <FieldContent>+ <FieldTitle>+ <UsersRoundIcon />+ Allow any+ </FieldTitle>+ <FieldDescription>Anyone who can bind</FieldDescription>+ </FieldContent>+ <RadioGroupItem value="all" id="user-access-all" /></Field>- )}- />- <IconButton- type="button"- variant="ghost"- size="sm"- aria-label="Remove authorized attribute"- className="mt-0.5"- onClick={() => removeAllowedField(index)}- >- <XIcon />- </IconButton>- </div>- ))}- {allowedFieldsFields.length === 0 && (- <Alert variant="warning">- <TriangleAlertIcon />- <AlertTitle>All directory users can authenticate</AlertTitle>- <AlertDescription>- No authorized attributes are set, so every user in the configured LDAP directory- can authenticate as this identity. Add at least one attribute to restrict- access.- </AlertDescription>- </Alert>+ </FieldLabel>+ </RadioGroup>+ </Field>)}- <Button- type="button"- variant="outline"- size="xs"- className="w-fit"- onClick={() =>- appendAllowedField({- key: "",- value: ""- })- }- >- <PlusIcon />- Add Attribute- </Button>- </div>+ />++ {userAccess === "all" ? (+ <Alert variant="warning">+ <TriangleAlertIcon />+ <AlertTitle>All directory users can authenticate</AlertTitle>+ <AlertDescription>+ Every user in the configured LDAP directory who can bind will be able to+ authenticate as this identity. Switch to "Restrict" to+ limit access.+ </AlertDescription>+ </Alert>+ ) : (+ <div className="flex flex-col gap-3">+ <FieldLabel className="inline-flex items-center gap-1.5">+ Authorized user attributes+ <Tooltip>+ <TooltipTrigger asChild>+ <HelpCircleIcon className="size-3.5 text-muted" />+ </TooltipTrigger>+ <TooltipContent className="max-w-md">+ <div className="max-h-[300px] space-y-4 overflow-y-auto text-sm">+ <p>+ Only directory users whose LDAP entry matches every attribute below are+ authorized to authenticate as this identity.+ </p>+ <p>+ You can allow multiple values for an attribute by separating them with a+ comma.+ </p>+ <div className="space-y-2">+ <p>Example:</p>+ <p className="text-xs text-muted">+ 'uid' → 'user1,user2,user3'+ <br />+ 'mail' → '[email protected]'+ </p>+ </div>+ <p>+ The above example would allow users with the UID user1, user2, or user3 to+ authenticate but only if their emails also match [email protected]+ </p>+ </div>+ </TooltipContent>+ </Tooltip>+ </FieldLabel>+ {allowedFieldsFields.map(({ id }, index) => (+ <div className="flex items-start gap-2" key={id}>+ <Controller+ control={control}+ name={`allowedFields.${index}.key`}+ render={({ field, fieldState: { error } }) => (+ <Field className="flex-1">+ <Input+ id={`allowedField-key-${index}`}+ value={field.value}+ onChange={(e) => field.onChange(e)}+ placeholder="uid"+ isError={Boolean(error)}+ />+ <FieldError>{error?.message}</FieldError>+ </Field>+ )}+ />+ <Controller+ control={control}+ name={`allowedFields.${index}.value`}+ render={({ field, fieldState: { error } }) => (+ <Field className="flex-1">+ <Input+ id={`allowedField-value-${index}`}+ value={field.value}+ onChange={(e) => field.onChange(e)}+ placeholder="userid1,userid2,userid3"+ isError={Boolean(error)}+ />+ <FieldError>{error?.message}</FieldError>+ </Field>+ )}+ />+ <IconButton+ type="button"+ variant="ghost"+ size="sm"+ aria-label="Remove required attribute"+ className="mt-0.5"+ onClick={() => removeAllowedField(index)}+ >+ <XIcon />+ </IconButton>+ </div>+ ))}+ {allowedFieldsFields.length === 0 && (+ <FieldError>+ Add at least one attribute, or allow any directory user.+ </FieldError>+ )}+ <Button+ type="button"+ variant="outline"+ size="xs"+ className="w-fit"+ onClick={() =>+ appendAllowedField({+ key: "",+ value: ""+ })+ }+ >+ <PlusIcon />+ Add attribute+ </Button>+ </div>+ )}<AccessTokenTtlFields control={control} maxAccessTokenTTL={maxAccessTokenTTL} /><AccessTokenNumUsesLimitField control={control} />