implemented the multi select for the sso authentication disabled

This commit is contained in:
Simone Taeggi 2023-05-18 11:41:43 +02:00
parent bdd0c462a1
commit c5ab7915d6
5 changed files with 139 additions and 1 deletions

View File

@ -245,6 +245,8 @@
"Settings.sso.form.defaultRole.description": "It will attach the new authenticated user to the selected role",
"Settings.sso.form.defaultRole.description-not-allowed": "You need to have the permission to read the admin roles",
"Settings.sso.form.defaultRole.label": "Default role",
"Settings.sso.form.localAuthenticationLock.label": "Local authentication lock-out",
"Settings.sso.form.localAuthenticationLock.description": "Select the roles for which you want to disable the local authentication",
"Settings.sso.form.registration.description": "Create new user on SSO login if no account exists",
"Settings.sso.form.registration.label": "Auto-registration",
"Settings.sso.title": "Single Sign-On",

View File

@ -20,6 +20,8 @@ import {
Grid,
GridItem,
Flex,
MultiSelect,
MultiSelectOption,
} from '@strapi/design-system';
import { useIntl } from 'react-intl';
import isEqual from 'lodash/isEqual';
@ -49,6 +51,7 @@ export const SingleSignOn = () => {
] = useSettingsForm(getRequestUrl('providers/options'), schema, () => {}, [
'autoRegister',
'defaultRole',
'authenticationDisabled',
]);
const { roles } = useRolesList(canReadRoles);
@ -189,6 +192,44 @@ export const SingleSignOn = () => {
))}
</Select>
</GridItem>
<GridItem col={6} m={6} s={12}>
<MultiSelect
disabled={!canUpdate}
hint={formatMessage({
id: 'Settings.sso.form.localAuthenticationLock.description',
defaultMessage:
'Select the roles for which you want to disable the local authentication',
})}
error={
formErrors.authenticationDisabled
? formatMessage({
id: formErrors.authenticationDisabled.id,
defaultMessage: formErrors.authenticationDisabled.id,
})
: ''
}
label={formatMessage({
id: 'Settings.sso.form.localAuthenticationLock.label',
defaultMessage: 'Local authentication lock-out',
})}
name="authenticationDisabled"
onChange={(value) => {
handleChange({ target: { name: 'authenticationDisabled', value } });
}}
placeholder={formatMessage({
id: 'components.InputSelect.option.placeholder',
defaultMessage: 'Choose here',
})}
value={modifiedData.authenticationDisabled}
withTags
>
{roles.map(({ id, name }) => (
<MultiSelectOption key={id} value={id.toString()}>
{name}
</MultiSelectOption>
))}
</MultiSelect>
</GridItem>
</Grid>
</Flex>
)}

View File

@ -142,6 +142,16 @@ exports[`Admin | ee | SettingsPage | SSO renders and matches the snapshot 1`] =
color: #32324d;
}
.c47 {
font-size: 0.875rem;
line-height: 1.43;
display: block;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
color: #666687;
}
.c5 {
-webkit-align-items: center;
-webkit-box-align: center;
@ -437,7 +447,7 @@ exports[`Admin | ee | SettingsPage | SSO renders and matches the snapshot 1`] =
flex-wrap: wrap;
}
.c47[data-state='checked'] .c8 {
.c48[data-state='checked'] .c8 {
font-weight: bold;
color: #4945ff;
}
@ -791,6 +801,89 @@ exports[`Admin | ee | SettingsPage | SSO renders and matches the snapshot 1`] =
</div>
</div>
</div>
<div
class="c21"
>
<div
class=""
>
<div
class=""
>
<div
class="c23"
>
<label
class="c8 c24 c25"
for=":r6:"
>
Local authentication lock-out
</label>
<div
aria-autocomplete="none"
aria-controls="radix-:r9:"
aria-describedby=":r6:-hint :r6:-error"
aria-disabled="false"
aria-expanded="false"
aria-label="Local authentication lock-out"
class="c38 c39 c40"
data-placeholder=""
data-state="closed"
dir="ltr"
id=":r6:"
overflow="hidden"
role="combobox"
tabindex="0"
>
<span
class="c41 c42"
>
<span
class="c8 c47 c44"
>
<span
class="c45"
>
<span>
Choose here
</span>
</span>
</span>
</span>
<span
class="c42"
>
<span
aria-hidden="true"
class="c46"
>
<svg
fill="none"
height="1rem"
viewBox="0 0 14 8"
width="1rem"
xmlns="http://www.w3.org/2000/svg"
>
<path
clip-rule="evenodd"
d="M14 .889a.86.86 0 0 1-.26.625L7.615 7.736A.834.834 0 0 1 7 8a.834.834 0 0 1-.615-.264L.26 1.514A.861.861 0 0 1 0 .889c0-.24.087-.45.26-.625A.834.834 0 0 1 .875 0h12.25c.237 0 .442.088.615.264a.86.86 0 0 1 .26.625Z"
fill="#32324D"
fill-rule="evenodd"
/>
</svg>
</span>
</span>
</div>
<p
class="c8 c37"
id=":r6:-hint"
>
Select the roles for which you want to disable the local authentication
</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

View File

@ -6,6 +6,7 @@ const schema = yup.object().shape({
defaultRole: yup.mixed().when('autoRegister', (value, initSchema) => {
return value ? initSchema.required(translatedErrors.required) : initSchema.nullable();
}),
authenticationDisabled: yup.array().optional(),
});
export default schema;

View File

@ -10,6 +10,7 @@ const defaultAdminAuthSettings = {
providers: {
autoRegister: false,
defaultRole: null,
authenticationDisabled: null,
},
};