From 9a237db3d1f66cdbcf5079599258f5fb251c5564 Mon Sep 17 00:00:00 2001 From: Timothy Carambat Date: Mon, 22 Jan 2024 14:14:01 -0800 Subject: [PATCH] Implement total permission overhaul (#629) * Implement total permission overhaul Add explicit permissions on each flex and strict route Patch issues with role escalation and CRUD of users Patch permissions on all routes for coverage Improve middleware to accept role array for clarity * update comments * remove permissions to API-keys for manager. Manager could generate API-key and using high-privelege api-key give themselves admin * update sidebar permissions for multi-user and single user * update options for mobile sidebar --- frontend/src/App.jsx | 2 +- .../src/components/SettingsSidebar/index.jsx | 213 ++++++++++++------ frontend/src/models/system.js | 2 + .../src/pages/Admin/Users/UserRow/index.jsx | 35 ++- frontend/src/pages/Admin/Users/index.jsx | 3 +- server/endpoints/admin.js | 94 +++++--- server/endpoints/api/admin/index.js | 23 +- server/endpoints/chat.js | 8 +- server/endpoints/extensions/index.js | 7 +- server/endpoints/system.js | 208 +++++++---------- server/endpoints/utils.js | 75 ++---- server/endpoints/workspaces.js | 72 +++--- server/models/workspace.js | 6 +- server/utils/helpers/admin/index.js | 52 +++++ server/utils/helpers/chat/convertTo.js | 113 ++++++++++ server/utils/middleware/multiUserProtected.js | 72 ++++-- 16 files changed, 611 insertions(+), 374 deletions(-) create mode 100644 server/utils/helpers/admin/index.js create mode 100644 server/utils/helpers/chat/convertTo.js diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index 7acd2c5347..058505d204 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -81,7 +81,7 @@ export default function App() { /> } + element={} />
- {/* Admin/manager Multi-user Settings */} - {!!user && user?.role !== "default" && ( - <> -
@@ -265,63 +283,95 @@ export function SidebarMobileHeader() { href={paths.settings.system()} btnText="System Preferences" icon={} + user={user} + allowedRole={["admin", "manager"]} />