import { faInfoCircle } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { twMerge } from "tailwind-merge"; import { UpgradePlanModal } from "@app/components/license/UpgradePlanModal"; import { createNotification } from "@app/components/notifications"; import { OrgPermissionCan } from "@app/components/permissions"; import { Switch, Tooltip } from "@app/components/v2"; import { OrgPermissionActions, OrgPermissionSubjects, useOrganization, useSubscription } from "@app/context"; import { useLogoutUser, useUpdateOrg } from "@app/hooks/api"; import { usePopUp } from "@app/hooks/usePopUp"; enum EnforceAuthType { SAML = "saml", GOOGLE = "google", OIDC = "oidc" } export const OrgGeneralAuthSection = ({ isSamlConfigured, isOidcConfigured, isGoogleConfigured, isSamlActive, isOidcActive, isLdapActive }: { isSamlConfigured: boolean; isOidcConfigured: boolean; isGoogleConfigured: boolean; isSamlActive: boolean; isOidcActive: boolean; isLdapActive: boolean; }) => { const { currentOrg } = useOrganization(); const { subscription } = useSubscription(); const { popUp, handlePopUpOpen, handlePopUpToggle } = usePopUp(["upgradePlan"] as const); const { mutateAsync } = useUpdateOrg(); const logout = useLogoutUser(); const handleEnforceOrgAuthToggle = async (value: boolean, type: EnforceAuthType) => { try { if (!currentOrg?.id) return; if (type === EnforceAuthType.SAML) { if (!subscription?.samlSSO) { handlePopUpOpen("upgradePlan"); return; } await mutateAsync({ orgId: currentOrg?.id, authEnforced: value }); } else if (type === EnforceAuthType.GOOGLE) { if (!subscription?.enforceGoogleSSO) { handlePopUpOpen("upgradePlan"); return; } await mutateAsync({ orgId: currentOrg?.id, googleSsoAuthEnforced: value }); } else if (type === EnforceAuthType.OIDC) { if (!subscription?.oidcSSO) { handlePopUpOpen("upgradePlan"); return; } await mutateAsync({ orgId: currentOrg?.id, authEnforced: value }); } else { createNotification({ text: `Invalid auth enforcement type ${type}`, type: "error" }); } createNotification({ text: `Successfully ${value ? "enabled" : "disabled"} org-level auth`, type: "success" }); if (value) { await logout.mutateAsync(); if (type === EnforceAuthType.SAML) { window.open(`/api/v1/sso/redirect/saml2/organizations/${currentOrg.slug}`); } else if (type === EnforceAuthType.GOOGLE) { window.open(`/api/v1/sso/redirect/google?org_slug=${currentOrg.slug}`); } window.close(); } } catch (err) { console.error(err); createNotification({ text: (err as { response: { data: { message: string } } }).response.data.message, type: "error" }); } }; const handleEnableBypassOrgAuthToggle = async (value: boolean) => { try { if (!currentOrg?.id) return; if (!subscription?.samlSSO) { handlePopUpOpen("upgradePlan"); return; } await mutateAsync({ orgId: currentOrg?.id, bypassOrgAuthEnabled: value }); createNotification({ text: `Successfully ${value ? "enabled" : "disabled"} admin bypassing of org-level auth`, type: "success" }); } catch (err) { console.error(err); } }; const isGoogleOAuthEnforced = currentOrg.googleSsoAuthEnforced; const getActiveSsoLabel = () => { if (isSamlActive) return "SAML"; if (isOidcActive) return "OIDC"; if (isLdapActive) return "LDAP"; return ""; }; return (

SSO Enforcement

Manage strict enforcement of specific authentication methods for your organization.

Enforce SAML SSO
{(isAllowed) => ( handleEnforceOrgAuthToggle(value, EnforceAuthType.SAML) } isChecked={currentOrg?.authEnforced ?? false} isDisabled={!isAllowed || currentOrg?.googleSsoAuthEnforced} /> )}

Enforce users to authenticate via SAML to access this organization.
When this is enabled your organization members will only be able to login with SAML.

Enforce OIDC SSO
{(isAllowed) => ( handleEnforceOrgAuthToggle(value, EnforceAuthType.OIDC) } isDisabled={!isAllowed} /> )}

Enforce users to authenticate via OIDC to access this organization.
When this is enabled your organization members will only be able to login with OIDC.

Enforce Google OAuth
{(isAllowed) => (
handleEnforceOrgAuthToggle(value, EnforceAuthType.GOOGLE) } isChecked={currentOrg?.googleSsoAuthEnforced ?? false} isDisabled={ !isAllowed || currentOrg?.authEnforced || isOidcActive || isSamlActive || isLdapActive } />
)}

Enforce users to authenticate via Google OAuth to access this organization.
When this is enabled your organization members will only be able to login with Google OAuth (not Google SAML).

{(currentOrg?.authEnforced || currentOrg?.googleSsoAuthEnforced) && (
Enable Admin SSO Bypass When enabling admin SSO bypass, we highly recommend enabling MFA enforcement at the organization-level for security reasons.

In case of a lockout, admins can use the{" "} Admin Login Portal {" "} at{" "} {window.location.origin}/login/admin

} >
{(isAllowed) => ( handleEnableBypassOrgAuthToggle(value)} isDisabled={!isAllowed} /> )}

Allow organization admins to bypass SSO login enforcement when your SSO provider is unavailable, misconfigured, or inaccessible.

)} handlePopUpToggle("upgradePlan", isOpen)} text="You can enforce SAML SSO if you switch to Infisical's Pro plan." /> ); };