diff --git a/frontend/package.json b/frontend/package.json index 3c7866ea80..6253209c8d 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -25,6 +25,7 @@ "license": "Apache-2.0", "scripts": { "build": "INLINE_RUNTIME_CHUNK=false react-scripts build", + "lint": "eslint src", "start": "react-scripts start", "start:heroku": "UNLEASH_API=https://unleash.herokuapp.com yarn run start", "test": "react-scripts test", diff --git a/frontend/src/component/application/__tests__/application-edit-component-test.js b/frontend/src/component/application/__tests__/application-edit-component-test.js index 3a86caf41d..9c58edbd57 100644 --- a/frontend/src/component/application/__tests__/application-edit-component-test.js +++ b/frontend/src/component/application/__tests__/application-edit-component-test.js @@ -4,12 +4,7 @@ import { ThemeProvider } from '@material-ui/core'; import ClientApplications from '../application-edit-component'; import renderer from 'react-test-renderer'; import { MemoryRouter } from 'react-router-dom'; -import { - ADMIN, - CREATE_FEATURE, - CREATE_STRATEGY, - UPDATE_APPLICATION, -} from '../../AccessProvider/permissions'; +import { ADMIN } from '../../AccessProvider/permissions'; import theme from '../../../themes/main-theme'; import { createFakeStore } from '../../../accessStoreFake'; diff --git a/frontend/src/component/menu/routes.js b/frontend/src/component/menu/routes.js index cae0865ebd..f642d116b2 100644 --- a/frontend/src/component/menu/routes.js +++ b/frontend/src/component/menu/routes.js @@ -353,7 +353,7 @@ export const routes = [ { path: '/admin/auth', parent: '/admin', - title: 'Authentication', + title: 'Single Sign-On', component: AdminAuth, type: 'protected', layout: 'main', diff --git a/frontend/src/interfaces/route.ts b/frontend/src/interfaces/route.ts index e4aee7861c..6d642e58ad 100644 --- a/frontend/src/interfaces/route.ts +++ b/frontend/src/interfaces/route.ts @@ -1,5 +1,4 @@ import React from 'react'; -import { RouteComponentProps } from 'react-router'; interface IRoute { path: string; diff --git a/frontend/src/page/admin/admin-menu.jsx b/frontend/src/page/admin/admin-menu.jsx index 5bde29fc1b..a513bd9b60 100644 --- a/frontend/src/page/admin/admin-menu.jsx +++ b/frontend/src/page/admin/admin-menu.jsx @@ -56,7 +56,7 @@ function AdminMenu({ history }) { activeStyle={activeNavLinkStyle} style={navLinkStyle} > - Authentication + Single Sign-On } > diff --git a/frontend/src/page/admin/auth/AutoCreateForm/AutoCreateForm.tsx b/frontend/src/page/admin/auth/AutoCreateForm/AutoCreateForm.tsx new file mode 100644 index 0000000000..602f6ffb26 --- /dev/null +++ b/frontend/src/page/admin/auth/AutoCreateForm/AutoCreateForm.tsx @@ -0,0 +1,102 @@ +import React, { ChangeEvent, Fragment } from 'react'; +import { FormControl, Grid, MenuItem, Switch, TextField, Select, InputLabel, FormControlLabel } from '@material-ui/core'; + +interface Props { + data?: { + enabled: boolean; + autoCreate: boolean; + defaultRootRole?: string; + emailDomains?: string; + + }; + setValue: (name: string, value: string | boolean) => void; +} + +function AutoCreateForm({ data = { enabled: false, autoCreate: false }, setValue }: Props) { + const updateAutoCreate = () => { + setValue('autoCreate', !data.autoCreate); + } + + const updateDefaultRootRole = (evt: ChangeEvent<{ name?: string; value: unknown }>) => { + setValue('defaultRootRole', evt.target.value as string); + } + + const updateField = (e: ChangeEvent) => { + setValue(e.target.name, e.target.value); + } + +return ( + + + + Auto-create users +

+ Enable automatic creation of new users when signing in. +

+
+ + + } + label="Auto-create users" + /> + +
+ + + Default Root Role +

+ Choose which root role the user should get when no explicit role mapping exists. +

+
+ + + Default Role + + + +
+ + + Email domains +

+ Comma separated list of email domains + that should be allowed to sign in. +

+
+ + + +
+
); +} +export default AutoCreateForm; diff --git a/frontend/src/page/admin/auth/authentication.jsx b/frontend/src/page/admin/auth/authentication.jsx index 186d63de33..a1a187482d 100644 --- a/frontend/src/page/admin/auth/authentication.jsx +++ b/frontend/src/page/admin/auth/authentication.jsx @@ -28,7 +28,7 @@ function AdminAuthPage({ authenticationType, history }) { return (
- + diff --git a/frontend/src/page/admin/auth/google-auth.jsx b/frontend/src/page/admin/auth/google-auth.jsx index d2e694f31a..73a824ea75 100644 --- a/frontend/src/page/admin/auth/google-auth.jsx +++ b/frontend/src/page/admin/auth/google-auth.jsx @@ -1,6 +1,6 @@ import React, { useState, useEffect, useContext } from 'react'; import PropTypes from 'prop-types'; -import { Button, Grid, Switch, TextField } from '@material-ui/core'; +import { Button, FormControlLabel, Grid, Switch, TextField } from '@material-ui/core'; import { Alert } from '@material-ui/lab'; import PageContent from '../../../component/common/PageContent/PageContent'; import AccessContext from '../../../contexts/AccessContext'; @@ -92,13 +92,15 @@ function GoogleAuth({

- - {data.enabled ? 'Enabled' : 'Disabled'} - + } + label={data.enabled ? 'Enabled' : 'Disabled'} + /> diff --git a/frontend/src/page/admin/auth/oidc-auth.jsx b/frontend/src/page/admin/auth/oidc-auth.jsx index 226f7c0406..7fc62d1504 100644 --- a/frontend/src/page/admin/auth/oidc-auth.jsx +++ b/frontend/src/page/admin/auth/oidc-auth.jsx @@ -1,10 +1,11 @@ import React, { useState, useEffect, useContext } from 'react'; import PropTypes from 'prop-types'; -import { Button, Grid, Switch, TextField } from '@material-ui/core'; +import { Button, FormControlLabel, Grid, Switch, TextField } from '@material-ui/core'; import { Alert } from '@material-ui/lab'; import PageContent from '../../../component/common/PageContent/PageContent'; import AccessContext from '../../../contexts/AccessContext'; import { ADMIN } from '../../../component/AccessProvider/permissions'; +import AutoCreateForm from './AutoCreateForm/AutoCreateForm'; const initialState = { enabled: false, @@ -39,19 +40,19 @@ function OidcAuth({ config, getOidcConfig, updateOidcConfig, unleashUrl }) { } const updateField = e => { - setData({ - ...data, - [e.target.name]: e.target.value, - }); + setValue(e.target.name, e.target.value); }; const updateEnabled = () => { setData({ ...data, enabled: !data.enabled }); }; - const updateAutoCreate = () => { - setData({ ...data, autoCreate: !data.autoCreate }); - }; + const setValue = (field, value) => { + setData({ + ...data, + [field]: value, + }); + } const onSubmit = async e => { e.preventDefault(); @@ -93,14 +94,15 @@ function OidcAuth({ config, getOidcConfig, updateOidcConfig, unleashUrl }) {

Enable Open Id Connect Authentication.

- - {data.enabled ? 'Enabled' : 'Disabled'} - + } + label={data.enabled ? 'Enabled' : 'Disabled'} + /> @@ -114,6 +116,7 @@ function OidcAuth({ config, getOidcConfig, updateOidcConfig, unleashUrl }) { label="Discover URL" name="discoverUrl" value={data.discoverUrl || ''} + disabled={!data.enabled} style={{ width: '400px' }} variant="outlined" size="small" @@ -132,6 +135,7 @@ function OidcAuth({ config, getOidcConfig, updateOidcConfig, unleashUrl }) { label="Client ID" name="clientId" value={data.clientId || ''} + disabled={!data.enabled} style={{ width: '400px' }} variant="outlined" size="small" @@ -150,6 +154,7 @@ function OidcAuth({ config, getOidcConfig, updateOidcConfig, unleashUrl }) { label="Client Secret" name="secret" value={data.secret || ''} + disabled={!data.enabled} style={{ width: '400px' }} variant="outlined" size="small" @@ -157,46 +162,9 @@ function OidcAuth({ config, getOidcConfig, updateOidcConfig, unleashUrl }) { /> - - - Auto-create users -

- Enable automatic creation of new users when signing - in with Open ID connect. -

-
- - - Auto-create users - - -
- - - Email domains -

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

-
- - - -
+ + +