From cf967703afe5481785a8dd93e82a96718131fb99 Mon Sep 17 00:00:00 2001 From: Jatin Mehta Date: Mon, 6 Jan 2025 00:13:44 +0530 Subject: [PATCH 1/3] update token script should reject the tampered user-info-jwt --- admin-ui/app/locales/en/translation.json | 5 +- admin-ui/app/locales/fr/translation.json | 8 +-- admin-ui/app/locales/pt/translation.json | 8 +-- .../routes/Apps/Gluu/GluuPermissionModal.js | 49 +++++++++++++++++++ .../app/routes/Dashboards/DashboardPage.js | 30 +++++++----- 5 files changed, 81 insertions(+), 19 deletions(-) create mode 100644 admin-ui/app/routes/Apps/Gluu/GluuPermissionModal.js diff --git a/admin-ui/app/locales/en/translation.json b/admin-ui/app/locales/en/translation.json index 691a2d309..555413557 100644 --- a/admin-ui/app/locales/en/translation.json +++ b/admin-ui/app/locales/en/translation.json @@ -83,7 +83,10 @@ "config_api_status":"Config API Status", "key_cloak":"Keycloak", "jans_lock":"Jans Lock", - "jans_link":"Jans Link" + "jans_link":"Jans Link", + "access_denied":"Access Denied", + "access_denied_message":"You do not have permission to access this page", + "access_contact_admin":"Please contact your administrator for more information" }, "fields": { "access_token_signing_alg": "JWS alg for signing", diff --git a/admin-ui/app/locales/fr/translation.json b/admin-ui/app/locales/fr/translation.json index 336415927..37049329b 100644 --- a/admin-ui/app/locales/fr/translation.json +++ b/admin-ui/app/locales/fr/translation.json @@ -31,7 +31,10 @@ "config_api_status": "État de l'API de configuration", "key_cloak": "Keycloak", "jans_lock": "Jans Lock", - "jans_link": "Lien Jans" + "jans_link": "Lien Jans", + "access_denied":"Accès refusé", + "access_denied_message":"Vous n'êtes pas autorisé à accéder à cette page", + "access_contact_admin":"Veuillez contacter l'administrateur pour obtenir de l'aide" }, "menus": { "adminui": "Administratrice", @@ -104,8 +107,7 @@ "customer_backend_key_attributes": "Clé/attributs du backend client", "source_backend_ldap_servers": "Serveurs LDAP dorsaux sources", "inum_db_server": "Serveur de base de données Inum", - "static_configuration": "Configuration statique", - "dynamic_configuration": "Configuration dynamique" + "static_configuration": "Configuration statique" }, "actions": { "accept": "J'accepte", diff --git a/admin-ui/app/locales/pt/translation.json b/admin-ui/app/locales/pt/translation.json index 2f8ad127e..54d2dc364 100644 --- a/admin-ui/app/locales/pt/translation.json +++ b/admin-ui/app/locales/pt/translation.json @@ -31,7 +31,10 @@ "config_api_status": "Status da API de configuração", "key_cloak": "Keycloak", "jans_lock": "Jans Lock", - "jans_link": "Link Jans" + "jans_link": "Link Jans", + "access_denied":"Acesso negado", + "access_denied_message":"Entre em contato com o administrador para obter ajuda", + "access_contact_admin":"Se você acha que isso é um erro, entre em contato com o administrador" }, "menus": { "adminui": "Admin", @@ -102,8 +105,7 @@ "customer_backend_key_attributes": "Chave/atributos de back-end do cliente", "source_backend_ldap_servers": "Servidores LDAP de back-end de origem", "inum_db_server": "Servidor DB Inum", - "static_configuration": "Configuração estática", - "dynamic_configuration": "Configuração Dinâmica" + "static_configuration": "Configuração estática" }, "actions": { "accept": "Aceitar", diff --git a/admin-ui/app/routes/Apps/Gluu/GluuPermissionModal.js b/admin-ui/app/routes/Apps/Gluu/GluuPermissionModal.js new file mode 100644 index 000000000..457559f61 --- /dev/null +++ b/admin-ui/app/routes/Apps/Gluu/GluuPermissionModal.js @@ -0,0 +1,49 @@ +import React from "react"; +import { useTranslation } from "react-i18next"; +import { Button, Modal, ModalBody, ModalFooter, ModalHeader } from "reactstrap"; + +const GluuPermissionModal = ({ description = "", handler, isOpen }) => { + const { t } = useTranslation(); + + return ( +
+ + + {t("dashboard.access_denied")} + + +

+ 🚫 {t("dashboard.access_denied_message")} +

+

{t("dashboard.access_contact_admin")}

+
+ + + +
+ + {/* Scoped CSS inside the component */} + +
+ ); +}; + +export default GluuPermissionModal; diff --git a/admin-ui/app/routes/Dashboards/DashboardPage.js b/admin-ui/app/routes/Dashboards/DashboardPage.js index ac991e1af..69c4480fe 100644 --- a/admin-ui/app/routes/Dashboards/DashboardPage.js +++ b/admin-ui/app/routes/Dashboards/DashboardPage.js @@ -26,6 +26,8 @@ import UsersIcon from "Components/SVG/menu/Users"; import Administrator from "Components/SVG/menu/Administrator"; import OAuthIcon from "Components/SVG/menu/OAuth"; import { getHealthServerStatus } from "../../redux/features/healthSlice"; +import GluuPermissionModal from "Routes/Apps/Gluu/GluuPermissionModal"; +import { auditLogoutLogs } from "../../../plugins/user-management/redux/features/userSlice"; function DashboardPage() { const { t } = useTranslation(); @@ -80,20 +82,22 @@ function DashboardPage() { }, [statData]); useEffect(() => { - if (Object.keys(license).length === 0 && access_token) { + if (Object.keys(license).length === 0 && access_token && hasBoth(permissions, STAT_READ, STAT_JANS_READ)) { getLicense(); } }, [access_token, license]); useEffect(() => { - if (clients.length === 0 && access_token) { + if (clients.length === 0 && access_token && hasBoth(permissions, STAT_READ, STAT_JANS_READ)) { buildPayload(userAction, "Fetch openid connect clients", {}); dispatch(getClients({ action: userAction })); } }, [access_token, clients]); useEffect(() => { - if (access_token) { + + if (access_token && hasBoth(permissions, STAT_READ, STAT_JANS_READ)) { + console.log("access_token", access_token,hasBoth(permissions, STAT_READ, STAT_JANS_READ)); getServerStatus(); buildPayload(userAction, "GET Health Status", { service: "all" }); dispatch(getHealthServerStatus({ action: userAction })); @@ -289,14 +293,23 @@ function DashboardPage() { ); }, [serverStatus, serverHealth, dbStatus, t, statusDetails, classes]); + const handleLogout = () => { + dispatch(auditLogoutLogs({ message: "Logging out due to insufficient permissions for Admin UI access." })); + }; + return ( + { + handleLogout(); + }} + isOpen={!hasBoth(permissions, STAT_READ, STAT_JANS_READ)} + />
-
- + - From a93bea8a215f947b056162670bc39e5d3e540b14 Mon Sep 17 00:00:00 2001 From: Jatin Mehta Date: Mon, 6 Jan 2025 00:17:40 +0530 Subject: [PATCH 2/3] resolve sonar qube issues --- admin-ui/app/routes/Apps/Gluu/GluuPermissionModal.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/admin-ui/app/routes/Apps/Gluu/GluuPermissionModal.js b/admin-ui/app/routes/Apps/Gluu/GluuPermissionModal.js index 457559f61..c597fa02a 100644 --- a/admin-ui/app/routes/Apps/Gluu/GluuPermissionModal.js +++ b/admin-ui/app/routes/Apps/Gluu/GluuPermissionModal.js @@ -1,8 +1,9 @@ import React from "react"; import { useTranslation } from "react-i18next"; import { Button, Modal, ModalBody, ModalFooter, ModalHeader } from "reactstrap"; +import PropTypes from 'prop-types' -const GluuPermissionModal = ({ description = "", handler, isOpen }) => { +const GluuPermissionModal = ({ handler, isOpen }) => { const { t } = useTranslation(); return ( @@ -46,4 +47,10 @@ const GluuPermissionModal = ({ description = "", handler, isOpen }) => { ); }; + +GluuPermissionModal.propTypes = { + handler: PropTypes.func, + isOpen: PropTypes.bool, +} + export default GluuPermissionModal; From 1e0e4d1222dce5bcc8e39ef51a6dd41c7009c43b Mon Sep 17 00:00:00 2001 From: Jatin Mehta Date: Mon, 6 Jan 2025 21:56:21 +0530 Subject: [PATCH 3/3] show alert when token expored --- admin-ui/app/routes/Dashboards/DashboardPage.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/admin-ui/app/routes/Dashboards/DashboardPage.js b/admin-ui/app/routes/Dashboards/DashboardPage.js index 69c4480fe..8ae0af922 100644 --- a/admin-ui/app/routes/Dashboards/DashboardPage.js +++ b/admin-ui/app/routes/Dashboards/DashboardPage.js @@ -28,9 +28,11 @@ import OAuthIcon from "Components/SVG/menu/OAuth"; import { getHealthServerStatus } from "../../redux/features/healthSlice"; import GluuPermissionModal from "Routes/Apps/Gluu/GluuPermissionModal"; import { auditLogoutLogs } from "../../../plugins/user-management/redux/features/userSlice"; +import { useNavigate } from "react-router"; function DashboardPage() { const { t } = useTranslation(); + const navigate = useNavigate(); const isTabletOrMobile = useMediaQuery({ query: "(max-width: 1224px)" }); const breakDashboardCard = useMediaQuery({ query: "(max-width: 1424px)" }); const isMobile = useMediaQuery({ maxWidth: 767 }); @@ -294,7 +296,11 @@ function DashboardPage() { }, [serverStatus, serverHealth, dbStatus, t, statusDetails, classes]); const handleLogout = () => { - dispatch(auditLogoutLogs({ message: "Logging out due to insufficient permissions for Admin UI access." })); + if(access_token){ + dispatch(auditLogoutLogs({ message: "Logging out due to insufficient permissions for Admin UI access." })); + } + else navigate("/logout") + }; return ( @@ -303,7 +309,7 @@ function DashboardPage() { handler={() => { handleLogout(); }} - isOpen={!hasBoth(permissions, STAT_READ, STAT_JANS_READ)} + isOpen={!access_token || !hasBoth(permissions, STAT_READ, STAT_JANS_READ)} />