Skip to content

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

small bugfixes for mysql aws iam support (#65585)

Nicola Mometto5a7f27262d88
diff --git a/src/metabase/app_db/env.clj b/src/metabase/app_db/env.clj
index 45e2d5da1b7..91095315b76 100644
--- a/src/metabase/app_db/env.clj
+++ b/src/metabase/app_db/env.clj
@@ -92,10 +92,10 @@
:ssl-cert mb-db-ssl-cert}))
(defn- env->DataSource
- [db-type {:keys [mb-db-connection-uri mb-db-user mb-db-pass mb-db-azure-managed-identity-client-id aws-iam], :as env-vars}]
+ [db-type {:keys [mb-db-connection-uri mb-db-user mb-db-pass mb-db-azure-managed-identity-client-id mb-db-aws-iam], :as env-vars}]
(if mb-db-connection-uri
(mdb.data-source/raw-connection-string->DataSource
- mb-db-connection-uri mb-db-user mb-db-pass mb-db-azure-managed-identity-client-id aws-iam)
+ mb-db-connection-uri mb-db-user mb-db-pass mb-db-azure-managed-identity-client-id mb-db-aws-iam)
(mdb.data-source/broken-out-details->DataSource db-type (broken-out-details db-type env-vars))))
;;;; exports: [[db-type]], [[db-file]], and [[data-source]] created using environment variables.
diff --git a/src/metabase/driver/mysql.clj b/src/metabase/driver/mysql.clj
index 037be11fb06..0e4ae807fef 100644
--- a/src/metabase/driver/mysql.clj
+++ b/src/metabase/driver/mysql.clj
@@ -668,7 +668,7 @@
(throw (ex-info "You must enable SSL in order to use AWS IAM authentication" {})))
(when (and use-iam?
(contains? addl-opts-map "sslMode")
- (not (contains? addl-opts-map "sslMode=VERIFY_CA")))
+ (not= (get addl-opts-map "sslMode") "VERIFY_CA"))
(throw (ex-info "sslMode must be VERIFY_CA in order to use AWS IAM authentication" {})))
(merge
default-connection-args
diff --git a/test/metabase/driver/sql_jdbc/connection_test.clj b/test/metabase/driver/sql_jdbc/connection_test.clj
index 0caea3630b0..87b34924007 100644
--- a/test/metabase/driver/sql_jdbc/connection_test.clj
+++ b/test/metabase/driver/sql_jdbc/connection_test.clj
@@ -415,6 +415,17 @@
:user "root"
:auth-provider :aws-iam
:ssl false
+ :db "metabase"})))
+ (is (thrown-with-msg?
+ clojure.lang.ExceptionInfo
+ #"sslMode must be VERIFY_CA in order to use AWS IAM authentication"
+ (sql-jdbc.conn/connection-details->spec :mysql
+ {:host "localhost"
+ :port 3306
+ :user "root"
+ :auth-provider :aws-iam
+ :ssl true
+ :additional-options "sslMode=require"
:db "metabase"}))))))
(defmacro ^:private with-tunnel-details!