Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Manage Table Metadata permission is enough to sync table schema (#65866)

Nathan Voxlandd5644614106f
diff --git a/.clj-kondo/config/modules/config.edn b/.clj-kondo/config/modules/config.edn
index 1f728d6971a..232a7ea7bc3 100644
--- a/.clj-kondo/config/modules/config.edn
+++ b/.clj-kondo/config/modules/config.edn
@@ -1622,6 +1622,7 @@
lib
models
parameters
+ permissions
premium-features
query-processor
request
diff --git a/src/metabase/warehouse_schema_rest/api/table.clj b/src/metabase/warehouse_schema_rest/api/table.clj
index c00fc38b610..0d859bad126 100644
--- a/src/metabase/warehouse_schema_rest/api/table.clj
+++ b/src/metabase/warehouse_schema_rest/api/table.clj
@@ -14,6 +14,7 @@
[metabase.lib.metadata :as lib.metadata]
[metabase.lib.schema.id :as lib.schema.id]
[metabase.models.interface :as mi]
+ [metabase.permissions.core :as perms]
[metabase.premium-features.core :as premium-features]
[metabase.query-processor :as qp]
;; legacy usage -- don't do things like this going forward
@@ -499,8 +500,15 @@
"Trigger a manual update of the schema metadata for this `Table`."
[{:keys [id]} :- [:map
[:id ms/PositiveInt]]]
- (let [table (api/write-check (t2/select-one :model/Table :id id))
- database (api/write-check (warehouses/get-database (:db_id table) {:exclude-uneditable-details? true}))]
+ (let [table (t2/select-one :model/Table :id id)
+ database (warehouses/get-database (:db_id table))]
+ (api/check-403
+ (perms/user-has-permission-for-table?
+ api/*current-user-id*
+ :perms/manage-table-metadata
+ :yes
+ (:id database)
+ id))
;; it's okay to allow testing H2 connections during sync. We only want to disallow you from testing them for the
;; purposes of creating a new H2 database.
(if-let [ex (try