From 043461fe1be30a7dec5dc042497effda52e3e36a Mon Sep 17 00:00:00 2001 From: Pe5h4 Date: Thu, 6 Apr 2023 16:46:27 +0200 Subject: [PATCH 01/29] Add access resources --- src/modules/auth/index.js | 73 +++++++++++++++++++++++++-------------- 1 file changed, 48 insertions(+), 25 deletions(-) diff --git a/src/modules/auth/index.js b/src/modules/auth/index.js index 1cc223b9..56be0726 100644 --- a/src/modules/auth/index.js +++ b/src/modules/auth/index.js @@ -42,19 +42,22 @@ export default class SeaCatAuthModule extends Module { path: '/auth/resources', exact: true, name: 'Resources', - component: ResourcesListContainer + component: ResourcesListContainer, + resource: "seacat:resource:access" }); app.Router.addRoute({ path: '/auth/resources/!create', exact: true, name: 'New resource', - component: ResourcesCreateContainer + component: ResourcesCreateContainer, + resource: "seacat:resource:access" }); app.Router.addRoute({ path: '/auth/resources/:resource_id', exact: true, name: 'Resource detail', - component: ResourcesDetailContainer + component: ResourcesDetailContainer, + resource: "seacat:resource:access" }); // Roles @@ -62,19 +65,22 @@ export default class SeaCatAuthModule extends Module { path: '/auth/roles', exact: true, name: 'Roles', - component: RolesListContainer + component: RolesListContainer, + resource: "seacat:role:access" }); app.Router.addRoute({ path: '/auth/roles/!create', exact: true, name: 'New roles', - component: RolesCreateContainer + component: RolesCreateContainer, + resource: "seacat:role:access" }); app.Router.addRoute({ path: '/auth/roles/:tenant_id/:role_name', exact: true, name: 'Role detail', - component: RolesDetailContainer + component: RolesDetailContainer, + resource: "seacat:role:access" }); // Credentials @@ -82,27 +88,31 @@ export default class SeaCatAuthModule extends Module { path: '/auth/credentials', exact: true, name: 'Credentials', - component: CredentialsListContainer + component: CredentialsListContainer, + resource: "seacat:credentials:access" }); app.Router.addRoute({ path: '/auth/credentials/!create', name: 'New credentials', - component: CredentialsCreateContainer + component: CredentialsCreateContainer, + resource: "seacat:credentials:access" }); app.Router.addRoute({ path: '/auth/credentials/:credentials_id', exact: true, name: 'Credentials detail', - component: CredentialsDetailContainer + component: CredentialsDetailContainer, + resource: "seacat:credentials:access" }); app.Router.addRoute({ path: '/auth/credentials/:credentials_id/passwordreset', exact: true, name: 'Reset password', - component: ResetPasswordContainer + component: ResetPasswordContainer, + resource: "seacat:credentials:access" }); @@ -111,14 +121,16 @@ export default class SeaCatAuthModule extends Module { path: '/auth/session', exact: true, name: 'Sessions', - component: SessionListContainer + component: SessionListContainer, + resource: "seacat:session:access" }); app.Router.addRoute({ path: '/auth/session/:session_id', exact: true, name: 'Session detail', - component: SessionDetailContainer + component: SessionDetailContainer, + resource: "seacat:session:access" }); @@ -127,20 +139,23 @@ export default class SeaCatAuthModule extends Module { path: '/auth/tenant', exact: true, name: 'Tenants', - component: TenantListContainer + component: TenantListContainer, + resource: "seacat:tenant:access" }); app.Router.addRoute({ path: '/auth/tenant/!create', name: 'New tenant', - component: TenantCreateContainer + component: TenantCreateContainer, + resource: "seacat:tenant:access" }); app.Router.addRoute({ path: '/auth/tenant/:tenant_id', exact: true, name: 'Tenant detail', - component: TenantDetailContainer + component: TenantDetailContainer, + resource: "seacat:tenant:access" }); // Clients @@ -148,28 +163,32 @@ export default class SeaCatAuthModule extends Module { path: '/auth/clients', exact: true, name: 'Clients', - component: ClientListContainer + component: ClientListContainer, + resource: "seacat:client:access" }); app.Router.addRoute({ path: '/auth/clients/!create', exact: true, name: 'New client', - component: ClientCreateContainer + component: ClientCreateContainer, + resource: "seacat:client:access" }); app.Router.addRoute({ path: '/auth/clients/:client_id', exact: true, name: 'Client detail', - component: ClientDetailContainer + component: ClientDetailContainer, + resource: "seacat:client:access" }); app.Router.addRoute({ path: '/auth/clients/:client_id/edit', exact: true, name: 'Edit', - component: ClientCreateContainer + component: ClientCreateContainer, + resource: "seacat:client:access" }); // Navigation @@ -181,34 +200,38 @@ export default class SeaCatAuthModule extends Module { { name: 'Credentials', url: '/auth/credentials', - icon: 'cil-people' + icon: 'cil-people', + resource: "seacat:credentials:access" }, { name: 'Tenants', url: '/auth/tenant', - icon: 'cil-apps' + icon: 'cil-apps', + resource: "seacat:tenant:access" }, { name: 'Sessions', url: '/auth/session', icon: 'cil-link', - resource: 'authz:superuser' // Hide Sessions child in sidebar to users without authz:superuser rights + resource: "seacat:session:access" }, { name: 'Roles', url: '/auth/roles', - icon: 'cil-user' + icon: 'cil-user', + resource: "seacat:role:access" }, { name: 'Resources', url: '/auth/resources', - icon: 'cil-lock-unlocked' + icon: 'cil-lock-unlocked', + resource: "seacat:resource:access" }, { name: 'Clients', url: '/auth/clients', icon: 'cil-layers', - resource: 'authz:superuser' // Hide Clients child in sidebar to users without authz:superuser rights + resource: "seacat:client:access" }, ] }); From dcac86064f31c4a54fff8bddb5de08f54aaf561c Mon Sep 17 00:00:00 2001 From: Pe5h4 Date: Thu, 6 Apr 2023 16:46:40 +0200 Subject: [PATCH 02/29] Version bump --- asab-webui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/asab-webui b/asab-webui index 1960466a..fbeb0c09 160000 --- a/asab-webui +++ b/asab-webui @@ -1 +1 @@ -Subproject commit 1960466a45d0c48ec279e703317ebf0a59fdcbda +Subproject commit fbeb0c09b3d64deb9ca8292c2b507930d4019c7b From 616b8bb40f91fd6e2546ac078a89dccfbbb9526a Mon Sep 17 00:00:00 2001 From: Pe5h4 Date: Tue, 11 Apr 2023 13:10:38 +0200 Subject: [PATCH 03/29] remove home module --- public/locales/cs/translation.json | 13 +++----- public/locales/en/translation.json | 13 +++----- src/index.js | 32 ++------------------ src/modules/home/containers/HomeContainer.js | 29 ------------------ src/modules/home/containers/home.scss | 8 ----- src/modules/home/index.js | 18 ----------- 6 files changed, 12 insertions(+), 101 deletions(-) delete mode 100644 src/modules/home/containers/HomeContainer.js delete mode 100644 src/modules/home/containers/home.scss delete mode 100644 src/modules/home/index.js diff --git a/public/locales/cs/translation.json b/public/locales/cs/translation.json index f7bd0297..be31c2cf 100644 --- a/public/locales/cs/translation.json +++ b/public/locales/cs/translation.json @@ -78,7 +78,6 @@ "Clients": "Klienti", "New client": "Nový klient", "Client detail": "Detail klienta", - "Home": "Domů", "About": "O Aplikaci", "Access control": "Přístupová oprávnění" }, @@ -281,12 +280,6 @@ "Send instructions to set password": "Zaslat instrukce k nastavení hesla", "Required field": "Povinný údaj" }, - "HomeContainer": { - "Welcome!": "Vítejte!", - "This is TeskaLabs SeaCat Admin, cyber-security tool": "Toto je TeskaLabs SeaCat Admin, nástroj pro správu kybernetické bezpečnosti", - "SeaCat Admin is a comphrehensive security management tool": "SeaCat Admin je nástroj pro komplexní zabezpečení, organizaci a správu dat.", - "Please continue to desired agenda by navigating in the menu on the left": "Pokračujte prosím do požadované sekce pomocí nabídky na levé straně." - }, "ResetPasswordContainer": { "Reset password": "Obnovení hesla", "Username": "Uživatelské jméno", @@ -486,6 +479,7 @@ "Something went wrong, failed to create tenant": "Něco je špatně, nepodařilo se vytvořit tenanta", "Something went wrong, can't propose tenant name": "Něco je špatně, není možné navrhnout jméno tenanta" }, + "UserInterfaceCard": { "User interface": "Uživatelské rozhraní", "Build date": "Datum sestavení", @@ -498,8 +492,11 @@ "Select tenant": "Vyberte tenanta", "Back to login": "Zpět na přihlášení" }, + "UnauthorizedAccessScreen": { + "Unauthorized access": "Neoprávněný přístup", + "You are not authorized to access this part of the application. Please ask your application administrator for following resource": "Nejste oprávněni k přístupu do této části aplikace. Prosím, kontaktujte administrátora aplikace. K udělení přístupu je potřeba následující zdroj" + }, "Sidebar": { - "Home": "Domů", "About": "O Aplikaci", "Auth": "Autorizace", "Credentials": "Uživ. Identifikace", diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index e0cd07e7..ad738fae 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -78,7 +78,6 @@ "Clients": "Clients", "New client": "New client", "Client detail": "Client detail", - "Home": "Home", "About": "About", "Access control": "Access control" }, @@ -281,12 +280,6 @@ "Send instructions to set password": "Send instructions to set password", "Required field": "Required field" }, - "HomeContainer": { - "Welcome!": "Welcome!", - "This is TeskaLabs SeaCat Admin, cyber-security tool": "This is TeskaLabs SeaCat Admin, cyber-security tool", - "SeaCat Admin is a comphrehensive security management tool": "SeaCat Admin is a comphrehensive security management tool.", - "Please continue to desired agenda by navigating in the menu on the left": "Please continue to desired agenda by navigating in the menu on the left." - }, "ResetPasswordContainer": { "Username": "Username", "ID": "ID", @@ -487,6 +480,7 @@ "Something went wrong, failed to create tenant": "Something went wrong, failed to create tenant", "Something went wrong, can't propose tenant name": "Something went wrong, can't propose tenant name" }, + "UserInterfaceCard": { "User interface": "User interface", "Build date": "Build date", @@ -499,8 +493,11 @@ "Select tenant": "Select tenant", "Back to login": "Back to login" }, + "UnauthorizedAccessScreen": { + "Unauthorized access": "Unauthorized access", + "You are not authorized to access this part of the application. Please ask your application administrator for following resource": "You are not authorized to access this part of the application. Please ask your application administrator for following resource" + }, "Sidebar": { - "Home": "Home", "About": "About", "Auth": "Auth", "Credentials": "Credentials", diff --git a/src/index.js b/src/index.js index e8776d78..4189ef1e 100644 --- a/src/index.js +++ b/src/index.js @@ -69,36 +69,8 @@ modules.push(AboutModule); import SeaCatAuthModule from './modules/auth'; modules.push(SeaCatAuthModule); -// Specify dynamic modules in a config file -/* - // Example of use - app: { - modules: [ - "HomeModule" - ], - }, -*/ - -// Load custom modules -import HomeModule from './modules/home'; - -if (__CONFIG__.modules != null) { - Object.values(__CONFIG__.modules).map((module_name) => { - switch(module_name) { - case "HomeModule": modules.push(HomeModule); break; - } - }); -} - -// Option to specify custom default path of the module to be displayed when HomeModule is not loaded -/* - app: { - defaultpath: "/auth/credentials", - }, -*/ - // Items order in the sidebar -const sidebarItemsOrder = ["Home", "Auth"]; +const sidebarItemsOrder = ["Auth"]; ReactDOM.render(( @@ -106,7 +78,7 @@ ReactDOM.render(( sidebarItemsOrder={sidebarItemsOrder} configdefaults={ConfigDefaults} modules={modules} - defaultpath={__CONFIG__.defaultpath ? __CONFIG__.defaultpath : "/home"} + defaultpath={__CONFIG__.defaultpath ? __CONFIG__.defaultpath : "/auth/credentials"} hasSidebar={true} /> diff --git a/src/modules/home/containers/HomeContainer.js b/src/modules/home/containers/HomeContainer.js deleted file mode 100644 index 1ddebdba..00000000 --- a/src/modules/home/containers/HomeContainer.js +++ /dev/null @@ -1,29 +0,0 @@ -import React from 'react' -import { useTranslation } from 'react-i18next'; - -import { - Container, Row, Col, Jumbotron -} from 'reactstrap'; - -function HomeContainer(props) { - - const { t, i18n } = useTranslation(); - - return ( - - - - -

{t('HomeContainer|Welcome!')}

-

{t('HomeContainer|This is TeskaLabs SeaCat Admin, cyber-security tool')}

-
-

{t('HomeContainer|SeaCat Admin is a comphrehensive security management tool')}

-

{t('HomeContainer|Please continue to desired agenda by navigating in the menu on the left')}

-
- -
-
- ) -} - -export default HomeContainer; diff --git a/src/modules/home/containers/home.scss b/src/modules/home/containers/home.scss deleted file mode 100644 index 9c59d35e..00000000 --- a/src/modules/home/containers/home.scss +++ /dev/null @@ -1,8 +0,0 @@ -@import "~asab-webui/styles/constants/index.scss"; - -.sc-home-container { - .jumbotron { - box-shadow: 0 1px 1px 0 rgba(60,75,100,.14),0 2px 1px -1px rgba(60,75,100,.12),0 1px 3px 0 rgba(60,75,100,.2); - background-color: $bg-color; - } -} \ No newline at end of file diff --git a/src/modules/home/index.js b/src/modules/home/index.js deleted file mode 100644 index b5605ed7..00000000 --- a/src/modules/home/index.js +++ /dev/null @@ -1,18 +0,0 @@ -import HomeContainer from './containers/HomeContainer' -import Module from 'asab-webui/abc/Module'; -import "./containers/home.scss"; - -export default class HomeModule extends Module { - constructor(app, name){ - super(app, "HomeModule"); - - app.Router.addRoute({ path: '/home', exact: true, name: 'Home', component: HomeContainer }); - - app.Navigation.addItem({ - name: 'Home', - icon: 'cil-home', - url: '/home' - }); - - } -} From 0874ee5b5e96821b44d545dc5ff7d1f63f7f1142 Mon Sep 17 00:00:00 2001 From: Pe5h4 Date: Tue, 11 Apr 2023 13:10:52 +0200 Subject: [PATCH 04/29] version bump --- asab-webui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/asab-webui b/asab-webui index fbeb0c09..ce85b29a 160000 --- a/asab-webui +++ b/asab-webui @@ -1 +1 @@ -Subproject commit fbeb0c09b3d64deb9ca8292c2b507930d4019c7b +Subproject commit ce85b29a6feae89fbdb06770ff9a462ef44d8903 From ceaa66bae52cab6d959ad7d0cd13529e08aba979 Mon Sep 17 00:00:00 2001 From: Pe5h4 Date: Tue, 11 Apr 2023 13:34:32 +0200 Subject: [PATCH 05/29] Update resources for credentials section --- .../auth/credentials/CredentialsCreateContainer.js | 2 +- .../auth/credentials/CredentialsDetailContainer.js | 11 ++++++----- .../auth/credentials/CredentialsListContainer.js | 2 +- .../auth/credentials/CredentialsSessionCard.js | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/modules/auth/credentials/CredentialsCreateContainer.js b/src/modules/auth/credentials/CredentialsCreateContainer.js index e7c3e93e..68e87074 100644 --- a/src/modules/auth/credentials/CredentialsCreateContainer.js +++ b/src/modules/auth/credentials/CredentialsCreateContainer.js @@ -40,7 +40,7 @@ function CredentialsCreateContainer(props) { const [activeTab, setActiveTab] = useState('create'); - const resourceCreateCredentials = "authz:tenant:admin"; + const resourceCreateCredentials = "seacat:credentials:edit"; const resources = useSelector(state => state.auth?.resources); const tenant = useSelector(state => state.tenant?.current); diff --git a/src/modules/auth/credentials/CredentialsDetailContainer.js b/src/modules/auth/credentials/CredentialsDetailContainer.js index 5b669ccd..fe6d9e1d 100644 --- a/src/modules/auth/credentials/CredentialsDetailContainer.js +++ b/src/modules/auth/credentials/CredentialsDetailContainer.js @@ -40,9 +40,10 @@ function CredentialsDetailContainer(props) { const advmode = useSelector(state => state.advmode?.enabled); const theme = useSelector(state => state.theme); - const resourceAssignTenantRole = "authz:tenant:admin"; - const resourceManageCredentials = "authz:superuser"; - const displaySessions = resources ? resources.indexOf("authz:superuser") != -1 : false; + const resourceAssignTenant = "seacat:tenant:assign"; + const resourceAssignRole = "seacat:role:assign"; + const resourceManageCredentials = "seacat:credentials:edit"; + const displaySessions = resources ? ((resources.indexOf("seacat:session:access") != -1) || (resources.indexOf("authz:superuser") != -1)) : false; const credentials_id = props.match.params.credentials_id; useEffect(() => { @@ -356,7 +357,7 @@ function CredentialsDetailContainer(props) {
- + {displaySessions && } - +
diff --git a/src/modules/auth/credentials/CredentialsListContainer.js b/src/modules/auth/credentials/CredentialsListContainer.js index 1b2a9c67..bedc292a 100644 --- a/src/modules/auth/credentials/CredentialsListContainer.js +++ b/src/modules/auth/credentials/CredentialsListContainer.js @@ -25,7 +25,7 @@ function CredentialsListContainer(props) { const [height, setHeight] = useState(0); const ref = useRef(null); - const resourceCreateCredentials = "authz:tenant:admin"; + const resourceCreateCredentials = "seacat:credentials:edit"; const resources = useSelector(state => state.auth?.resources); const tenant = useSelector(state => state.tenant?.current); diff --git a/src/modules/auth/credentials/CredentialsSessionCard.js b/src/modules/auth/credentials/CredentialsSessionCard.js index 94a90db9..5700905b 100644 --- a/src/modules/auth/credentials/CredentialsSessionCard.js +++ b/src/modules/auth/credentials/CredentialsSessionCard.js @@ -66,7 +66,7 @@ function CredentialsSessionCard(props) { color="danger" outline onClick={() => {terminateSessionsForm()}} - resource="authz:superuser" + resource="seacat:session:terminate" resources={props.resources} disabled={data.length == 0} > From 0555e088e76f1cd3906a8d9135442cf5302aab22 Mon Sep 17 00:00:00 2001 From: Pe5h4 Date: Tue, 11 Apr 2023 13:36:53 +0200 Subject: [PATCH 06/29] Update resources for clients --- src/modules/auth/clients/ClientCreateContainer.js | 2 +- src/modules/auth/clients/ClientDetailContainer.js | 2 +- src/modules/auth/clients/ClientListContainer.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/modules/auth/clients/ClientCreateContainer.js b/src/modules/auth/clients/ClientCreateContainer.js index ef04df50..0a6c16bd 100644 --- a/src/modules/auth/clients/ClientCreateContainer.js +++ b/src/modules/auth/clients/ClientCreateContainer.js @@ -22,7 +22,7 @@ const ClientCreateContainer = (props) => { const location = useLocation(); // tracking method in URL const SeaCatAuthAPI = props.app.axiosCreate('seacat_auth'); - const resource = "authz:superuser"; + const resource = "seacat:client:edit"; const resources = useSelector(state => state.auth?.resources); const theme = useSelector(state => state.theme); const advmode = useSelector(state => state.advmode.enabled); diff --git a/src/modules/auth/clients/ClientDetailContainer.js b/src/modules/auth/clients/ClientDetailContainer.js index f86f5dd0..e82834e6 100644 --- a/src/modules/auth/clients/ClientDetailContainer.js +++ b/src/modules/auth/clients/ClientDetailContainer.js @@ -18,7 +18,7 @@ const ClientDetailContainer = (props) => { const [client, setClient] = useState(null); const { client_id } = props.match.params; - const resource = "authz:superuser"; + const resource = "seacat:client:edit"; const resources = useSelector(state => state.auth?.resources); const theme = useSelector(state => state.theme); const advmode = useSelector(state => state.advmode.enabled); diff --git a/src/modules/auth/clients/ClientListContainer.js b/src/modules/auth/clients/ClientListContainer.js index 2304a557..d42b8630 100644 --- a/src/modules/auth/clients/ClientListContainer.js +++ b/src/modules/auth/clients/ClientListContainer.js @@ -22,7 +22,7 @@ function ClientListContainer(props) { const [height, setHeight] = useState(0); const ref = useRef(null); - const resource = "authz:superuser"; + const resource = "seacat:client:edit"; const resources = useSelector(state => state.auth?.resources); const headers = [ From 6b074f2ef25a2a8c669f965d0506763617a642ed Mon Sep 17 00:00:00 2001 From: Pe5h4 Date: Tue, 11 Apr 2023 13:44:01 +0200 Subject: [PATCH 07/29] Add resources for resources part --- src/modules/auth/resources/ResourcesCreateContainer.js | 3 ++- src/modules/auth/resources/ResourcesDetailContainer.js | 3 ++- src/modules/auth/resources/ResourcesListContainer.js | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/modules/auth/resources/ResourcesCreateContainer.js b/src/modules/auth/resources/ResourcesCreateContainer.js index 3521790f..e2dfd4b0 100644 --- a/src/modules/auth/resources/ResourcesCreateContainer.js +++ b/src/modules/auth/resources/ResourcesCreateContainer.js @@ -15,6 +15,7 @@ import { const ResourceCreateContainer = (props) => { const { handleSubmit, register, formState: { errors, isSubmitting }, getValues } = useForm(); const credentialsResources = useSelector(state => state.auth?.resources); + const resourceEdit = "seacat:resource:edit"; const SeaCatAuthAPI = props.app.axiosCreate('seacat_auth'); const { t } = useTranslation(); const reg = register( @@ -106,7 +107,7 @@ const ResourceCreateContainer = (props) => { color="primary" type="submit" disabled={isSubmitting} - resource="authz:superuser" + resource={resourceEdit} resources={credentialsResources} > {t("ResourcesCreateContainer|Create resource")} diff --git a/src/modules/auth/resources/ResourcesDetailContainer.js b/src/modules/auth/resources/ResourcesDetailContainer.js index ab625e2b..2bc940c0 100644 --- a/src/modules/auth/resources/ResourcesDetailContainer.js +++ b/src/modules/auth/resources/ResourcesDetailContainer.js @@ -21,6 +21,7 @@ const ResourceDetailContainer = (props) => { const { resource_id } = props.match.params; const resources = useSelector(state => state.auth?.resources); + const resourceEdit = "seacat:resource:edit"; const advmode = useSelector(state => state.advmode?.enabled); const theme = useSelector(state => state.theme); @@ -124,7 +125,7 @@ const ResourceDetailContainer = (props) => { type="button" onClick={(e) => (e.preventDefault(), setEditMode(true))} resources={resources} - resource="authz:superuser" + resource={resourceEdit} > {t("Edit")} diff --git a/src/modules/auth/resources/ResourcesListContainer.js b/src/modules/auth/resources/ResourcesListContainer.js index ceee280f..d4931bca 100644 --- a/src/modules/auth/resources/ResourcesListContainer.js +++ b/src/modules/auth/resources/ResourcesListContainer.js @@ -19,6 +19,7 @@ function ResourcesListContainer(props) { const ref = useRef(null); const { t } = useTranslation(); + const resourceEdit = "seacat:resource:edit"; const credentialsResources = useSelector(state => state.auth?.resources); const headers = [ @@ -74,7 +75,7 @@ function ResourcesListContainer(props) { title={t("ResourcesListContainer|Create resource")} color="primary" onClick={() => {redirectToCreate()}} - resource="authz:superuser" + resource={resourceEdit} resources={credentialsResources} > {t("ResourcesListContainer|Create resource")} From 3294f1af85faf6adce38a7cd854da071008cb08b Mon Sep 17 00:00:00 2001 From: Pe5h4 Date: Tue, 11 Apr 2023 14:08:51 +0200 Subject: [PATCH 08/29] Update resources in roles part --- src/modules/auth/roles/RolesCreateContainer.js | 11 ++++++++--- src/modules/auth/roles/RolesDetailContainer.js | 13 ++++++++++--- src/modules/auth/roles/RolesListContainer.js | 2 +- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/modules/auth/roles/RolesCreateContainer.js b/src/modules/auth/roles/RolesCreateContainer.js index c63f8dfe..c4bf2cbb 100644 --- a/src/modules/auth/roles/RolesCreateContainer.js +++ b/src/modules/auth/roles/RolesCreateContainer.js @@ -6,14 +6,17 @@ import { useTranslation } from 'react-i18next'; import { Container, Row, Col, Card, CardHeader, CardFooter, CardBody, - Button, Form, FormGroup, FormText, + Form, FormGroup, FormText, Input, Label, FormFeedback } from 'reactstrap'; +import { ButtonWithAuthz } from 'asab-webui'; + const RolesCreateContainer = (props) => { const { handleSubmit, register, formState: { errors, isSubmitting }, getValues } = useForm(); const SeaCatAuthAPI = props.app.axiosCreate('seacat_auth'); + const resource = "seacat:role:edit"; const resources = useSelector(state => state.auth?.resources); const currentTenant = useSelector(state => state.tenant?.current); @@ -101,11 +104,13 @@ const RolesCreateContainer = (props) => { - + resources={resources} + resource={resource} + >{t("RolesCreateContainer|Create role")} diff --git a/src/modules/auth/roles/RolesDetailContainer.js b/src/modules/auth/roles/RolesDetailContainer.js index 353061bb..2faf19f0 100644 --- a/src/modules/auth/roles/RolesDetailContainer.js +++ b/src/modules/auth/roles/RolesDetailContainer.js @@ -23,7 +23,8 @@ const RolesDetailContainer = (props) => { const [credentialsList, setCredentialsList] = useState([]); const [assignedCredentialsDropdown, setAssignedCredentialsDropdown] = useState([]); - const resource = tenant_id === "*" ? "authz:superuser" : "authz:tenant:admin"; + const resourceAssign = "seacat:role:assign", + const resource = tenant_id === "*" ? "authz:superuser" : "seacat:role:edit"; const resources = useSelector(state => state.auth?.resources); const advmode = useSelector(state => state.advmode?.enabled); const theme = useSelector(state => state.theme); @@ -78,7 +79,7 @@ const RolesDetailContainer = (props) => { size="sm" color="danger" onClick={() => {unassignCredentialsForm(credentials._id)}} - resource="authz:tenant:admin" + resource={resourceAssign} resources={resources} > @@ -230,7 +231,13 @@ const RolesDetailContainer = (props) => { const assignNewCredentials = ( retrieveCredentialsForDropdown()}> - + {t("RolesDetailContainer|Assign credentials")} diff --git a/src/modules/auth/roles/RolesListContainer.js b/src/modules/auth/roles/RolesListContainer.js index da269904..e101e46a 100644 --- a/src/modules/auth/roles/RolesListContainer.js +++ b/src/modules/auth/roles/RolesListContainer.js @@ -18,7 +18,7 @@ const RolesListcontainer = (props) => { const [height, setHeight] = useState(0); const ref = useRef(null); - const resource = "authz:tenant:admin"; + const resource = "seacat:role:edit"; const resources = useSelector(state => state.auth?.resources); const tenant = useSelector(state => state.tenant?.current); From b1d15552177c976367e002dee5165b448b8849b3 Mon Sep 17 00:00:00 2001 From: Pe5h4 Date: Tue, 11 Apr 2023 14:13:59 +0200 Subject: [PATCH 09/29] Update resources for sessions part --- src/modules/auth/session/SessionDetailContainer.js | 5 +++-- src/modules/auth/session/SessionListContainer.js | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/modules/auth/session/SessionDetailContainer.js b/src/modules/auth/session/SessionDetailContainer.js index 8353e063..8bda1d1a 100644 --- a/src/modules/auth/session/SessionDetailContainer.js +++ b/src/modules/auth/session/SessionDetailContainer.js @@ -16,6 +16,7 @@ function SessionDetailContainer(props) { const { t } = useTranslation(); const history = useHistory(); const [data, setData] = useState({}); + const resource = "seacat:session:terminate"; const resources = useSelector(state => state.auth?.resources); const advmode = useSelector(state => state.advmode?.enabled); const theme = useSelector(state => state.theme); @@ -60,7 +61,7 @@ function SessionDetailContainer(props) { color="danger" outline onClick={() => {terminateSessionForm(session._id)}} - resource="authz:superuser" + resource={resource} resources={resources} > @@ -172,7 +173,7 @@ function SessionDetailContainer(props) { color="danger" outline onClick={() => {terminateSessionForm(session_id)}} - resource="authz:superuser" + resource={resource} resources={resources} > {t("SessionDetailContainer|Terminate session")} diff --git a/src/modules/auth/session/SessionListContainer.js b/src/modules/auth/session/SessionListContainer.js index 41057e60..a6a9975c 100644 --- a/src/modules/auth/session/SessionListContainer.js +++ b/src/modules/auth/session/SessionListContainer.js @@ -18,6 +18,7 @@ const SessionListContainer = (props) => { const [show, setShow] = useState(false); const [limit, setLimit] = useState(15); + const resource = "seacat:session:terminate"; const resources = useSelector(state => state.auth?.resources); const headers = [ @@ -65,7 +66,7 @@ const SessionListContainer = (props) => { color="danger" outline onClick={() => {terminateSessionForm(session._id)}} - resource="authz:superuser" + resource={resource} resources={resources} > @@ -158,7 +159,7 @@ const SessionListContainer = (props) => { title: t("SessionListContainer|Terminate all sessions"), color:"danger", onClick() {terminateAllSessionsForm()}, - resource: "authz:superuser", + resource: resource, resources: resources, children: t("SessionListContainer|Terminate all") } From e8ee0511f0c3c10c7388be2cbc1a5c9f03593034 Mon Sep 17 00:00:00 2001 From: Pe5h4 Date: Tue, 11 Apr 2023 14:28:01 +0200 Subject: [PATCH 10/29] Update resources for tenant part --- src/modules/auth/tenant/TenantCreateContainer.js | 11 +++++++++-- src/modules/auth/tenant/TenantDetailContainer.js | 8 ++++++-- src/modules/auth/tenant/TenantListContainer.js | 3 ++- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/modules/auth/tenant/TenantCreateContainer.js b/src/modules/auth/tenant/TenantCreateContainer.js index 139f5e59..38e10b83 100644 --- a/src/modules/auth/tenant/TenantCreateContainer.js +++ b/src/modules/auth/tenant/TenantCreateContainer.js @@ -1,6 +1,7 @@ import React from 'react'; import { useForm } from "react-hook-form"; import { useTranslation } from 'react-i18next'; +import { useSelector } from 'react-redux'; import { Container, Row, Col, @@ -10,11 +11,15 @@ import { ButtonGroup, FormFeedback, FormText } from 'reactstrap'; +import { ButtonWithAuthz } from 'asab-webui'; + function TenantCreateContainer(props) { const { handleSubmit, register, formState: { errors, isSubmitting }, setValue, getValues } = useForm(); const SeaCatAuthAPI = props.app.axiosCreate('seacat_auth'); const { t } = useTranslation(); + const resources = useSelector(state => state.auth?.resources); + const resource = "seacat:tenant:edit"; const reg = register( "id", @@ -93,11 +98,13 @@ function TenantCreateContainer(props) { - + resources={resources} + resource={resource} + >{t("TenantCreateContainer|Create a tenant")}