Skip to content

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

Send CORS headers for localhost regardless of whether SDK is enabled or not (#61747)

Phoomparin Mano4a1ce5d04f25
diff --git a/.clj-kondo/config/modules/config.edn b/.clj-kondo/config/modules/config.edn
index 87bef326523..431080279b6 100644
--- a/.clj-kondo/config/modules/config.edn
+++ b/.clj-kondo/config/modules/config.edn
@@ -516,6 +516,7 @@
public-sharing
queries
query-processor
+ server
settings
tiles
util}}
@@ -1097,6 +1098,7 @@
:api #{metabase.server.core
metabase.server.init
metabase.server.middleware.session
+ metabase.server.settings
metabase.server.streaming-response} ; TODO -- too many API namespaces
:uses #{analytics
api
diff --git a/docs/configuring-metabase/config-template.md b/docs/configuring-metabase/config-template.md
index fb45b4f0247..ae04241b5ca 100644
--- a/docs/configuring-metabase/config-template.md
+++ b/docs/configuring-metabase/config-template.md
@@ -134,7 +134,7 @@ config:
email-smtp-username: null
email-smtp-username-override: null
embedding-app-origins-interactive: null
- embedding-app-origins-sdk: localhost:*
+ embedding-app-origins-sdk: ""
embedding-homepage: hidden
embedding-secret-key: null
enable-embedding-interactive: false
diff --git a/docs/configuring-metabase/environment-variables.md b/docs/configuring-metabase/environment-variables.md
index 09ce64eafef..4c222e08abd 100644
--- a/docs/configuring-metabase/environment-variables.md
+++ b/docs/configuring-metabase/environment-variables.md
@@ -562,7 +562,7 @@ Allow these space delimited origins to embed Metabase interactive.
> Only available on Metabase [Pro](https://www.metabase.com/product/pro) and [Enterprise](https://www.metabase.com/product/enterprise) plans.
- Type: string
-- Default: `localhost:*`
+- Default: `""`
- [Configuration file name](./config-file.md): `embedding-app-origins-sdk`
Allow Metabase SDK access to these space delimited origins.
diff --git a/frontend/src/metabase-types/api/mocks/settings.ts b/frontend/src/metabase-types/api/mocks/settings.ts
index 4770615ae88..79090a34b92 100644
--- a/frontend/src/metabase-types/api/mocks/settings.ts
+++ b/frontend/src/metabase-types/api/mocks/settings.ts
@@ -220,6 +220,7 @@ export const createMockSettings = (
"help-link-custom-destination": "",
"deprecation-notice-version": undefined,
"development-mode?": false,
+ "disable-cors-on-localhost": false,
"ee-ai-features-enabled": false,
"ee-openai-model": "",
"ee-openai-api-key": "",
diff --git a/frontend/src/metabase-types/api/settings.ts b/frontend/src/metabase-types/api/settings.ts
index e9577de17bf..bd995b674b3 100644
--- a/frontend/src/metabase-types/api/settings.ts
+++ b/frontend/src/metabase-types/api/settings.ts
@@ -430,6 +430,7 @@ interface AdminSettings {
"active-users-count"?: number;
"custom-geojson-enabled": boolean;
"deprecation-notice-version"?: string;
+ "disable-cors-on-localhost": boolean;
"embedding-secret-key"?: string;
"redirect-all-requests-to-https": boolean;
"query-caching-min-ttl": number;
diff --git a/frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingSdkSettings/EmbeddingSdkSettings.tsx b/frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingSdkSettings/EmbeddingSdkSettings.tsx
index 4ebe0fdaad5..d51d5813b49 100644
--- a/frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingSdkSettings/EmbeddingSdkSettings.tsx
+++ b/frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingSdkSettings/EmbeddingSdkSettings.tsx
@@ -44,6 +44,7 @@ export function EmbeddingSdkSettings() {
const isReactSdkEnabled = useSetting("enable-embedding-sdk");
const isReactSdkFeatureEnabled = PLUGIN_EMBEDDING_SDK.isEnabled();
+ const isLocalhostCorsDisabled = useSetting("disable-cors-on-localhost");
const isSimpleEmbedEnabled = useSetting("enable-embedding-simple");
const isSimpleEmbedFeatureEnabled =
@@ -129,6 +130,10 @@ export function EmbeddingSdkSettings() {
)
.otherwise(() => null);
+ const corsHintText = isLocalhostCorsDisabled
+ ? t`Separate values with a space. Localhost is not allowed. Changes will take effect within one minute.`
+ : t`Separate values with a space. Localhost is automatically included. Changes will take effect within one minute.`;
+
return (
<SettingsPageWrapper title={t`Modular embedding`}>
<UpsellDevInstances location="embedding-page" />
@@ -245,7 +250,7 @@ export function EmbeddingSdkSettings() {
<HoverCard.Dropdown>
<Box p="md" w={270}>
<Text lh="lg" c="text-medium">
- {t`Separate values with a space. Localhost is automatically included. Changes will take effect within one minute.`}
+ {corsHintText}
</Text>
</Box>
</HoverCard.Dropdown>
diff --git a/src/metabase/analytics/stats.clj b/src/metabase/analytics/stats.clj
index 6d954d2cd82..428356f8e6a 100644
--- a/src/metabase/analytics/stats.clj
+++ b/src/metabase/analytics/stats.clj
@@ -142,8 +142,11 @@
:embedding_app_origin_set (boolean
#_{:clj-kondo/ignore [:deprecated-var]}
(setting/get :embedding-app-origin))
+ ;; We no longer add "localhost:*" as a default origin as of Metabase 56, as it is always allowed,
+ ;; but we still filter it out in stats for compatibility with migrated instances.
:embedding_app_origin_sdk_set (boolean (let [sdk-origins (setting/get :embedding-app-origins-sdk)]
- (and sdk-origins (not= "localhost:*" sdk-origins))))
+ (and (not (str/blank? sdk-origins))
+ (not= "localhost:*" sdk-origins))))
:embedding_app_origin_interactive_set (setting/get :embedding-app-origins-interactive)
:appearance_site_name (not= (appearance/site-name) "Metabase")
:appearance_help_link (appearance/help-link)
diff --git a/src/metabase/embedding/settings.clj b/src/metabase/embedding/settings.clj
index 3618f5cb5e8..cead5eb3324 100644
--- a/src/metabase/embedding/settings.clj
+++ b/src/metabase/embedding/settings.clj
@@ -6,6 +6,7 @@
[metabase.analytics.core :as analytics]
[metabase.config.core :as config]
[metabase.premium-features.core :as premium-features]
+ [metabase.server.settings :as server.settings]
[metabase.settings.core :as setting :refer [defsetting]]
[metabase.util :as u]
[metabase.util.i18n :as i18n :refer [deferred-tru]]
@@ -66,7 +67,9 @@
(or (setting/get-value-of-type :string :embedding-app-origin)
(setting/get-value-of-type :string :embedding-app-origins-interactive)
(let [sdk-origins (setting/get-value-of-type :string :embedding-app-origins-sdk)]
- (and sdk-origins (not= "localhost:*" sdk-origins)))))
+ ;; Don't track "localhost:*" as a meaningful origin since it was
+ ;; the old default and may still exist in migrated instances
+ (and sdk-origins (not (str/blank? sdk-origins)) (not= "localhost:*" sdk-origins)))))
:number-embedded-questions (t2/count :model/Card :enable_embedding true)
:number-embedded-dashboards (t2/count :model/Dashboard :enable_embedding true)}))))))
@@ -147,24 +150,33 @@
(str/join " ")
str/trim))
-(mu/defn- add-localhost :- :string [s :- [:maybe :string]]
- (->> s ignore-localhost (str "localhost:* ") str/trim))
-
(defn- -embedding-app-origins-sdk []
- (add-localhost (setting/get-value-of-type :string :embedding-app-origins-sdk)))
+ (setting/get-value-of-type :string :embedding-app-origins-sdk))
+
+(defn- validate-no-localhost-when-disabled
+ "Throws an exception if localhost origins are present when disable-cors-on-localhost is enabled."
+ [origins-string]
+ (when (and (server.settings/disable-cors-on-localhost)
+ (seq origins-string)
+ (re-find #"localhost" origins-string))
+ (throw (ex-info
+ "Localhost is not allowed because DISABLE_CORS_ON_LOCALHOST is set."
+ {:status-code 400}))))
(defn- -embedding-app-origins-sdk!
"The setter for [[embedding-app-origins-sdk]].
- Checks that we have SDK embedding feature and that it's enabled, then sets the value accordingly."
+ Checks that we have SDK embedding feature and that it's enabled, then sets the value accordingly.
+ Also validates that localhost origins are not added when disable-cors-on-localhost is enabled."
[new-value]
- (add-localhost ;; return the same value that is returned from the getter
- (->> new-value
- ignore-localhost
- ;; Why ignore-localhost?, because localhost:* will always be allowed, so we don't need to store it, if we
- ;; were to store it, and the value was set N times, it would have localhost:* prefixed N times. Also, we
- ;; should not store localhost:port, since it's covered by localhost:* (which is the minumum value).
- (setting/set-value-of-type! :string :embedding-app-origins-sdk))))
+ ;; Validate before processing if disable-cors-on-localhost is enabled
+ (validate-no-localhost-when-disabled new-value)
+ (let [processed-value (->> new-value
+ ignore-localhost)]
+ ;; Why ignore-localhost?, because localhost:* will always be allowed, so we don't need to store it, if we
+ ;; were to store it, and the value was set N times, it would have localhost:* prefixed N times. Also, we
+ ;; should not store localhost:port, since it's covered by localhost:* (which is the minimum value).
+ (setting/set-value-of-type! :string :embedding-app-origins-sdk processed-value)))
(defsetting embedding-app-origins-sdk
(deferred-tru "Allow Metabase SDK access to these space delimited origins.")
@@ -172,7 +184,7 @@
:export? false
:visibility :public
:feature :embedding-sdk
- :default "localhost:*"
+ :default ""
:encryption :no
:audit :getter
:getter #'-embedding-app-origins-sdk
diff --git a/src/metabase/server/middleware/security.clj b/src/metabase/server/middleware/security.clj
index 06566e336f4..05466a4534a 100644
--- a/src/metabase/server/middleware/security.clj
+++ b/src/metabase/server/middleware/security.clj
@@ -11,6 +11,7 @@
[metabase.server.settings :as server.settings]
[metabase.settings.core :as setting]
+ [metabase.util :as u]
[metabase.util.log :as log]
[metabase.util.malli :as mu]
[ring.util.codec :refer [base64-encode]])
@@ -209,34 +210,48 @@
(let [urls (str/split approved-origins-raw #" +")]
(keep parse-url urls)))
+(defn- localhost-origin?
+ "Returns true if the origin is localhost (any port)"
+ [raw-origin]
+ (when raw-origin
+ (let [origin (parse-url raw-origin)]
+ (and origin
+ (= (u/lower-case-en (:domain origin)) "localhost")))))
+
(mu/defn approved-origin?
"Returns true if `origin` should be allowed for CORS based on the `approved-origins`"
[raw-origin :- [:maybe :string]
approved-origins-raw :- [:maybe :string]]
(boolean
- (when (and (seq raw-origin) (seq approved-origins-raw))
- (let [approved-list (parse-approved-origins approved-origins-raw)
- origin (parse-url raw-origin)]
- (some (fn [approved-origin]
- (and
- (approved-domain? (:domain origin) (:domain approved-origin))
- (approved-protocol? (:protocol origin) (:protocol approved-origin))
- (approved-port? (:port origin) (:port approved-origin))))
- approved-list)))))
+ (or
+ ;; Allow localhost origins unless explicitly disallowed
+ (and (localhost-origin? raw-origin)
+ (not (server.settings/disable-cors-on-localhost)))
+ ;; Check against approved origins list
+ (when (and (seq raw-origin) (seq approved-origins-raw))
+ (let [approved-list (parse-approved-origins approved-origins-raw)
+ origin (parse-url raw-origin)]
+ (some (fn [approved-origin]
+ (and
+ (approved-domain? (:domain origin) (:domain approved-origin))
+ (approved-protocol? (:protocol origin) (:protocol approved-origin))
+ (approved-port? (:port origin) (:port approved-origin))))
+ approved-list))))))
(defn access-control-headers
"Returns headers for CORS requests"
[origin enabled? approved-origins]
- (when enabled?
- (merge
- (when (approved-origin? origin approved-origins)
- {"Access-Control-Allow-Origin" origin
- "Vary" "Origin"})
- {"Access-Control-Allow-Headers" "*"
- "Access-Control-Allow-Methods" "*"
- "Access-Control-Expose-Headers" "X-Metabase-Anti-CSRF-Token, X-Metabase-Version"
- ;; Needed for Embedding SDK. Should cache preflight requests for the specified number of seconds.
- "Access-Control-Max-Age" "60"})))
+ (let [localhost-allowed? (and (localhost-origin? origin) (not (server.settings/disable-cors-on-localhost)))]
+ (when (or enabled? localhost-allowed?)
+ (merge
+ (when (approved-origin? origin approved-origins)
+ {"Access-Control-Allow-Origin" origin
+ "Vary" "Origin"})
+ {"Access-Control-Allow-Headers" "*"
+ "Access-Control-Allow-Methods" "*"
+ "Access-Control-Expose-Headers" "X-Metabase-Anti-CSRF-Token, X-Metabase-Version"
+ ;; Needed for Embedding SDK. Should cache preflight requests for the specified number of seconds.
+ "Access-Control-Max-Age" "60"}))))
(defn security-headers
"Fetch a map of security headers that should be added to a response based on the passed options."
diff --git a/src/metabase/server/settings.clj b/src/metabase/server/settings.clj
index 76da94388f8..67a371caa4b 100644
--- a/src/metabase/server/settings.clj
+++ b/src/metabase/server/settings.clj
@@ -60,3 +60,10 @@ x.com")
:default true
:visibility :internal
:export? false)
+
+(defsetting disable-cors-on-localhost
+ (deferred-tru "Prevents the server from sending CORS headers for requests originating from localhost.")
+ :type :boolean
+ :default false
+ :visibility :admin
+ :export? true)
diff --git a/test/metabase/embedding/settings_test.clj b/test/metabase/embedding/settings_test.clj
index 37c1615e1dc..c2c8cc665df 100644
--- a/test/metabase/embedding/settings_test.clj
+++ b/test/metabase/embedding/settings_test.clj
@@ -74,12 +74,12 @@
(mt/with-temporary-setting-values [enable-embedding-sdk true]
(let [origin-value "localhost:*"]
(embed.settings/embedding-app-origins-sdk! origin-value)
- (testing "All localhosty origins should be ignored, so the result should be \"localhost:*\""
+ (testing "All localhosty origins should be ignored, so the result should be empty"
(embed.settings/embedding-app-origins-sdk! (str origin-value " localhost:8080"))
- (is (= "localhost:*" (embed.settings/embedding-app-origins-sdk))))
+ (is (= "" (embed.settings/embedding-app-origins-sdk))))
(testing "Normal ips are added to the list"
(embed.settings/embedding-app-origins-sdk! (str origin-value " " other-ip))
- (is (= (str "localhost:* " other-ip) (embed.settings/embedding-app-origins-sdk))))))))
+ (is (= other-ip (embed.settings/embedding-app-origins-sdk))))))))
(deftest enable-embedding-SDK-false-returns-nothing
(mt/with-premium-features #{:embedding :embedding-sdk}
@@ -185,13 +185,13 @@
(= expected-behavior :no-op)
(do (is (= (:embedding-app-origins-interactive unsyncd-setting)
(embed.settings/embedding-app-origins-interactive)))
- (is (= (#'embed.settings/add-localhost (:embedding-app-origins-sdk unsyncd-setting))
+ (is (= (:embedding-app-origins-sdk unsyncd-setting)
(embed.settings/embedding-app-origins-sdk))))
(= expected-behavior :sets-both)
(do (is (= (:mb-embedding-app-origin env)
(embed.settings/embedding-app-origins-interactive)))
- (is (= (#'embed.settings/add-localhost (:mb-embedding-app-origin env))
+ (is (= (:mb-embedding-app-origin env)
(embed.settings/embedding-app-origins-sdk))))
:else (throw (ex-info "Invalid expected-behavior in test-origin-sync." {:expected-behavior expected-behavior}))))))
@@ -217,3 +217,39 @@
(test-origin-sync! {:mb-embedding-app-origins-interactive nil} :no-op)
(test-origin-sync! {:mb-embedding-app-origin other-ip} :sets-both))))
+
+(deftest disable-cors-on-localhost-validation-test
+ (testing "Should reject localhost origins when disable-cors-on-localhost is enabled"
+ (mt/with-premium-features #{:embedding-sdk}
+ (mt/with-temporary-setting-values [enable-embedding-sdk true
+ disable-cors-on-localhost true
+ embedding-app-origins-sdk ""]
+ (testing "localhost:* should be rejected"
+ (is (thrown-with-msg?
+ clojure.lang.ExceptionInfo
+ #"Localhost is not allowed because DISABLE_CORS_ON_LOCALHOST is set."
+ (embed.settings/embedding-app-origins-sdk! "localhost:*"))))
+ (testing "localhost:3000 should be rejected"
+ (is (thrown-with-msg?
+ clojure.lang.ExceptionInfo
+ #"Localhost is not allowed because DISABLE_CORS_ON_LOCALHOST is set."
+ (embed.settings/embedding-app-origins-sdk! "localhost:3000"))))
+ (testing "localhost mixed with other origins should be rejected"
+ (is (thrown-with-msg?
+ clojure.lang.ExceptionInfo
+ #"Localhost is not allowed because DISABLE_CORS_ON_LOCALHOST is set."
+ (embed.settings/embedding-app-origins-sdk! "https://example.com localhost:3000")))))))
+
+ (testing "Should allow localhost origins when disable-cors-on-localhost is disabled"
+ (mt/with-premium-features #{:embedding-sdk}
+ (mt/with-temporary-setting-values [enable-embedding-sdk true
+ disable-cors-on-localhost false
+ embedding-app-origins-sdk ""]
+ (testing "localhost origins should be allowed"
+ (embed.settings/embedding-app-origins-sdk! "localhost:*")
+ (is (= "" (embed.settings/embedding-app-origins-sdk)))
+ (embed.settings/embedding-app-origins-sdk! "localhost:3000")
+ (is (= "" (embed.settings/embedding-app-origins-sdk))))
+ (testing "localhost mixed with other origins should work"
+ (embed.settings/embedding-app-origins-sdk! "https://example.com localhost:3000")
+ (is (= "https://example.com" (embed.settings/embedding-app-origins-sdk))))))))
diff --git a/test/metabase/server/middleware/security_test.clj b/test/metabase/server/middleware/security_test.clj
index 8c202fcf0f7..b807e341aae 100644
--- a/test/metabase/server/middleware/security_test.clj
+++ b/test/metabase/server/middleware/security_test.clj
@@ -152,10 +152,30 @@
(is (mw.security/approved-port? "80" "*"))
(is (mw.security/approved-port? "8080" "*"))))
+(deftest ^:parallel test-localhost-origin?
+ (testing "Should identify localhost origins correctly"
+ (is (#'mw.security/localhost-origin? "http://localhost"))
+ (is (#'mw.security/localhost-origin? "https://localhost"))
+ (is (#'mw.security/localhost-origin? "http://localhost:3000"))
+ (is (#'mw.security/localhost-origin? "https://localhost:8080"))
+ (is (#'mw.security/localhost-origin? "localhost:3000"))
+ (is (#'mw.security/localhost-origin? "localhost")))
+ (testing "Should not identify non-localhost origins as localhost"
+ (is (not (#'mw.security/localhost-origin? "http://example.com")))
+ (is (not (#'mw.security/localhost-origin? "https://127.0.0.1")))
+ (is (not (#'mw.security/localhost-origin? "http://sub.localhost.com")))
+ (is (not (#'mw.security/localhost-origin? nil)))
+ (is (not (#'mw.security/localhost-origin? "")))))
+
(deftest ^:parallel test-approved-origin?
(testing "Should return false if parameters are nil"
(is (not (mw.security/approved-origin? nil "example.com")))
(is (not (mw.security/approved-origin? "example.com" nil))))
+ (testing "Should always approve localhost origins regardless of approved list"
+ (is (mw.security/approved-origin? "http://localhost" ""))
+ (is (mw.security/approved-origin? "http://localhost:3000" ""))
+ (is (mw.security/approved-origin? "https://localhost:8080" nil))
+ (is (mw.security/approved-origin? "localhost:3000" "example.com")))
(testing "Approved origins with exact protocol and port match"
(let [approved "http://example1.com http://example2.com:3000 https://example3.com"]
(is (mw.security/approved-origin? "http://example1.com" approved))
@@ -181,29 +201,55 @@
(testing "Should handle invalid origins"
(is (mw.security/approved-origin? "http://example.com" " fpt://something ://123 4 http://example.com"))))
+(deftest test-disable-cors-on-localhost-approved-origin
+ (testing "Should approve localhost origins when disable-cors-on-localhost is false"
+ (mt/with-temporary-setting-values [disable-cors-on-localhost false]
+ (is (mw.security/approved-origin? "http://localhost" ""))
+ (is (mw.security/approved-origin? "http://localhost:3000" ""))))
+ (testing "Should reject localhost origins when disable-cors-on-localhost is true"
+ (mt/with-temporary-setting-values [disable-cors-on-localhost true]
+ (is (not (mw.security/approved-origin? "http://localhost" "")))
+ (is (not (mw.security/approved-origin? "http://localhost:3000" "")))))
+ (testing "Should allow localhost origins when explicitly added to approved origins even with disable-cors-on-localhost true"
+ (mt/with-temporary-setting-values [disable-cors-on-localhost true]
+ (is (mw.security/approved-origin? "http://localhost" "localhost"))
+ (is (mw.security/approved-origin? "http://localhost:3000" "localhost:*")))))
+
+(deftest test-disable-cors-on-localhost-access-control-headers
+ (testing "Should allow CORS headers for localhost when disable-cors-on-localhost is false"
+ (mt/with-temporary-setting-values [disable-cors-on-localhost false
+ enable-embedding-sdk false]
+ (is (= "http://localhost:8080" (get (mw.security/access-control-headers
+ "http://localhost:8080"
+ false
+ "")
+ "Access-Control-Allow-Origin")))))
+ (testing "Should block CORS headers for localhost when disable-cors-on-localhost is true and embedding disabled"
+ (mt/with-temporary-setting-values [disable-cors-on-localhost true
+ enable-embedding-sdk false]
+ (is (= nil (get (mw.security/access-control-headers
+ "http://localhost:8080"
+ false
+ "")
+ "Access-Control-Allow-Origin"))))))
+
(deftest test-access-control-headers
(mt/with-premium-features #{:embedding-sdk}
- (testing "Should always allow localhost:*"
- (mt/with-temporary-setting-values [enable-embedding-sdk true
- embedding-app-origins-sdk "localhost:*"]
- (is (= "http://localhost:8080" (-> "http://localhost:8080"
- (mw.security/access-control-headers
- (embed.settings/enable-embedding-sdk)
- (embed.settings/embedding-app-origins-sdk))
- (get "Access-Control-Allow-Origin"))))))
- (testing "Should disable CORS when enable-embedding-sdk is disabled"
- (mt/with-temporary-setting-values [enable-embedding-sdk false]
+ (testing "Should allow localhost even when enable-embedding-sdk is disabled"
+ (mt/with-temporary-setting-values [enable-embedding-sdk false
+ enable-embedding-simple false]
+ (is (= "http://localhost:8080" (get (mw.security/access-control-headers
+ "http://localhost:8080"
+ (embed.settings/enable-embedding-sdk)
+ (embed.settings/embedding-app-origins-sdk))
+ "Access-Control-Allow-Origin"))
+ "Localhost should always be permitted even when `enable-embedding-sdk` is `false`."))
+ (testing "Non-localhost origins should still be blocked when embedding is disabled"
(is (= nil (get (mw.security/access-control-headers
- "http://localhost:8080"
- (embed.settings/enable-embedding-sdk)
- (embed.settings/embedding-app-origins-sdk))
- "Access-Control-Allow-Origin"))
- "Localhost is only permitted when `enable-embedding-sdk` is `true`."))
- (is (= nil (get (mw.security/access-control-headers
- "http://1.2.3.4:5555"
- false
- "localhost:*")
- "Access-Control-Allow-Origin"))))
+ "http://1.2.3.4:5555"
+ false
+ "localhost:*")
+ "Access-Control-Allow-Origin")))))
(testing "Should work with embedding-app-origin"
(mt/with-premium-features #{:embedding-sdk}
(mt/with-temporary-setting-values [enable-embedding-sdk true
@@ -356,24 +402,24 @@
[18 [true "https://my-site-1:1234 http://my-other-site:8080" "http://localhost:1234" "http://www.a-site.com" "http://localhost:1234"]]
[19 [true "https://my-site-1:1234 http://my-other-site:8080" "http://my-site.com" "http://public.metabase.com" nil]]
[20 [true "https://my-site-1:1234 http://my-other-site:8080" "http://my-site.com" "http://www.a-site.com" nil]]
- [21 [false "" "http://localhost:1234" "http://public.metabase.com" nil]]
- [22 [false "" "http://localhost:1234" "http://www.a-site.com" nil]]
+ [21 [false "" "http://localhost:1234" "http://public.metabase.com" "http://localhost:1234"]]
+ [22 [false "" "http://localhost:1234" "http://www.a-site.com" "http://localhost:1234"]]
[23 [false "" "http://my-site.com" "http://public.metabase.com" nil]]
[24 [false "" "http://my-site.com" "http://www.a-site.com" nil]]
- [25 [false "localhost:1234" "http://localhost:1234" "http://public.metabase.com" nil]]
- [26 [false "localhost:1234" "http://localhost:1234" "http://www.a-site.com" nil]]
+ [25 [false "localhost:1234" "http://localhost:1234" "http://public.metabase.com" "http://localhost:1234"]]
+ [26 [false "localhost:1234" "http://localhost:1234" "http://www.a-site.com" "http://localhost:1234"]]
[27 [false "localhost:1234" "http://my-site.com" "http://public.metabase.com" nil]]
[28 [false "localhost:1234" "http://my-site.com" "http://www.a-site.com" nil]]
- [29 [false "http://my-site.com" "http://localhost:1234" "http://public.metabase.com" nil]]
- [30 [false "http://my-site.com" "http://localhost:1234" "http://www.a-site.com" nil]]
+ [29 [false "http://my-site.com" "http://localhost:1234" "http://public.metabase.com" "http://localhost:1234"]]
+ [30 [false "http://my-site.com" "http://localhost:1234" "http://www.a-site.com" "http://localhost:1234"]]
[31 [false "http://my-site.com" "http://my-site.com" "http://public.metabase.com" nil]]
[32 [false "http://my-site.com" "http://my-site.com" "http://www.a-site.com" nil]]
- [33 [false "http://my-site.com:80" "http://localhost:1234" "http://public.metabase.com" nil]]
- [34 [false "http://my-site.com:80" "http://localhost:1234" "http://www.a-site.com" nil]]
+ [33 [false "http://my-site.com:80" "http://localhost:1234" "http://public.metabase.com" "http://localhost:1234"]]
+ [34 [false "http://my-site.com:80" "http://localhost:1234" "http://www.a-site.com" "http://localhost:1234"]]
[35 [false "http://my-site.com:80" "http://my-site.com" "http://public.metabase.com" nil]]
[36 [false "http://my-site.com:80" "http://my-site.com" "http://www.a-site.com" nil]]
- [37 [false "https://my-site-1:1234 http://my-other-site:8080" "http://localhost:1234" "http://public.metabase.com" nil]]
- [38 [false "https://my-site-1:1234 http://my-other-site:8080" "http://localhost:1234" "http://www.a-site.com" nil]]
+ [37 [false "https://my-site-1:1234 http://my-other-site:8080" "http://localhost:1234" "http://public.metabase.com" "http://localhost:1234"]]
+ [38 [false "https://my-site-1:1234 http://my-other-site:8080" "http://localhost:1234" "http://www.a-site.com" "http://localhost:1234"]]
[39 [false "https://my-site-1:1234 http://my-other-site:8080" "http://my-site.com" "http://public.metabase.com" nil]]
[40 [false "https://my-site-1:1234 http://my-other-site:8080" "http://my-site.com" "http://www.a-site.com" nil]]]]
(testing (str "add security headers mw test, index: " idx)
@@ -408,7 +454,7 @@
response (wrapped-handler {:headers {"origin" request-origin} :uri request-uri} identity identity)]
[enable-embedding-sdk embedding-app-origins-sdk request-origin request-uri (-> response :headers (get "Access-Control-Allow-Origin"))])))))
-(deftest ^:parallel add-cors-headers-for-auth-sso-test
+(deftest add-cors-headers-for-auth-sso-test
(testing "Should add CORS headers for /auth/sso endpoint with 402 status (embedding disabled errors)"
(let [wrapped-handler (mw.security/add-security-headers
(fn [_request respond _raise]
diff --git a/test_resources/serialization_baseline/settings.yaml b/test_resources/serialization_baseline/settings.yaml
index d4d1bea0eaf..8118c1e088b 100644
--- a/test_resources/serialization_baseline/settings.yaml
+++ b/test_resources/serialization_baseline/settings.yaml
@@ -14,6 +14,7 @@ custom-formatting: null
custom-geojson: null
custom-geojson-enabled: null
default-maps-enabled: null
+disable-cors-on-localhost: null
email-max-recipients-per-second: null
embedding-homepage: null
enable-embedding: null