Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

Add 403 and disallow develoepr accessing instance related pages

天舟b366ed6d9e02
diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.ts
index ba598ffb75..c2aa3e6c65 100644
--- a/frontend/src/router/index.ts
+++ b/frontend/src/router/index.ts
@@ -117,6 +117,18 @@ const routes: Array<RouteRecordRaw> = [
leftSidebar: true,
},
},
+ {
+ path: "403",
+ name: "error.403",
+ components: {
+ content: () => import("../views/Page403.vue"),
+ leftSidebar: DashboardSidebar,
+ },
+ props: {
+ content: true,
+ leftSidebar: true,
+ },
+ },
{
path: "404",
name: "error.404",
@@ -455,6 +467,7 @@ export const router = createRouter({
router.beforeEach((to, from, next) => {
const loginUser: Principal = store.getters["auth/currentUser"]();
+ const isDBAorAbove = loginUser.role == "OWNER" || loginUser.role == "DBA";
const isGuest = loginUser.id == "0";
const fromModule = from.name
@@ -501,12 +514,12 @@ router.beforeEach((to, from, next) => {
}
if (
+ to.name === "error.403" ||
to.name === "error.404" ||
to.name === "error.500" ||
to.name === "workspace.home" ||
to.name === "workspace.inbox" ||
to.name === "workspace.environment" ||
- to.name === "workspace.instance" ||
to.name === "workspace.database" ||
to.name === "workspace.database.create" ||
to.name?.toString().startsWith("setting")
@@ -515,6 +528,18 @@ router.beforeEach((to, from, next) => {
return;
}
+ if (to.name?.toString().startsWith("workspace.instance")) {
+ if (isDBAorAbove) {
+ next();
+ } else {
+ next({
+ name: "error.403",
+ replace: false,
+ });
+ }
+ return;
+ }
+
const routerSlug = store.getters["router/routeSlug"](to);
const taskSlug = routerSlug.taskSlug;
const instanceSlug = routerSlug.instanceSlug;
diff --git a/frontend/src/views/Page403.vue b/frontend/src/views/Page403.vue
new file mode 100644
index 0000000000..d54f2bbc41
--- /dev/null
+++ b/frontend/src/views/Page403.vue
@@ -0,0 +1,12 @@
+<template>
+ <h1>403</h1>
+ <div class="flex-shrink-0 flex border-t border-block-border p-4"></div>
+</template>
+
+<script lang="ts">
+export default {
+ name: "403",
+ components: {},
+ setup(props, ctx) {},
+};
+</script>