perf: domains set to any

This commit is contained in:
ibuler
2026-03-18 15:28:16 +08:00
parent a1d086882c
commit f94e1be039
3 changed files with 9 additions and 4 deletions

View File

@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
#
import os
from django.contrib.auth import get_user_model
from django.core.cache import cache
@@ -111,10 +112,12 @@ class SessionAuthentication(authentication.SessionAuthentication):
if not user or not user.is_active or not user.is_valid:
return None
try:
self.enforce_csrf(request)
except exceptions.AuthenticationFailed:
return None
ignore_csrf_check = os.environ.get("DOMAINS", "") == "*"
if not ignore_csrf_check:
try:
self.enforce_csrf(request)
except exceptions.AuthenticationFailed:
return None
# CSRF passed with authenticated user
return user, None

View File

@@ -198,5 +198,6 @@ class SafeRedirectMiddleware:
class CsrfCheckMiddleware(CsrfViewMiddleware):
def _origin_verified(self, request):
if IGNORE_CSRF_CHECK:
request._dont_enforce_csrf_checks = True
return True
return super()._origin_verified(request)

View File

@@ -118,6 +118,7 @@ BOOTSTRAP3 = {
REDIS_LAYERS_HOST = {
'db': CONFIG.REDIS_DB_WS,
}
USE_X_FORWARDED_HOST = True
REDIS_LAYERS_SSL_PARAMS = {}
if REDIS_USE_SSL: