The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
Workspace provisioning honors admin-connection-details (#74775)
bryanc1e6641e283c
diff --git a/enterprise/backend/src/metabase_enterprise/workspaces/provisioning.clj b/enterprise/backend/src/metabase_enterprise/workspaces/provisioning.cljindex dca7d1274f5..3ccff44feb3 100644--- a/enterprise/backend/src/metabase_enterprise/workspaces/provisioning.clj+++ b/enterprise/backend/src/metabase_enterprise/workspaces/provisioning.clj@@ -4,6 +4,7 @@[metabase-enterprise.workspaces.remapping-cleanup :as ws.remapping-cleanup][metabase.app-db.cluster-lock :as cluster-lock][metabase.driver :as driver]+ [metabase.driver.connection :as driver.conn][metabase.driver.util :as driver.u][metabase.util.log :as log][potemkin.types :as p]@@ -28,14 +29,23 @@"Tear down isolated schema + user. Should be idempotent."))(def dispatching-provisioner- "Default Provisioner that dispatches to the driver multimethods."+ "Default Provisioner that dispatches to the driver multimethods.++ Each call is wrapped in [[driver.conn/with-admin-connection]] so the underlying+ driver impls acquire connections via the database's `:admin-details` overlay+ (when configured). Workspace DDL — `CREATE USER`, `CREATE SCHEMA`, `GRANT` —+ typically needs higher-privilege credentials than the regular query user, and+ the admin overlay is how operators provide them."(reify Provisioner(init! [_ driver database workspace]- (driver/init-workspace-isolation! driver database workspace))+ (driver.conn/with-admin-connection+ (driver/init-workspace-isolation! driver database workspace)))(grant! [_ driver database workspace schemas]- (driver/grant-workspace-read-access! driver database workspace schemas))+ (driver.conn/with-admin-connection+ (driver/grant-workspace-read-access! driver database workspace schemas)))(destroy! [_ driver database workspace]- (driver/destroy-workspace-isolation! driver database workspace))))+ (driver.conn/with-admin-connection+ (driver/destroy-workspace-isolation! driver database workspace)))));;; ---------------------------------------------- Implementation ----------------------------------------------------diff --git a/src/metabase/driver.clj b/src/metabase/driver.cljindex 6d1155a6d1a..6e02f784cab 100644--- a/src/metabase/driver.clj+++ b/src/metabase/driver.clj@@ -1833,7 +1833,13 @@- Grant appropriate permissions (CREATE, INSERT, SELECT, etc.) on the isolated schemaThis is an enterprise feature. Drivers must also return true for- (database-supports? driver :workspace database) to indicate support."+ (database-supports? driver :workspace database) to indicate support.++ Callers are expected to bind [[metabase.driver.connection/with-admin-connection]]+ around this call so connections resolve against the database's `:admin-details`+ overlay when configured. The default `dispatching-provisioner` in+ `metabase-enterprise.workspaces.provisioning` does this; do not rely on+ default connection details from inside impls."{:added "0.59.0" :arglists '([driver database workspace])}dispatch-on-initialized-driver:hierarchy #'hierarchy)@@ -1844,7 +1850,10 @@resources created by init-workspace-isolation!.Should be called when deleting a workspace. Implementations should be- idempotent - calling on an already-destroyed workspace should not error."+ idempotent - calling on an already-destroyed workspace should not error.++ Same admin-connection-scope contract as [[init-workspace-isolation!]]: callers+ bind [[metabase.driver.connection/with-admin-connection]] before invoking."{:added "0.59.0" :arglists '([driver database workspace])}dispatch-on-initialized-driver:hierarchy #'hierarchy)@@ -1862,7 +1871,10 @@- 3-slot (Snowflake, SQL Server, BigQuery): read `:db` + `:schema`. `:db`falls back to the connection's bound db when absent.- schema-less (MySQL): read `:db`; the `qualified-name-components` is `[]`- and the database name lives in the `:db` slot."+ and the database name lives in the `:db` slot.++ Same admin-connection-scope contract as [[init-workspace-isolation!]]: callers+ bind [[metabase.driver.connection/with-admin-connection]] before invoking."{:added "0.59.0" :arglists '([driver database workspace input])}dispatch-on-initialized-driver:hierarchy #'hierarchy)