Skip to content

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

fix: access control policy messages (#6237)

Danny Xue524031f3be0
diff --git a/frontend/src/views/EnvironmentDashboard.vue b/frontend/src/views/EnvironmentDashboard.vue
index 5a97bbf373..d7fb6406c0 100644
--- a/frontend/src/views/EnvironmentDashboard.vue
+++ b/frontend/src/views/EnvironmentDashboard.vue
@@ -266,22 +266,26 @@ const doCreate = async (
updateMask: ["payload"],
policy: backupPolicy,
}),
- policyV1Store.upsertPolicy({
- parentPath: environment.name,
- updateMask: ["payload", "inherit_from_parent"],
- policy: {
- type: PolicyType.ACCESS_CONTROL,
- inheritFromParent: false,
- accessControlPolicy: {
- disallowRules: [
- {
- fullDatabase: environmentTier === EnvironmentTier.PROTECTED,
- },
- ],
- },
- },
- }),
];
+ if (environmentTier === EnvironmentTier.PROTECTED) {
+ requests.push(
+ policyV1Store.upsertPolicy({
+ parentPath: environment.name,
+ updateMask: ["payload", "inherit_from_parent"],
+ policy: {
+ type: PolicyType.ACCESS_CONTROL,
+ inheritFromParent: true,
+ accessControlPolicy: {
+ disallowRules: [
+ {
+ fullDatabase: environmentTier === EnvironmentTier.PROTECTED,
+ },
+ ],
+ },
+ },
+ })
+ );
+ }
await Promise.all(requests);
state.showCreateModal = false;
selectEnvironment(environment.order);
diff --git a/frontend/src/views/EnvironmentDetail.vue b/frontend/src/views/EnvironmentDetail.vue
index f1e94a9548..f75176baac 100644
--- a/frontend/src/views/EnvironmentDetail.vue
+++ b/frontend/src/views/EnvironmentDetail.vue
@@ -169,17 +169,46 @@ const doUpdate = (environmentPatch: Environment) => {
pendingUpdate.tier = environmentPatch.tier;
}
- environmentV1Store.updateEnvironment(pendingUpdate).then((environment) => {
- assignEnvironment(environment);
+ environmentV1Store
+ .updateEnvironment(pendingUpdate)
+ .then((environment) => {
+ assignEnvironment(environment);
- pushNotification({
- module: "bytebase",
- style: "SUCCESS",
- title: t("environment.successfully-updated-environment", {
- name: environment.title,
- }),
+ const disallowed = environment.tier === EnvironmentTier.PROTECTED;
+ if (disallowed) {
+ return policyV1Store.upsertPolicy({
+ parentPath: environment.name,
+ updateMask: ["payload", "inherit_from_parent"],
+ policy: {
+ type: PolicyTypeV1.ACCESS_CONTROL,
+ inheritFromParent: true,
+ accessControlPolicy: {
+ disallowRules: [{ fullDatabase: true }],
+ },
+ },
+ });
+ } else {
+ policyV1Store
+ .getOrFetchPolicyByParentAndType({
+ parentPath: environment.name,
+ policyType: PolicyTypeV1.ACCESS_CONTROL,
+ })
+ .then((existingPolicy) => {
+ if (existingPolicy) {
+ policyV1Store.deletePolicy(existingPolicy.name);
+ }
+ });
+ }
+ })
+ .then(() => {
+ pushNotification({
+ module: "bytebase",
+ style: "SUCCESS",
+ title: t("environment.successfully-updated-environment", {
+ name: state.environment.title,
+ }),
+ });
});
- });
};
const doArchive = (environment: Environment) => {
diff --git a/frontend/src/views/SettingWorkspaceAccessControl.vue b/frontend/src/views/SettingWorkspaceAccessControl.vue
index c0e1101fde..91fc97641a 100644
--- a/frontend/src/views/SettingWorkspaceAccessControl.vue
+++ b/frontend/src/views/SettingWorkspaceAccessControl.vue
@@ -330,11 +330,7 @@ const handleAddRule = async (databaseList: Database[]) => {
type: PolicyType.ACCESS_CONTROL,
inheritFromParent: false,
accessControlPolicy: {
- disallowRules: [
- {
- fullDatabase: true,
- },
- ],
+ disallowRules: [],
},
},
});