Skip to content

Commit

Permalink
Merge pull request #28 from TeskaLabs/feature/add-resources
Browse files Browse the repository at this point in the history
Feature/add resources
  • Loading branch information
Pe5h4 authored Apr 19, 2023
2 parents d8e218c + 3cc85df commit 71c82da
Show file tree
Hide file tree
Showing 23 changed files with 186 additions and 91 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,20 @@

## Release Candidate

## v23.16-beta

### Compatibility

Tested with Seacat Auth service [v23.16-beta](https://github.com/TeskaLabs/seacat-auth/releases/tag/v23.16-beta)

### Features

- ASAB WebUI submodule version bump [[c7d682a](https://github.com/TeskaLabs/asab-webui/commit/c7d682ad8f08e432ddbed2c0d21f16a73b23bd58)] commit (INDIGO Sprint 230414, [!29](https://github.com/TeskaLabs/seacat-admin-webui/pull/29))

- Update access and edit resources in SeaCat Admin application (INDIGO Sprint 230414, [!28](https://github.com/TeskaLabs/seacat-admin-webui/pull/28))

- Remove Homepage (INDIGO Sprint 230414, [!28](https://github.com/TeskaLabs/seacat-admin-webui/pull/28))

### Bugfix

- Version bump of ASAB WebUI with fix on userinfo loop when session expiration time is set to small values (INDIGO Sprint 230414, [!29](https://github.com/TeskaLabs/seacat-admin-webui/pull/29))
Expand Down
20 changes: 12 additions & 8 deletions public/locales/cs/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -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í"
},
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -466,6 +459,7 @@
"Do you want to remove the tenant?": "Opravdu chcete odstranit tenanta?",
"Do you want to unassign these credentials?": "Opravdu chcete odebrat uživatele?",
"Failed to remove the tenant": "Nepodařilo se odstranit tenanta",
"Tenant removed successfully, you will be logged out in a while": "Tenant úspěšně odstraněn, za moment budete odhlášeni",
"Tenant removed successfully": "Tenant úspěšně odstraněn",
"Tenant data updated successfully": "Tenant úspěšně aktualizován"
},
Expand All @@ -486,6 +480,13 @@
"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"
},
"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ě."
},

"UserInterfaceCard": {
"User interface": "Uživatelské rozhraní",
"Build date": "Datum sestavení",
Expand All @@ -498,8 +499,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",
Expand Down
20 changes: 12 additions & 8 deletions public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@
"Clients": "Clients",
"New client": "New client",
"Client detail": "Client detail",
"Home": "Home",
"About": "About",
"Access control": "Access control"
},
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -466,6 +459,7 @@
"Do you want to remove the tenant?": "Do you want to remove the tenant?",
"Do you want to unassign these credentials?": "Do you want to unassign these credentials?",
"Failed to remove the tenant": "Failed to remove the tenant",
"Tenant removed successfully, you will be logged out in a while": "Tenant removed successfully, you will be logged out in a while",
"Tenant removed successfully": "Tenant removed successfully",
"Tenant data updated successfully": "Tenant data updated successfully"
},
Expand All @@ -487,6 +481,13 @@
"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"
},
"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."
},

"UserInterfaceCard": {
"User interface": "User interface",
"Build date": "Build date",
Expand All @@ -499,8 +500,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",
Expand Down
2 changes: 1 addition & 1 deletion src/modules/auth/clients/ClientCreateContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
24 changes: 11 additions & 13 deletions src/modules/auth/clients/ClientDetailContainer.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { useState, useEffect } from 'react';
import { useSelector } from 'react-redux';
import { useTranslation } from 'react-i18next';
import { Link } from "react-router-dom";

import {
Container, Row, Col,
Expand All @@ -18,7 +17,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);
Expand Down Expand Up @@ -129,17 +128,16 @@ const ClientDetailContainer = (props) => {
</CardBody>
<CardFooter>
<ButtonGroup>
<Link to={{pathname: `/auth/clients/${client_id}/edit`}}>
<ButtonWithAuthz
title={t("Edit")}
color="primary"
type="button"
resource={resource}
resources={resources}
>
{t("Edit")}
</ButtonWithAuthz>
</Link>
<ButtonWithAuthz
title={t("Edit")}
color="primary"
type="button"
resource={resource}
resources={resources}
onClick={() => props.history.push(`/auth/clients/${client_id}/edit`)}
>
{t("Edit")}
</ButtonWithAuthz>
<ButtonWithAuthz
outline
title={t("ClientDetailContainer|Remove client")}
Expand Down
2 changes: 1 addition & 1 deletion src/modules/auth/clients/ClientListContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
2 changes: 1 addition & 1 deletion src/modules/auth/credentials/CredentialsCreateContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
26 changes: 17 additions & 9 deletions src/modules/auth/credentials/CredentialsDetailContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down Expand Up @@ -102,6 +103,10 @@ function CredentialsDetailContainer(props) {
}


/*
TODO: Option to remove user from DB has been commented for eventual future usage
// Set delete user dialog
const deleteUserForm = () => {
var r = confirm(t('CredentialsDetailContainer|Do you want to remove this user?'));
Expand All @@ -122,7 +127,7 @@ function CredentialsDetailContainer(props) {
props.app.addAlert("warning", `${t("CredentialsDetailContainer|Something went wrong, failed to remove user")}. ${e?.response?.data?.message}`, 30);
}
};

*/

// Set suspend/activate user dialog
const suspendUserForm = (isActive) => {
Expand Down Expand Up @@ -266,18 +271,20 @@ function CredentialsDetailContainer(props) {

<CardFooter>
<ButtonGroup>
{/*
TODO: Option to remove user from DB has been commented for eventual future usage
<ButtonWithAuthz
resource={resources}
resource={resourceManageCredentials}
resources={resources}
color="danger"
outline
onClick={() => { deleteUserForm() }}
>
{t('CredentialsDetailContainer|Remove user')}
</ButtonWithAuthz>
</ButtonWithAuthz>*/}
<ButtonWithAuthz
color="outline-primary"
resource={resources}
resource={resourceManageCredentials}
resources={resources}
onClick={() => { resetPwd() }}
>
Expand Down Expand Up @@ -346,6 +353,7 @@ function CredentialsDetailContainer(props) {
resource={resourceManageCredentials}
/>
<CustomDataContainer
resource={resourceManageCredentials}
resources={resources}
customData={customCredentialData}
setCustomData={setCustomCredentialData}
Expand All @@ -356,7 +364,7 @@ function CredentialsDetailContainer(props) {
</div>
</div>
<div className="credential-detail-resource-area credential-resources-wrapper">
<CredentialsTenantsCard app={props.app} credentials_id={credentials_id} resource={resourceAssignTenantRole} resources={resources} setRolesRefresh={setRolesRefresh}/>
<CredentialsTenantsCard app={props.app} credentials_id={credentials_id} resource={resourceAssignTenant} resources={resources} setRolesRefresh={setRolesRefresh}/>

{displaySessions && <CredentialsSessionCard
app={props.app}
Expand All @@ -365,7 +373,7 @@ function CredentialsDetailContainer(props) {
resources={resources}
retrieveSessions={retrieveSessions}/>
}
<CredentialsRolesCard app={props.app} credentials_id={credentials_id} resource={resourceAssignTenantRole} resources={resources} rolesRefresh={rolesRefresh}/>
<CredentialsRolesCard app={props.app} credentials_id={credentials_id} resource={resourceAssignRole} resources={resources} rolesRefresh={rolesRefresh}/>
</div>

<div className="credential-detail-json-area">
Expand Down
2 changes: 1 addition & 1 deletion src/modules/auth/credentials/CredentialsListContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion src/modules/auth/credentials/CredentialsSessionCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}
>
Expand Down
2 changes: 1 addition & 1 deletion src/modules/auth/credentials/CredentialsTenantsCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ function CredentialsTenantsCard(props) {
props.setRolesRefresh(prev => !prev);
} catch(e) {
console.error(e);
props.app.addAlert("warning", `${t("CredentialsRolesCard|Failed to update tenants")}. ${e?.response?.data?.message}`, 30);
props.app.addAlert("warning", `${t("CredentialsTenantsCard|Failed to update tenants")}. ${e?.response?.data?.message}`, 30);
}
}

Expand Down
Loading

0 comments on commit 71c82da

Please sign in to comment.