import React, { useContext, useEffect, useState } from 'react'; import { Button, FormControlLabel, Grid, Switch, TextField, } from '@mui/material'; import { Alert } from '@mui/material'; import { PageContent } from 'component/common/PageContent/PageContent'; import AccessContext from 'contexts/AccessContext'; import { ADMIN } from 'component/providers/AccessProvider/permissions'; import { AutoCreateForm } from '../AutoCreateForm/AutoCreateForm'; import useToast from 'hooks/useToast'; import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig'; import useAuthSettings from 'hooks/api/getters/useAuthSettings/useAuthSettings'; import useAuthSettingsApi from 'hooks/api/actions/useAuthSettingsApi/useAuthSettingsApi'; import { formatUnknownError } from 'utils/formatUnknownError'; import { removeEmptyStringFields } from 'utils/removeEmptyStringFields'; const initialState = { enabled: false, autoCreate: false, unleashHostname: location.hostname, entityId: '', signOnUrl: '', certificate: '', signOutUrl: '', spCertificate: '', }; export const SamlAuth = () => { const { setToastData, setToastApiError } = useToast(); const { uiConfig } = useUiConfig(); const [data, setData] = useState(initialState); const { hasAccess } = useContext(AccessContext); const { config } = useAuthSettings('saml'); const { updateSettings, errors, loading } = useAuthSettingsApi('saml'); useEffect(() => { if (config.entityId) { setData(config); } }, [config]); if (!hasAccess(ADMIN)) { return ( You need to be a root admin to access this section. ); } const updateField = (event: React.ChangeEvent) => { setValue(event.target.name, event.target.value); }; const updateEnabled = () => { setData({ ...data, enabled: !data.enabled }); }; const setValue = (name: string, value: string | boolean) => { setData({ ...data, [name]: value, }); }; const onSubmit = async (event: React.SyntheticEvent) => { event.preventDefault(); try { await updateSettings(removeEmptyStringFields(data)); setToastData({ title: 'Settings stored', type: 'success', }); } catch (error: unknown) { setToastApiError(formatUnknownError(error)); } }; return ( Please read the{' '} documentation {' '} to learn how to integrate with specific SAML 2.0 providers (Okta, Keycloak, etc).
Callback URL:{' '} {uiConfig.unleashUrl}/auth/saml/callback
Enable

Enable SAML 2.0 Authentication.

} label={data.enabled ? 'Enabled' : 'Disabled'} />
Entity ID

(Required) The Entity Identity provider issuer.

Single Sign-On URL

(Required) The url to redirect the user to for signing in.

X.509 Certificate

(Required) The certificate used to sign the SAML 2.0 request.

Optional Configuration

Single Sign-out URL

(Optional) The url to redirect the user to for signing out of the IDP.

Service Provider X.509 Certificate

(Optional) The private certificate used by the Service Provider used to sign the SAML 2.0 request towards the IDP. E.g. used to sign single logout requests (SLO).

{' '}

{errors?.message}

); };