import { UpgradePlanModal } from "@app/components/license/UpgradePlanModal"; import { createNotification } from "@app/components/notifications"; import { OrgPermissionCan } from "@app/components/permissions"; import { Button, Switch } from "@app/components/v2"; import { OrgPermissionActions, OrgPermissionSubjects, useOrganization, useSubscription } from "@app/context"; import { useCreateLDAPConfig, useGetLDAPConfig, useUpdateLDAPConfig } from "@app/hooks/api"; import { usePopUp } from "@app/hooks/usePopUp"; import { LDAPGroupMapModal } from "./LDAPGroupMapModal"; import { LDAPModal } from "./LDAPModal"; export const OrgLDAPSection = (): JSX.Element => { const { currentOrg } = useOrganization(); const { subscription } = useSubscription(); const { data } = useGetLDAPConfig(currentOrg?.id ?? ""); const { mutateAsync } = useUpdateLDAPConfig(); const { popUp, handlePopUpOpen, handlePopUpClose, handlePopUpToggle } = usePopUp([ "addLDAP", "ldapGroupMap", "deleteLdapGroupMap", "upgradePlan" ] as const); const { mutateAsync: createMutateAsync } = useCreateLDAPConfig(); const handleLDAPToggle = async (value: boolean) => { try { if (!currentOrg?.id) return; if (!subscription?.ldap) { handlePopUpOpen("upgradePlan"); return; } await mutateAsync({ organizationId: currentOrg?.id, isActive: value }); createNotification({ text: `Successfully ${value ? "enabled" : "disabled"} LDAP`, type: "success" }); } catch (err) { console.error(err); createNotification({ text: `Failed to ${value ? "enable" : "disable"} LDAP`, type: "error" }); } }; const addLDAPBtnClick = async () => { try { if (subscription?.ldap && currentOrg) { if (!data) { // case: LDAP is not configured // -> initialize empty LDAP configuration await createMutateAsync({ organizationId: currentOrg.id, isActive: false, url: "", bindDN: "", bindPass: "", uniqueUserAttribute: "", searchBase: "", searchFilter: "", groupSearchBase: "", groupSearchFilter: "" }); } handlePopUpOpen("addLDAP"); } else { handlePopUpOpen("upgradePlan"); } } catch (err) { console.error(err); } }; const openLDAPGroupMapModal = () => { if (!subscription?.ldap) { handlePopUpOpen("upgradePlan"); return; } handlePopUpOpen("ldapGroupMap"); }; return (
LDAP
Manage LDAP authentication configuration
Allow members to authenticate into Infisical with LDAP
Manage how LDAP groups are mapped to internal groups in Infisical