# Path: axes/conf.py

# 
# Path: axes/models.py
# class AccessBase(models.Model):
#     user_agent = models.CharField(_("User Agent"), max_length=255, db_index=True)
# 
#     ip_address = models.GenericIPAddressField(_("IP Address"), null=True, db_index=True)
# 
#     username = models.CharField(_("Username"), max_length=255, null=True, db_index=True)
# 
#     http_accept = models.CharField(_("HTTP Accept"), max_length=1025)
# 
#     path_info = models.CharField(_("Path"), max_length=255)
# 
#     attempt_time = models.DateTimeField(_("Attempt Time"), auto_now_add=True)
# 
#     class Meta:
#         app_label = "axes"
#         abstract = True
#         ordering = ["-attempt_time"]


from datetime import timedelta
from hashlib import md5
from logging import getLogger
from string import Template
from typing import Callable, Optional, Type, Union
from urllib.parse import urlencode
from django.core.cache import caches, BaseCache
from django.http import HttpRequest, HttpResponse, JsonResponse, QueryDict
from django.shortcuts import render, redirect
from django.utils.module_loading import import_string
from axes.conf import settings
from axes.models import AccessBase
import ipware.ip
            "Access-Control-Allow-Origin"
        ] = settings.AXES_ALLOWED_CORS_ORIGINS
        json_response["Access-Control-Allow-Methods"] = "POST, OPTIONS"
        json_response[
            "Access-Control-Allow-Headers"
        ] = "Origin, Content-Type, Accept, Authorization, x-requested-with"
        return json_response

    if settings.AXES_LOCKOUT_TEMPLATE:
        return render(request, settings.AXES_LOCKOUT_TEMPLATE, context, status=status)

    if settings.AXES_LOCKOUT_URL:
        lockout_url = settings.AXES_LOCKOUT_URL
        query_string = urlencode({"username": context["username"]})
        url = f"{lockout_url}?{query_string}"
        return redirect(url)

    return HttpResponse(get_lockout_message(), status=status)


def is_ip_address_in_whitelist(ip_address: str) -> bool:
    if not settings.AXES_IP_WHITELIST:
        return False

    return (  # pylint: disable=unsupported-membership-test
        ip_address in settings.AXES_IP_WHITELIST
    )


def is_ip_address_in_blacklist(ip_address: str) -> bool:

# Path: axes/conf.py

# 
# Path: axes/models.py
# class AccessBase(models.Model):
#     user_agent = models.CharField(_("User Agent"), max_length=255, db_index=True)
# 
#     ip_address = models.GenericIPAddressField(_("IP Address"), null=True, db_index=True)
# 
#     username = models.CharField(_("Username"), max_length=255, null=True, db_index=True)
# 
#     http_accept = models.CharField(_("HTTP Accept"), max_length=1025)
# 
#     path_info = models.CharField(_("Path"), max_length=255)
# 
#     attempt_time = models.DateTimeField(_("Attempt Time"), auto_now_add=True)
# 
#     class Meta:
#         app_label = "axes"
#         abstract = True
#         ordering = ["-attempt_time"]


# Path: axes/helpers.py
from datetime import timedelta
from hashlib import md5
from logging import getLogger
from string import Template
from typing import Callable, Optional, Type, Union
from urllib.parse import urlencode
from django.core.cache import caches, BaseCache
from django.http import HttpRequest, HttpResponse, JsonResponse, QueryDict
from django.shortcuts import render, redirect
from django.utils.module_loading import import_string
from axes.conf import settings
from axes.models import AccessBase
import ipware.ip

            "Access-Control-Allow-Origin"
        ] = settings.AXES_ALLOWED_CORS_ORIGINS
        json_response["Access-Control-Allow-Methods"] = "POST, OPTIONS"
        json_response[
            "Access-Control-Allow-Headers"
        ] = "Origin, Content-Type, Accept, Authorization, x-requested-with"
        return json_response

    if settings.AXES_LOCKOUT_TEMPLATE:
        return render(request, settings.AXES_LOCKOUT_TEMPLATE, context, status=status)

    if settings.AXES_LOCKOUT_URL:
        lockout_url = settings.AXES_LOCKOUT_URL
        query_string = urlencode({"username": context["username"]})
        url = f"{lockout_url}?{query_string}"
        return redirect(url)

    return HttpResponse(get_lockout_message(), status=status)


def is_ip_address_in_whitelist(ip_address: str) -> bool:
    if not settings.AXES_IP_WHITELIST:
        return False

    return (  # pylint: disable=unsupported-membership-test
        ip_address in settings.AXES_IP_WHITELIST
    )


def is_ip_address_in_blacklist(ip_address: str) -> bool:

    if not settings.AXES_IP_BLACKLIST: