From 4a82d1262d91d57db578d68c32acb8ac420fb3ed Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Tue, 23 Aug 2022 08:43:58 +0100 Subject: [PATCH] Add a basic rate limit --- website/settings.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/website/settings.py b/website/settings.py index ebdef0f..06c9cd6 100644 --- a/website/settings.py +++ b/website/settings.py @@ -211,3 +211,15 @@ if DEBUG: SWAGGER_SETTINGS = {"USE_SESSION_AUTH": False, "SECURITY_DEFINITIONS": {}} + +REST_FRAMEWORK = { + "DEFAULT_THROTTLE_CLASSES": [ + "rest_framework.throttling.AnonRateThrottle", + ], + "DEFAULT_THROTTLE_RATES": { + "anon": "10/min", + }, + "DEFAULT_AUTHENTICATION_CLASSES": [ + "rest_framework.authentication.SessionAuthentication", + ], +}