Configurable ratelimit key

This commit is contained in:
Yingtong Li 2019-01-25 18:42:04 +11:00
parent 05c3440a33
commit 3dfea0f8a0
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A
2 changed files with 3 additions and 1 deletions

View File

@ -128,6 +128,8 @@ SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET = None # FIXME
GOOGLE_API_KEY = None # FIXME GOOGLE_API_KEY = None # FIXME
GOOGLE_CALENDAR_ID = None # FIXME GOOGLE_CALENDAR_ID = None # FIXME
RATELIMIT_KEY = 'ip' # https://django-ratelimit.readthedocs.io/en/stable/keys.html#common-keys e.g. 'header:CF-Connecting-IP'
SOCIAL_AUTH_PIPELINE = ( SOCIAL_AUTH_PIPELINE = (
'social_core.pipeline.social_auth.social_details', 'social_core.pipeline.social_auth.social_details',
'social_core.pipeline.social_auth.social_uid', 'social_core.pipeline.social_auth.social_uid',

View File

@ -92,7 +92,7 @@ def import_signed(request):
'sig': sig_expected 'sig': sig_expected
}) })
@ratelimit(key='ip', rate='100/h') @ratelimit(key=settings.RATELIMIT_KEY, rate='100/h')
def import_search(request): def import_search(request):
if request.method != 'POST': if request.method != 'POST':
return redirect(reverse('import_index')) return redirect(reverse('import_index'))