import { twMerge } from "tailwind-merge"; import { Button, ContentLoader, UpgradePlanModal } from "@app/components/v2"; import { OrgPermissionActions, OrgPermissionSubjects, useOrganization, useServerConfig, useSubscription } from "@app/context"; import { withPermission } from "@app/hoc"; import { usePopUp } from "@app/hooks"; import { useGetLDAPConfig, useGetOIDCConfig, useGetSSOConfig } from "@app/hooks/api"; import { LoginMethod } from "@app/hooks/api/admin/types"; import { LDAPModal } from "./LDAPModal"; import { OIDCModal } from "./OIDCModal"; import { OrgGeneralAuthSection } from "./OrgGeneralAuthSection"; import { OrgLDAPSection } from "./OrgLDAPSection"; import { OrgOIDCSection } from "./OrgOIDCSection"; import { OrgScimSection } from "./OrgSCIMSection"; import { OrgSSOSection } from "./OrgSSOSection"; import { SSOModal } from "./SSOModal"; export const OrgAuthTab = withPermission( () => { const { config: { enabledLoginMethods } } = useServerConfig(); const { currentOrg } = useOrganization(); const { popUp, handlePopUpOpen, handlePopUpClose, handlePopUpToggle } = usePopUp([ "addLDAP", "addSSO", "addOIDC", "upgradePlan" ] as const); const { subscription } = useSubscription(); const { data: oidcConfig, isLoading: isLoadingOidcConfig } = useGetOIDCConfig( currentOrg?.slug ?? "" ); const { data: samlConfig, isLoading: isLoadingSamlConfig } = useGetSSOConfig( currentOrg?.id ?? "" ); const { data: ldapConfig, isLoading: isLdapConfig } = useGetLDAPConfig(currentOrg?.id ?? ""); const areConfigsLoading = isLoadingOidcConfig || isLoadingSamlConfig || isLdapConfig; const shouldDisplaySection = (method: LoginMethod) => !enabledLoginMethods || enabledLoginMethods.includes(method); const isOidcConfigured = oidcConfig && (oidcConfig.discoveryURL || oidcConfig.issuer); const isSamlConfigured = samlConfig && samlConfig.entryPoint; const isLdapConfigured = ldapConfig && ldapConfig.url; const shouldShowCreateIdentityProviderView = !isOidcConfigured && !isSamlConfigured && !isLdapConfigured; const createIdentityProviderView = (shouldDisplaySection(LoginMethod.SAML) || shouldDisplaySection(LoginMethod.OIDC) || shouldDisplaySection(LoginMethod.LDAP)) && ( <>
Connect an Identity Provider
Connect your identity provider to simplify user management
{shouldDisplaySection(LoginMethod.SAML) && (SAML
OIDC
LDAP