mirror of
https://github.com/Unleash/unleash.git
synced 2025-09-28 17:55:15 +02:00
Follows up on https://github.com/Unleash/unleash/pull/4853 to add Biome to the frontend as well.  Added a few `biome-ignore` to speed up the process but we may want to check and fix them in the future.
118 lines
4.4 KiB
TypeScript
118 lines
4.4 KiB
TypeScript
import React, { Fragment } from 'react';
|
|
import { FormControlLabel, Grid, Switch, TextField } from '@mui/material';
|
|
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
|
|
|
|
interface SsoGroupSettingsProps {
|
|
ssoType: 'OIDC' | 'SAML';
|
|
data?: {
|
|
enabled: boolean;
|
|
enableGroupSyncing: boolean;
|
|
groupJsonPath: string;
|
|
addGroupsScope: boolean;
|
|
};
|
|
setValue: (name: string, value: string | boolean) => void;
|
|
}
|
|
|
|
export const SsoGroupSettings = ({
|
|
ssoType,
|
|
data = {
|
|
enabled: false,
|
|
enableGroupSyncing: false,
|
|
groupJsonPath: '',
|
|
addGroupsScope: false,
|
|
},
|
|
setValue,
|
|
}: SsoGroupSettingsProps) => {
|
|
const updateGroupSyncing = () => {
|
|
setValue('enableGroupSyncing', !data.enableGroupSyncing);
|
|
};
|
|
|
|
const updateField = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
setValue(event.target.name, event.target.value);
|
|
};
|
|
|
|
const updateAddGroupScope = () => {
|
|
setValue('addGroupsScope', !data.addGroupsScope);
|
|
};
|
|
return (
|
|
<>
|
|
<Grid container spacing={3} mb={2}>
|
|
<Grid item md={5}>
|
|
<strong>Enable Group Syncing</strong>
|
|
<p>
|
|
Enables automatically syncing of users from the{' '}
|
|
{ssoType}
|
|
provider when a user logs in.
|
|
</p>
|
|
</Grid>
|
|
<Grid item md={6} style={{ padding: '20px' }}>
|
|
<FormControlLabel
|
|
control={
|
|
<Switch
|
|
onChange={updateGroupSyncing}
|
|
value={data.enableGroupSyncing}
|
|
name='enableGroupSyncing'
|
|
checked={data.enableGroupSyncing}
|
|
disabled={!data.enabled}
|
|
/>
|
|
}
|
|
label={data.enableGroupSyncing ? 'Enabled' : 'Disabled'}
|
|
/>
|
|
</Grid>
|
|
</Grid>
|
|
<Grid container spacing={3} mb={2}>
|
|
<Grid item md={5}>
|
|
<strong>Group Field JSON Path</strong>
|
|
<p>
|
|
Specifies the path in the {ssoType} token response from
|
|
which to read the groups the user belongs to.
|
|
</p>
|
|
</Grid>
|
|
<Grid item md={6}>
|
|
<TextField
|
|
onChange={updateField}
|
|
label='Group JSON Path'
|
|
name='groupJsonPath'
|
|
value={data.groupJsonPath}
|
|
disabled={!data.enableGroupSyncing}
|
|
style={{ width: '400px' }}
|
|
variant='outlined'
|
|
size='small'
|
|
required
|
|
/>
|
|
</Grid>
|
|
</Grid>
|
|
<ConditionallyRender
|
|
condition={ssoType === 'OIDC'}
|
|
show={
|
|
<Grid container spacing={3} mb={2}>
|
|
<Grid item md={5}>
|
|
<strong>Request 'groups' Scope</strong>
|
|
<p>
|
|
When enabled Unleash will also request the
|
|
'groups' scope as part of the login request.
|
|
</p>
|
|
</Grid>
|
|
<Grid item md={6} style={{ padding: '20px' }}>
|
|
<FormControlLabel
|
|
control={
|
|
<Switch
|
|
onChange={updateAddGroupScope}
|
|
value={data.addGroupsScope}
|
|
disabled={!data.enableGroupSyncing}
|
|
name='addGroupsScope'
|
|
checked={data.addGroupsScope}
|
|
/>
|
|
}
|
|
label={
|
|
data.addGroupsScope ? 'Enabled' : 'Disabled'
|
|
}
|
|
/>
|
|
</Grid>
|
|
</Grid>
|
|
}
|
|
/>
|
|
</>
|
|
);
|
|
};
|