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
Bump metabase/throttle to 1.0.3 (#86127)
Alexander Polyankin21650085f60e
diff --git a/deps.edn b/deps.ednindex e1e2f20776e..0108410d9c7 100644--- a/deps.edn+++ b/deps.edn@@ -117,7 +117,7 @@org.bouncycastle/bcprov-jdk15onorg.bouncycastle/bcpkix-jdk18onorg.bouncycastle/bcprov-jdk18on]}- metabase/throttle {:mvn/version "1.0.2"} ; Tools for throttling access to API endpoints and other code pathways+ metabase/throttle {:mvn/version "1.0.3"} ; Tools for throttling access to API endpoints and other code pathwaysmethodical/methodical {:mvn/version "1.0.127"} ; drop-in replacements for Clojure multimethods and adds several advanced featuresmetosin/malli {:git/url "https://github.com/metabase/malli" ; Data-driven Schemas for Clojure/Script and babashka:git/sha "b4a2d78647a049870b316753d7aae7fb4ade3ae5"} ; patched to resolve an issue causing OOMdiff --git a/src/metabase/oauth_server/api/oauth.clj b/src/metabase/oauth_server/api/oauth.cljindex f3efbe69899..ff1e0d4f983 100644--- a/src/metabase/oauth_server/api/oauth.clj+++ b/src/metabase/oauth_server/api/oauth.clj@@ -316,7 +316,7 @@[{:keys [attempts attempts-threshold attempt-ttl-ms]} throttle-key](if-let [[_ blocking-attempt-ms] (nth (filter (fn [[attempt-key]] (= throttle-key attempt-key)) @attempts)(dec attempts-threshold) nil)]- (quot (+ 999 (max 0 (- (+ blocking-attempt-ms attempt-ttl-ms) (System/currentTimeMillis)))) 1000)+ (quot (+ 999 (max 0 (- (+ blocking-attempt-ms attempt-ttl-ms) (u.throttle/now-ms)))) 1000)0))(defn- do-with-token-throttlingdiff --git a/src/metabase/util/throttle.clj b/src/metabase/util/throttle.cljindex abf82119aa7..8220f8c4bdb 100644--- a/src/metabase/util/throttle.clj+++ b/src/metabase/util/throttle.clj@@ -7,6 +7,11 @@(set! *warn-on-reflection* true)+(defn now-ms+ "Return the monotonic clock reading in milliseconds that `throttle.core` timestamps attempts with."+ []+ (quot (System/nanoTime) 1000000))+(defn throttle-exception?"True when `e` is a throttle-limit exception thrown by `throttle.core`."[^ExceptionInfo e]diff --git a/test/metabase/oauth_server/api_test.clj b/test/metabase/oauth_server/api_test.cljindex 2b755d09c82..2485e0f8fca 100644--- a/test/metabase/oauth_server/api_test.clj+++ b/test/metabase/oauth_server/api_test.clj@@ -13,6 +13,7 @@[metabase.test :as mt][metabase.test.http-client :as client][metabase.util.secret :as u.secret]+ [metabase.util.throttle :as u.throttle][oidc-provider.store :as oidc.store][oidc-provider.util :as oidc-util][toucan2.core :as t2])@@ -999,7 +1000,7 @@:redirect_uri "https://example.com/callback"}client-throttler @#'api.oauth/token-client-throttlerip-throttler @#'api.oauth/token-ip-throttler- now (System/currentTimeMillis)]+ now (u.throttle/now-ms)](reset! (:attempts client-throttler)(repeat client-attempt-count [client-id (- now (* 10 60 1000))]))(reset! (:attempts ip-throttler) (repeat 50 [ip-address (- now (* 59 60 1000))]))@@ -1121,7 +1122,7 @@authorization (basic-auth-header client-id client-secret)client-throttler @#'api.oauth/token-client-throttlerip-throttler @#'api.oauth/token-ip-throttler- now (System/currentTimeMillis)+ now (u.throttle/now-ms)attempts (fn [throttler throttle-key age-minutes](when age-minutes(concat (repeat (- (:attempts-threshold throttler) 2)