import React, { useState, useEffect } from 'react'; import PropTypes from 'prop-types'; import { Button, Grid, Switch, TextField, Typography } from '@material-ui/core'; import PageContent from '../../../component/common/PageContent/PageContent'; const initialState = { enabled: false, autoCreate: false, unleashHostname: location.hostname, }; function SamlAuth({ config, getSamlConfig, updateSamlConfig, hasPermission }) { const [data, setData] = useState(initialState); const [info, setInfo] = useState(); useEffect(() => { getSamlConfig(); // eslint-disable-next-line react-hooks/exhaustive-deps }, []); useEffect(() => { if (config.entityId) { setData(config); } // eslint-disable-next-line react-hooks/exhaustive-deps }, [config]); if (!hasPermission('ADMIN')) { return You need admin privileges to access this section.; } const updateField = e => { setData({ ...data, [e.target.name]: e.target.value, }); }; const updateEnabled = () => { setData({ ...data, enabled: !data.enabled }); }; const updateAutoCreate = () => { setData({ ...data, autoCreate: !data.autoCreate }); }; const onSubmit = async e => { e.preventDefault(); setInfo('...saving'); try { await updateSamlConfig(data); setInfo('Settings stored'); setTimeout(() => setInfo(''), 2000); } catch (e) { setInfo(e.message); } }; return ( Please read the{' '} documentation {' '} to learn how to integrate with specific SAML 2.0 providers (Okta, Keycloak, etc).
Callback URL: https://[unleash.hostname.com]/auth/saml/callback
Enable

Enable SAML 2.0 Authentication.

{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.

Auto-create users

Enable automatic creation of new users when signing in with Saml.

Auto-create users
Email domains

(Optional) Comma separated list of email domains that should be allowed to sign in.

{' '} {info}
); } SamlAuth.propTypes = { config: PropTypes.object, getSamlConfig: PropTypes.func.isRequired, updateSamlConfig: PropTypes.func.isRequired, hasPermission: PropTypes.func.isRequired, }; export default SamlAuth;