better honeypot logging

This commit is contained in:
thomas girod 2024-07-21 22:17:54 +02:00
parent 002d8f80a6
commit 03d15ddded

View File

@ -1,12 +1,15 @@
import logging
from time import localtime, strftime
from typing import Any
from django.http import HttpResponse
from django.test.client import WSGIRequest
from django.http import HttpRequest, HttpResponse
def custom_honeypot_error(
request: WSGIRequest, context: dict[str, Any]
request: HttpRequest, context: dict[str, Any]
) -> HttpResponse:
logging.warning(f"HoneyPot blocked user with ip {request.META.get('REMOTE_ADDR')}")
logging.warning(
f"[{strftime('%c', localtime())}] "
f"HoneyPot blocked user with ip {request.META.get('X-Forwarded-For')}"
)
return HttpResponse("Upon reading this, the http client was enlightened.")