Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
Returns database list conditionally based on the query pattern
天舟f70fb70d5d42
diff --git a/frontend/src/views/InstanceDetail.vue b/frontend/src/views/InstanceDetail.vueindex 9b812bc3a7..309bb6469a 100644--- a/frontend/src/views/InstanceDetail.vue+++ b/frontend/src/views/InstanceDetail.vue@@ -87,6 +87,7 @@ import DatabaseTable from "../components/DatabaseTable.vue";import DataSourceTable from "../components/DataSourceTable.vue";import InstanceForm from "../components/InstanceForm.vue";import {+ Database,Instance,InstanceMigration,MigrationSchemaStatus,@@ -176,9 +177,26 @@ export default {);const databaseList = computed(() => {- return store.getters["database/databaseListByInstanceId"](+ const list = store.getters["database/databaseListByInstanceId"](instance.value.id);+ if (isDBAOrOwner(currentUser.value.role)) {+ return list;+ }++ // In edge case when the user is no longer an Owner or DBA, we only want to display the database+ // belonging to the project which the user is a member of. The returned list above may contain+ // databases not meeting this criteria and we need to filter out them.+ const filteredList: Database[] = [];+ for (const database of list) {+ for (const member of database.project.memberList) {+ if (member.principal.id == currentUser.value.id) {+ filteredList.push(database);+ break;+ }+ }+ }+ return filteredList;});const allowEdit = computed(() => {diff --git a/server/database.go b/server/database.goindex 58c5846786..7dab88cde7 100644--- a/server/database.go+++ b/server/database.go@@ -64,7 +64,13 @@ func (s *Server) registerDatabaseRoutes(g *echo.Group) {filteredList := []*api.Database{}role := c.Get(GetRoleContextKey()).(api.Role)- if role == api.Developer {+ // If caller is NOT requesting for a paritcular instance or the caller is a Developer,+ // then we will only return databases belonging to the project where the caller is a member of.+ // Looking from the UI perspective:+ // - The database list left sidebar will only return databases related to the caller regardless of the caller's role.+ // - The database list on the instance page will return all databases if the caller is Owner or DBA, but will only return+ // related databases if the caller is Developer.+ if databaseFind.InstanceId == nil || role == api.Developer {principalId := c.Get(GetPrincipalIdContextKey()).(int)for _, database := range list {for _, projectMember := range database.Project.ProjectMemberList {