Fixes: add debugging log
This commit is contained in:
parent
8e7a6caae9
commit
b01041d150
1 changed files with 4 additions and 0 deletions
|
|
@ -14,6 +14,8 @@ from rest_framework_simplejwt.authentication import JWTAuthentication
|
||||||
from rest_framework_simplejwt.exceptions import InvalidToken
|
from rest_framework_simplejwt.exceptions import InvalidToken
|
||||||
from sentry_sdk import capture_exception
|
from sentry_sdk import capture_exception
|
||||||
|
|
||||||
|
from evibes.settings import DEBUG
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -70,6 +72,8 @@ class BlockInvalidHostMiddleware:
|
||||||
allowed_hosts = getenv("ALLOWED_HOSTS").split(" ")
|
allowed_hosts = getenv("ALLOWED_HOSTS").split(" ")
|
||||||
if not hasattr(request, "META"):
|
if not hasattr(request, "META"):
|
||||||
return BadRequest("Invalid Request")
|
return BadRequest("Invalid Request")
|
||||||
|
if DEBUG:
|
||||||
|
logger.debug(f"Checking {request.META.get("HTTP_HOST")} for presence in ALLOWED_HOSTS({allowed_hosts})")
|
||||||
if request.META.get("HTTP_HOST") not in allowed_hosts and "*" not in allowed_hosts:
|
if request.META.get("HTTP_HOST") not in allowed_hosts and "*" not in allowed_hosts:
|
||||||
return HttpResponseForbidden("Invalid Host Header")
|
return HttpResponseForbidden("Invalid Host Header")
|
||||||
return self.get_response(request)
|
return self.get_response(request)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue