import { faPlus } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; import { Button, Switch, UpgradePlanModal } from "@app/components/v2"; import { useOrganization, useSubscription } from "@app/context"; import { useCreateSSOConfig, useGetSSOConfig, useUpdateSSOConfig } from "@app/hooks/api"; import { usePopUp } from "@app/hooks/usePopUp"; import { SSOModal } from "./SSOModal"; const ssoAuthProviderMap: { [key: string]: string } = { "okta-saml": "Okta SAML", "azure-saml": "Azure SAML", "jumpcloud-saml": "JumpCloud SAML" } export const OrgSSOSection = (): JSX.Element => { const { currentOrg } = useOrganization(); const { subscription } = useSubscription(); const { createNotification } = useNotificationContext(); const { data, isLoading } = useGetSSOConfig(currentOrg?._id ?? ""); const { mutateAsync } = useUpdateSSOConfig(); const { popUp, handlePopUpOpen, handlePopUpClose, handlePopUpToggle } = usePopUp([ "upgradePlan", "addSSO" ] as const); const { mutateAsync: createMutateAsync } = useCreateSSOConfig(); const handleSamlSSOToggle = async (value: boolean) => { try { if (!currentOrg?._id) return; await mutateAsync({ organizationId: currentOrg?._id, isActive: value }); createNotification({ text: `Successfully ${value ? "enabled" : "disabled"} SAML SSO`, type: "success" }); } catch (err) { console.error(err); createNotification({ text: `Failed to ${value ? "enable" : "disable"} SAML SSO`, type: "error" }); } } const addSSOBtnClick = async () => { try { if (subscription?.samlSSO && currentOrg) { if (!data) { // case: SAML SSO is not configured // -> initialize empty SAML SSO configuration await createMutateAsync({ organizationId: currentOrg._id, authProvider: "okta-saml", isActive: false, entryPoint: "", issuer: "", cert: "" }); } handlePopUpOpen("addSSO"); } else { handlePopUpOpen("upgradePlan"); } } catch (err) { console.error(err); } } return (

SAML SSO Configuration

{!isLoading && ( )}
{data && (
handleSamlSSOToggle(value)} isChecked={data ? data.isActive : false} > Enable SAML SSO
)}

SSO identifier

{(data && data._id !== "") ? data._id : "-"}

Type

{(data && data.authProvider !== "") ? ssoAuthProviderMap[data.authProvider] : "-"}

Entrypoint

{(data && data.entryPoint !== "") ? data.entryPoint : "-"}

Issuer

{(data && data.issuer !== "") ? data.issuer : "-"}

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