Skip to content

Commit

Permalink
Fix to allow non owners and admins to get clusters (#998)
Browse files Browse the repository at this point in the history
  • Loading branch information
FancMa01 authored Jan 22, 2025
1 parent 031587a commit bcc8fb7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export const getCluster = async (id) => {
headers: authHeader(),
};

const response = await fetch(`/api/cluster/${id}`, payload);
const response = await fetch(`/api/cluster/getOne/${id}`, payload);

if (!response.ok) {
throw new Error('Failed to fetch cluster details');
Expand Down
23 changes: 12 additions & 11 deletions Tombolo/server/routes/clusterRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,20 @@ const role = require("../config/roleTypes");

const { validateUserRole } = require("../middlewares/rbacMiddleware");

router.get("/", getClusters); // GET - all clusters
router.get("/getOne/:id", validateClusterId, getCluster); // GET - one cluster by id

//cluster dashboards
router.get("/currentClusterUsage/:id", validateClusterId, clusterUsage);
router.get(
"/clusterStorageHistory/:queryData",
validateQueryData,
clusterStorageHistory
);

// All routes below is accessible only by users with role "owner" and "administrator"
router.use(validateUserRole([role.OWNER, role.ADMIN]));


router.post("/ping", validateClusterPingPayload, pingCluster); // GET - Ping cluster
router.get("/pingExistingCluster/:id", validateClusterId, pingExistingCluster); // GET - Ping existing cluster
router.get("/whiteList", getClusterWhiteList); // GET - cluster white list
Expand All @@ -39,17 +49,8 @@ router.post(
validateAddClusterInputs,
addClusterWithProgress
); // CREATE - one cluster with progress
router.get("/", getClusters); // GET - all clusters
router.get("/:id", validateClusterId, getCluster); // GET - one cluster by id

router.delete("/:id", validateClusterId, deleteCluster); // DELETE - one cluster by id
router.patch("/:id", validateUpdateClusterInputs, updateCluster); // UPDATE - one cluster by id

//cluster dashboards
router.get("/currentClusterUsage/:id", validateClusterId, clusterUsage);
router.get(
"/clusterStorageHistory/:queryData",
validateQueryData,
clusterStorageHistory
);

module.exports = router;

0 comments on commit bcc8fb7

Please sign in to comment.