From b83b57406eebca60432fbdcb54f8e7791b377e5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Thu, 1 Sep 2022 12:18:53 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=9A=20Add=20setting=20to=20disable=20r?= =?UTF-8?q?ate=20limiter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Not exposed on the UI and never will be, but allows us to disable rate limiting on the API for easier E2E testing. --- .github/fixtures/with_acl/config.yaml | 2 ++ src/octoprint/server/__init__.py | 6 +++++- src/octoprint/settings.py | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/fixtures/with_acl/config.yaml b/.github/fixtures/with_acl/config.yaml index 57fadccbf..f62e6554f 100644 --- a/.github/fixtures/with_acl/config.yaml +++ b/.github/fixtures/with_acl/config.yaml @@ -1,5 +1,7 @@ accessControl: salt: zXmvzI3uWuTLkSPOEfA2ZLwn3f3sGUNS +devel: + enableRateLimiter: false plugins: virtual_printer: enabled: true diff --git a/src/octoprint/server/__init__.py b/src/octoprint/server/__init__.py index b4a6c84d9..926b0c572 100644 --- a/src/octoprint/server/__init__.py +++ b/src/octoprint/server/__init__.py @@ -1452,7 +1452,11 @@ class Server: app.config["RATELIMIT_STRATEGY"] = "fixed-window-elastic-expiry" - limiter = Limiter(app, key_func=get_remote_address) + limiter = Limiter( + app, + key_func=get_remote_address, + enabled=s.getBoolean(["devel", "enableRateLimiter"]), + ) def _setup_i18n(self, app): global babel diff --git a/src/octoprint/settings.py b/src/octoprint/settings.py index c92eced73..032b23c03 100644 --- a/src/octoprint/settings.py +++ b/src/octoprint/settings.py @@ -471,6 +471,7 @@ default_settings = { "showLoadingAnimation": True, "sockJsConnectTimeout": 30, "pluginTimings": False, + "enableRateLimiter": True, }, } """The default settings of the core application."""