Skip to content

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

chore: update rbac (#3698)

ecmadao2b8d9dcf4887
diff --git a/frontend/public/help/routeMapList.json b/frontend/public/help/routeMapList.json
index 1ea3dc2b6b..c1124eb81c 100644
--- a/frontend/public/help/routeMapList.json
+++ b/frontend/public/help/routeMapList.json
@@ -91,10 +91,6 @@
"routeName": "setting.workspace.subscription",
"helpName": ""
},
- {
- "routeName": "setting.workspace.billing",
- "helpName": ""
- },
{
"routeName": "setting.workspace.integration.slack",
"helpName": ""
@@ -203,4 +199,4 @@
"routeName": "sheets.starred",
"helpName": ""
}
-]
\ No newline at end of file
+]
diff --git a/frontend/src/components/SQLReview/components/SQLReviewCard.vue b/frontend/src/components/SQLReview/components/SQLReviewCard.vue
index dc24bc9922..3315d94526 100644
--- a/frontend/src/components/SQLReview/components/SQLReviewCard.vue
+++ b/frontend/src/components/SQLReview/components/SQLReviewCard.vue
@@ -16,6 +16,7 @@
</div>
<div class="flex gap-x-3">
<button
+ v-if="enableDuplicate"
type="button"
class="btn-normal py-2 px-4"
@click.prevent="emit('duplicate', reviewPolicy)"
@@ -89,6 +90,10 @@ defineProps({
required: true,
type: Object as PropType<SQLReviewPolicy>,
},
+ enableDuplicate: {
+ required: true,
+ type: Boolean,
+ },
});
const emit = defineEmits<{
(event: "click", policy: SQLReviewPolicy): void;
diff --git a/frontend/src/components/SingleFileSelector.vue b/frontend/src/components/SingleFileSelector.vue
index 782db3aaf4..d6d3d71e17 100644
--- a/frontend/src/components/SingleFileSelector.vue
+++ b/frontend/src/components/SingleFileSelector.vue
@@ -1,7 +1,10 @@
<template>
<div
- class="cursor-pointer transition-all hover:bg-gray-100"
- :class="[state.dropAreaActive ? 'bg-gray-300 opacity-100' : '']"
+ class="transition-all hover:bg-gray-100"
+ :class="[
+ state.dropAreaActive ? 'bg-gray-300 opacity-100' : '',
+ disabled ? 'cursor-not-allowed' : 'cursor-pointer',
+ ]"
@click="onUploaderClick"
@drop="onFileDrop"
@dragover.prevent
@@ -14,6 +17,7 @@
type="file"
:accept="supportFileExtensions.join(',')"
class="sr-only hidden"
+ :disabled="disabled"
@input="onFileChange"
/>
<slot></slot>
@@ -34,6 +38,11 @@ const props = defineProps({
required: true,
type: Number,
},
+ disabled: {
+ required: false,
+ type: Boolean,
+ default: false,
+ },
supportFileExtensions: {
required: true,
type: Object as PropType<string[]>,
@@ -61,8 +70,12 @@ const onFileChange = () => {
const onFileDrop = (e: any) => {
e.preventDefault();
-
state.dropAreaActive = false;
+
+ if (props.disabled) {
+ return;
+ }
+
const files: File[] = e.dataTransfer.files;
selectFile(files);
};
diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.ts
index 655c770e35..0889c5bce4 100644
--- a/frontend/src/router/index.ts
+++ b/frontend/src/router/index.ts
@@ -397,13 +397,6 @@ const routes: Array<RouteRecordRaw> = [
import("../views/SettingWorkspaceSubscription.vue"),
props: true,
},
- {
- path: "billing",
- name: "setting.workspace.billing",
- meta: { title: () => t("common.billings") },
- component: () => import("../views/SettingWorkspaceBilling.vue"),
- props: true,
- },
{
path: "integration/slack",
name: "setting.workspace.integration.slack",
diff --git a/frontend/src/utils/role.ts b/frontend/src/utils/role.ts
index 6fb75ca29d..ca091e445a 100644
--- a/frontend/src/utils/role.ts
+++ b/frontend/src/utils/role.ts
@@ -16,6 +16,7 @@ export type WorkspacePermissionType =
| "bb.permission.workspace.manage-general"
| "bb.permission.workspace.manage-sensitive-data"
| "bb.permission.workspace.manage-access-control"
+ | "bb.permission.workspace.manage-subscription"
// Can execute admininstrive queries such as "SHOW PROCESSLIST"
| "bb.permission.workspace.admin-sql-editor";
@@ -38,6 +39,7 @@ export const WORKSPACE_PERMISSION_MATRIX: Map<
["bb.permission.workspace.manage-im-integration", [false, false, true]],
["bb.permission.workspace.manage-sensitive-data", [false, true, true]],
["bb.permission.workspace.manage-access-control", [false, true, true]],
+ ["bb.permission.workspace.manage-subscription", [false, false, true]],
["bb.permission.workspace.admin-sql-editor", [false, true, true]],
]);
diff --git a/frontend/src/views/SettingWorkspaceBilling.vue b/frontend/src/views/SettingWorkspaceBilling.vue
deleted file mode 100644
index 3890bb0741..0000000000
--- a/frontend/src/views/SettingWorkspaceBilling.vue
+++ /dev/null
@@ -1,9 +0,0 @@
-<template>
- <h1>Billing</h1>
-</template>
-
-<script lang="ts">
-export default {
- name: "SettingWorkspaceBilling",
-};
-</script>
diff --git a/frontend/src/views/SettingWorkspaceGeneral.vue b/frontend/src/views/SettingWorkspaceGeneral.vue
index b1be6ccde7..186ca4e0f6 100644
--- a/frontend/src/views/SettingWorkspaceGeneral.vue
+++ b/frontend/src/views/SettingWorkspaceGeneral.vue
@@ -29,6 +29,7 @@
:class="[state.logoUrl ? 'opacity-0 hover:opacity-90' : '']"
:max-file-size-in-mi-b="maxFileSizeInMiB"
:support-file-extensions="supportImageExtensions"
+ :disabled="!allowSave"
@on-select="onLogoSelect"
>
<svg
diff --git a/frontend/src/views/SettingWorkspaceSQLReview.vue b/frontend/src/views/SettingWorkspaceSQLReview.vue
index 21cadaadbe..4c697d6071 100644
--- a/frontend/src/views/SettingWorkspaceSQLReview.vue
+++ b/frontend/src/views/SettingWorkspaceSQLReview.vue
@@ -30,6 +30,7 @@
<template v-for="review in store.reviewPolicyList" :key="review.id">
<SQLReviewCard
:review-policy="review"
+ :enable-duplicate="hasPermission"
@click="onClick"
@duplicate="onDuplicate"
/>
diff --git a/frontend/src/views/SettingWorkspaceSQLReviewDetail.vue b/frontend/src/views/SettingWorkspaceSQLReviewDetail.vue
index 16535deca9..3443164168 100644
--- a/frontend/src/views/SettingWorkspaceSQLReviewDetail.vue
+++ b/frontend/src/views/SettingWorkspaceSQLReviewDetail.vue
@@ -30,30 +30,27 @@
/>
</div>
</div>
- <button
- v-if="reviewPolicy.rowStatus === 'NORMAL'"
- type="button"
- class="btn-normal py-2 px-4"
- @click.prevent="state.showDisableModal = true"
- >
- {{ $t("common.disable") }}
- </button>
- <button
- v-else
- type="button"
- class="btn-normal py-2 px-4"
- @click.prevent="state.showEnableModal = true"
- >
- {{ $t("common.enable") }}
- </button>
- <button
- v-if="hasPermission"
- type="button"
- class="btn-primary"
- @click="onEdit"
- >
- {{ $t("common.edit") }}
- </button>
+ <div v-if="hasPermission" class="flex space-x-2">
+ <button
+ v-if="reviewPolicy.rowStatus === 'NORMAL'"
+ type="button"
+ class="btn-normal py-2 px-4"
+ @click.prevent="state.showDisableModal = true"
+ >
+ {{ $t("common.disable") }}
+ </button>
+ <button
+ v-else
+ type="button"
+ class="btn-normal py-2 px-4"
+ @click.prevent="state.showEnableModal = true"
+ >
+ {{ $t("common.enable") }}
+ </button>
+ <button type="button" class="btn-primary" @click="onEdit">
+ {{ $t("common.edit") }}
+ </button>
+ </div>
</div>
<div
v-if="reviewPolicy.environment"
@@ -149,7 +146,7 @@
class="py-5"
/>
<BBButtonConfirm
- v-if="reviewPolicy.rowStatus === 'ARCHIVED'"
+ v-if="reviewPolicy.rowStatus === 'ARCHIVED' && hasPermission"
:style="'DELETE'"
:button-text="$t('sql-review.delete')"
:ok-text="$t('common.delete')"
diff --git a/frontend/src/views/SettingWorkspaceSubscription.vue b/frontend/src/views/SettingWorkspaceSubscription.vue
index c5bc494bb7..96ede2562a 100644
--- a/frontend/src/views/SettingWorkspaceSubscription.vue
+++ b/frontend/src/views/SettingWorkspaceSubscription.vue
@@ -46,7 +46,7 @@
<dd class="mt-1 text-4xl">{{ expireAt || "n/a" }}</dd>
</div>
</dl>
- <div class="w-full mt-5 flex flex-col">
+ <div v-if="canManageSubscription" class="w-full mt-5 flex flex-col">
<textarea
id="license"
v-model="state.license"
@@ -85,8 +85,13 @@ import { computed, defineComponent, reactive } from "vue";
import { useI18n } from "vue-i18n";
import PricingTable from "../components/PricingTable/";
import { PlanType } from "../types";
-import { pushNotification, useSubscriptionStore } from "@/store";
+import {
+ pushNotification,
+ useCurrentUser,
+ useSubscriptionStore,
+} from "@/store";
import { storeToRefs } from "pinia";
+import { hasWorkspacePermission } from "@/utils";
interface LocalState {
loading: boolean;
@@ -102,6 +107,7 @@ export default defineComponent({
setup() {
const subscriptionStore = useSubscriptionStore();
const { t } = useI18n();
+ const currentUser = useCurrentUser();
const state = reactive<LocalState>({
loading: false,
@@ -165,6 +171,13 @@ export default defineComponent({
state.showTrialModal = true;
};
+ const canManageSubscription = computed((): boolean => {
+ return hasWorkspacePermission(
+ "bb.permission.workspace.manage-subscription",
+ currentUser.value.role
+ );
+ });
+
return {
state,
disabled,
@@ -175,6 +188,7 @@ export default defineComponent({
instanceCount,
uploadLicense,
openTrialModal,
+ canManageSubscription,
};
},
});
diff --git a/frontend/src/views/SettingWorkspaceVCS.vue b/frontend/src/views/SettingWorkspaceVCS.vue
index 292554e3f2..425b2da64e 100644
--- a/frontend/src/views/SettingWorkspaceVCS.vue
+++ b/frontend/src/views/SettingWorkspaceVCS.vue
@@ -6,7 +6,7 @@
$t("version-control.setting.description-highlight")
}}</span>
</div>
- <div class="flex items-center justify-end">
+ <div v-if="vcsList.length > 0" class="flex items-center justify-end">
<button
type="button"
class="btn-primary ml-3 inline-flex justify-center py-2 px-4"
diff --git a/server/acl.go b/server/acl.go
index a8dd0150d6..b46c63ecfa 100644
--- a/server/acl.go
+++ b/server/acl.go
@@ -165,8 +165,8 @@ func aclMiddleware(s *Server, pathPrefix string, ce *casbin.Enforcer, next echo.
path := strings.TrimPrefix(c.Request().URL.Path, pathPrefix)
- // Skips auth, actuator, plan
- if common.HasPrefixes(path, "/auth", "/actuator", "/plan", "/oauth") {
+ // Skips auth, actuator
+ if common.HasPrefixes(path, "/auth", "/actuator", "/oauth") {
return next(c)
}
diff --git a/server/acl_casbin_policy_dba.csv b/server/acl_casbin_policy_dba.csv
index 1dee0e2d4a..61f374d7c6 100644
--- a/server/acl_casbin_policy_dba.csv
+++ b/server/acl_casbin_policy_dba.csv
@@ -88,20 +88,14 @@ p, DBA, /sql/ping, POST
p, DBA, /sql/sync-schema, POST
p, DBA, /sql/execute, POST
p, DBA, /sql/execute/admin, POST
-p, DBA, /vcs, POST
p, DBA, /vcs, GET
p, DBA, /vcs/{vcsID}, GET
-p, DBA, /vcs/{vcsID}, PATCH
-p, DBA, /vcs/{vcsID}, DELETE
p, DBA, /vcs/{vcsID}/repository, GET
p, DBA, /vcs/{vcsID}/external-repository, GET
-p, DBA, /plan, GET
-p, DBA, /plan, PATCH
p, DBA, /setting, GET
p, DBA, /label, GET
p, DBA, /label/{labelID}, PATCH
p, DBA, /subscription, GET
-p, DBA, /subscription, PATCH
p, DBA, /subscription/trial, POST
p, DBA, /sheet, POST
p, DBA, /sheet/my, GET
diff --git a/server/acl_casbin_policy_developer.csv b/server/acl_casbin_policy_developer.csv
index c3804d0770..02d53fc65a 100644
--- a/server/acl_casbin_policy_developer.csv
+++ b/server/acl_casbin_policy_developer.csv
@@ -80,8 +80,6 @@ p, DEVELOPER, /sql/execute, POST
p, DEVELOPER, /vcs, GET
p, DEVELOPER, /vcs/{vcsID}, GET
p, DEVELOPER, /vcs/{vcsID}/external-repository, GET
-p, DEVELOPER, /plan, GET
-p, DEVELOPER, /plan, PATCH
p, DEVELOPER, /setting, GET
p, DEVELOPER, /label, GET
p, DEVELOPER, /subscription, GET
diff --git a/server/acl_casbin_policy_owner.csv b/server/acl_casbin_policy_owner.csv
index ab5392dd7c..d9faf5c524 100644
--- a/server/acl_casbin_policy_owner.csv
+++ b/server/acl_casbin_policy_owner.csv
@@ -99,8 +99,6 @@ p, OWNER, /vcs/{vcsID}, PATCH
p, OWNER, /vcs/{vcsID}, DELETE
p, OWNER, /vcs/{vcsID}/repository, GET
p, OWNER, /vcs/{vcsID}/external-repository, GET
-p, OWNER, /plan, GET
-p, OWNER, /plan, PATCH
p, OWNER, /setting, GET
p, OWNER, /setting/{name}, PATCH
p, OWNER, /label, GET
diff --git a/server/jwt.go b/server/jwt.go
index 45fb5dc320..8b1079fb22 100644
--- a/server/jwt.go
+++ b/server/jwt.go
@@ -204,8 +204,8 @@ func JWTMiddleware(pathPrefix string, principalStore *store.Store, next echo.Han
return func(c echo.Context) error {
path := strings.TrimPrefix(c.Request().URL.Path, pathPrefix)
- // Skips auth, actuator, plan
- if common.HasPrefixes(path, "/auth", "/actuator", "/plan") {
+ // Skips auth, actuator
+ if common.HasPrefixes(path, "/auth", "/actuator") {
return next(c)
}