mirror of
https://github.com/FuzzyGrim/Yamtrack.git
synced 2026-04-18 12:09:33 +00:00
Configure django-allauth to use X-Real-IP for rate limiting
Also remove the unused get_client_ip helper See: https://docs.allauth.org/en/latest/release-notes/recent.html#id3
This commit is contained in:
@@ -39,6 +39,7 @@ http {
|
||||
location / {
|
||||
proxy_pass http://app_server;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
|
||||
}
|
||||
@@ -47,6 +48,7 @@ http {
|
||||
access_log off;
|
||||
proxy_pass http://app_server;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
|
||||
}
|
||||
|
||||
@@ -542,6 +542,7 @@ CELERY_BEAT_SCHEDULE = {
|
||||
},
|
||||
}
|
||||
# Allauth settings
|
||||
ALLAUTH_TRUSTED_CLIENT_IP_HEADER = "X-Real-IP"
|
||||
if CSRF_TRUSTED_ORIGINS:
|
||||
# Check if all origins start with http:// or https://
|
||||
all_http = all(
|
||||
|
||||
@@ -8,21 +8,6 @@ from django.utils import timezone
|
||||
import integrations
|
||||
|
||||
|
||||
def get_client_ip(request):
|
||||
"""Return the client's IP address.
|
||||
|
||||
Used when logging for user registration and login.
|
||||
"""
|
||||
# get the user's IP address
|
||||
ip_address = request.headers.get("x-forwarded-for")
|
||||
|
||||
# if the IP address is not available in HTTP_X_FORWARDED_FOR
|
||||
if not ip_address:
|
||||
ip_address = request.META.get("REMOTE_ADDR")
|
||||
|
||||
return ip_address
|
||||
|
||||
|
||||
def process_task_result(task):
|
||||
"""Process task result based on status and format appropriately."""
|
||||
if task.status == "FAILURE":
|
||||
|
||||
Reference in New Issue
Block a user