From dc4b02c7c3a67c34f16146c686786ffb09367ecf Mon Sep 17 00:00:00 2001 From: Gagan Trivedi Date: Tue, 24 Oct 2023 15:40:58 +0530 Subject: [PATCH] feat(rate-limit): allow user to pass default throttle classes (#2878) --- api/app/settings/common.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api/app/settings/common.py b/api/app/settings/common.py index 1b69b80b5b40..01e2bd7f9ac6 100644 --- a/api/app/settings/common.py +++ b/api/app/settings/common.py @@ -219,6 +219,7 @@ LOGIN_THROTTLE_RATE = env("LOGIN_THROTTLE_RATE", "20/min") SIGNUP_THROTTLE_RATE = env("SIGNUP_THROTTLE_RATE", "10000/min") USER_THROTTLE_RATE = env("USER_THROTTLE_RATE", "500/min") +DEFAULT_THROTTLE_CLASSES = env.list("DEFAULT_THROTTLE_CLASSES", default=[]) REST_FRAMEWORK = { "DEFAULT_PERMISSION_CLASSES": ["rest_framework.permissions.IsAuthenticated"], "DEFAULT_AUTHENTICATION_CLASSES": ( @@ -228,7 +229,7 @@ "PAGE_SIZE": 10, "UNICODE_JSON": False, "DEFAULT_PAGINATION_CLASS": "rest_framework.pagination.PageNumberPagination", - "DEFAULT_THROTTLE_CLASSES": ["rest_framework.throttling.UserRateThrottle"], + "DEFAULT_THROTTLE_CLASSES": DEFAULT_THROTTLE_CLASSES, "DEFAULT_THROTTLE_RATES": { "login": LOGIN_THROTTLE_RATE, "signup": SIGNUP_THROTTLE_RATE,