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
Report sandboxing and impersonation policies regardless of feature availability (#83788)
Nathan Voxland04589d8638f9
diff --git a/enterprise/backend/src/metabase_enterprise/impersonation/util.clj b/enterprise/backend/src/metabase_enterprise/impersonation/util.cljindex 715517f8a6a..694edbc9109 100644--- a/enterprise/backend/src/metabase_enterprise/impersonation/util.clj+++ b/enterprise/backend/src/metabase_enterprise/impersonation/util.clj@@ -24,8 +24,10 @@(defenterprise impersonated-user?"Returns a boolean if the current user is in a group that has a connection impersonation in place for any database.Note: this function does not check whether the impersonation is *enforced* for the current user, since another group's- permissions may supersede it. Will throw an error if [[api/*current-user-id*]] is not bound."- :feature :advanced-permissions+ permissions may supersede it. Will throw an error if [[api/*current-user-id*]] is not bound. Uses `:feature :none` so+ callers can recognize an impersonated user even when the `:advanced-permissions` feature is temporarily unavailable+ (e.g. during a transient token-check failure) and fail closed instead of leaking data."+ :feature :none[](boolean(when-not *is-superuser?*diff --git a/enterprise/backend/src/metabase_enterprise/sandbox/api/util.clj b/enterprise/backend/src/metabase_enterprise/sandbox/api/util.cljindex 309ab3e6864..afd656571da 100644--- a/enterprise/backend/src/metabase_enterprise/sandbox/api/util.clj+++ b/enterprise/backend/src/metabase_enterprise/sandbox/api/util.clj@@ -90,8 +90,9 @@(defenterprise sandboxed-user?"Returns true if the currently logged in user has any enforced sandboxes. Throws an exception if no current user is- bound."- :feature :sandboxes+ bound. Uses `:feature :none` so callers can recognize a sandboxed user even when the `:sandboxes` feature is+ temporarily unavailable (e.g. during a transient token-check failure) and fail closed instead of leaking data."+ :feature :none[](boolean(when-not *is-superuser?*diff --git a/enterprise/backend/test/metabase_enterprise/impersonation/util_test.clj b/enterprise/backend/test/metabase_enterprise/impersonation/util_test.cljindex 9713c9af298..8e7de85e5a1 100644--- a/enterprise/backend/test/metabase_enterprise/impersonation/util_test.clj+++ b/enterprise/backend/test/metabase_enterprise/impersonation/util_test.clj@@ -76,3 +76,10 @@(is (thrown-with-msg? clojure.lang.ExceptionInfo#"No current user found"(impersonation.util/impersonated-user?)))))))++(deftest impersonated-user-without-advanced-permissions-feature-test+ (testing "A configured impersonation policy is still reported when the `:advanced-permissions` feature is unavailable (e.g. token check failing)"+ (with-impersonations! {:impersonations [{:db-id (mt/id) :attribute "KEY"}]+ :attributes {"KEY" "VAL"}}+ (mt/with-premium-features #{}+ (is (impersonation.util/impersonated-user?))))))diff --git a/enterprise/backend/test/metabase_enterprise/sandbox/api/util_test.clj b/enterprise/backend/test/metabase_enterprise/sandbox/api/util_test.cljindex 361b5ee462b..e4e35169ed2 100644--- a/enterprise/backend/test/metabase_enterprise/sandbox/api/util_test.clj+++ b/enterprise/backend/test/metabase_enterprise/sandbox/api/util_test.clj@@ -63,6 +63,13 @@(mt/with-full-data-perms-for-all-users!(is (not (sandbox.api.util/sandboxed-user?)))))))))+(deftest sandboxed-user?-without-sandboxes-feature-test+ (testing "A configured sandbox is still reported when the `:sandboxes` feature is unavailable (e.g. token check failing)"+ (mt/with-temp [:model/User user {}]+ (met/with-gtaps-for-user! (u/the-id user) {:gtaps {:venues {}}}+ (mt/with-premium-features #{}+ (is (sandbox.api.util/sandboxed-user?)))))))+(defn- has-segmented-perms-when-segmented-db-exists?! [user-kw](testing "User is sandboxed when they are not in any other groups that provide unrestricted access"(met/with-gtaps-for-user! user-kw {:gtaps {:venues {}}}