2024-07-11 08:49:08 +00:00
|
|
|
import logging
|
2024-07-21 20:17:54 +00:00
|
|
|
from time import localtime, strftime
|
2024-07-11 08:49:08 +00:00
|
|
|
from typing import Any
|
|
|
|
|
2024-07-21 20:17:54 +00:00
|
|
|
from django.http import HttpRequest, HttpResponse
|
2024-07-11 08:49:08 +00:00
|
|
|
|
2024-07-22 07:49:08 +00:00
|
|
|
from core.utils import get_client_ip
|
|
|
|
|
2024-07-11 08:49:08 +00:00
|
|
|
|
|
|
|
def custom_honeypot_error(
|
2024-07-21 20:17:54 +00:00
|
|
|
request: HttpRequest, context: dict[str, Any]
|
2024-07-11 08:49:08 +00:00
|
|
|
) -> HttpResponse:
|
2024-07-21 20:17:54 +00:00
|
|
|
logging.warning(
|
|
|
|
f"[{strftime('%c', localtime())}] "
|
2024-07-22 07:49:08 +00:00
|
|
|
f"HoneyPot blocked user with ip {get_client_ip(request)}"
|
2024-07-21 20:17:54 +00:00
|
|
|
)
|
2024-07-11 08:49:08 +00:00
|
|
|
return HttpResponse("Upon reading this, the http client was enlightened.")
|