# Path: axes/conf.py

# 
# Path: axes/helpers.py
# def get_failure_limit(request, credentials) -> int:
#     if callable(settings.AXES_FAILURE_LIMIT):
#         return settings.AXES_FAILURE_LIMIT(  # pylint: disable=not-callable
#             request, credentials
#         )
#     if isinstance(settings.AXES_FAILURE_LIMIT, str):
#         return import_string(settings.AXES_FAILURE_LIMIT)(request, credentials)
#     if isinstance(settings.AXES_FAILURE_LIMIT, int):
#         return settings.AXES_FAILURE_LIMIT
#     raise TypeError("settings.AXES_FAILURE_LIMIT needs to be a callable or an integer")
# 
# def is_client_ip_address_blacklisted(request) -> bool:
#     """
#     Check if the given request refers to a blacklisted IP.
#     """
# 
#     if is_ip_address_in_blacklist(request.axes_ip_address):
#         return True
# 
#     if settings.AXES_ONLY_WHITELIST and not is_ip_address_in_whitelist(
#         request.axes_ip_address
#     ):
#         return True
# 
#     return False
# 
# def is_client_ip_address_whitelisted(request):
#     """
#     Check if the given request refers to a whitelisted IP.
#     """
# 
#     if settings.AXES_NEVER_LOCKOUT_WHITELIST and is_ip_address_in_whitelist(
#         request.axes_ip_address
#     ):
#         return True
# 
#     if settings.AXES_ONLY_WHITELIST and is_ip_address_in_whitelist(
#         request.axes_ip_address
#     ):
#         return True
# 
#     return False
# 
# def is_client_method_whitelisted(request) -> bool:
#     """
#     Check if the given request uses a whitelisted method.
#     """
# 
#     if settings.AXES_NEVER_LOCKOUT_GET and request.method == "GET":
#         return True
# 
#     return False
# 
# def is_user_attempt_whitelisted(request, credentials: dict = None) -> bool:
#     """
#     Check if the given request or credentials refer to a whitelisted username.
# 
#     This method invokes the ``settings.AXES_WHITELIST`` callable
#     with ``request`` and ``credentials`` arguments.
# 
#     This function could use the following implementation for checking
#     the lockout flags from a specific property in the user object:
# 
#     .. code-block: python
# 
#        username_value = get_client_username(request, credentials)
#        username_field = getattr(
#            get_user_model(),
#            "USERNAME_FIELD",
#            "username"
#        )
#        kwargs = {username_field: username_value}
# 
#        user_model = get_user_model()
#        user = user_model.objects.get(**kwargs)
#        return user.nolockout
#     """
# 
#     whitelist_callable = settings.AXES_WHITELIST_CALLABLE
#     if whitelist_callable is None:
#         return False
#     if callable(whitelist_callable):
#         return whitelist_callable(request, credentials)  # pylint: disable=not-callable
#     if isinstance(whitelist_callable, str):
#         return import_string(whitelist_callable)(request, credentials)
# 
#     raise TypeError(
#         "settings.AXES_WHITELIST_CALLABLE needs to be a string, callable, or None."
#     )


import re
from abc import ABC, abstractmethod
from django.urls import reverse
from django.urls.exceptions import NoReverseMatch
from axes.conf import settings
from axes.helpers import (
    get_failure_limit,
    is_client_ip_address_blacklisted,
    is_client_ip_address_whitelisted,
    is_client_method_whitelisted,
    is_user_attempt_whitelisted,
)
        """

        if is_user_attempt_whitelisted(request, credentials):
            return True

        if is_client_ip_address_whitelisted(request):
            return True

        if is_client_method_whitelisted(request):
            return True

        return False

    def is_locked(self, request, credentials: dict = None) -> bool:
        """
        Checks if the request or given credentials are locked.
        """

        if settings.AXES_LOCK_OUT_AT_FAILURE:
            # get_failures will have to be implemented by each specialized handler
            return self.get_failures(  # type: ignore
                request, credentials
            ) >= get_failure_limit(request, credentials)

        return False

    def is_admin_site(self, request) -> bool:
        """
        Checks if the request is for admin site.
        """

# Path: axes/conf.py

# 
# Path: axes/helpers.py
# def get_failure_limit(request, credentials) -> int:
#     if callable(settings.AXES_FAILURE_LIMIT):
#         return settings.AXES_FAILURE_LIMIT(  # pylint: disable=not-callable
#             request, credentials
#         )
#     if isinstance(settings.AXES_FAILURE_LIMIT, str):
#         return import_string(settings.AXES_FAILURE_LIMIT)(request, credentials)
#     if isinstance(settings.AXES_FAILURE_LIMIT, int):
#         return settings.AXES_FAILURE_LIMIT
#     raise TypeError("settings.AXES_FAILURE_LIMIT needs to be a callable or an integer")
# 
# def is_client_ip_address_blacklisted(request) -> bool:
#     """
#     Check if the given request refers to a blacklisted IP.
#     """
# 
#     if is_ip_address_in_blacklist(request.axes_ip_address):
#         return True
# 
#     if settings.AXES_ONLY_WHITELIST and not is_ip_address_in_whitelist(
#         request.axes_ip_address
#     ):
#         return True
# 
#     return False
# 
# def is_client_ip_address_whitelisted(request):
#     """
#     Check if the given request refers to a whitelisted IP.
#     """
# 
#     if settings.AXES_NEVER_LOCKOUT_WHITELIST and is_ip_address_in_whitelist(
#         request.axes_ip_address
#     ):
#         return True
# 
#     if settings.AXES_ONLY_WHITELIST and is_ip_address_in_whitelist(
#         request.axes_ip_address
#     ):
#         return True
# 
#     return False
# 
# def is_client_method_whitelisted(request) -> bool:
#     """
#     Check if the given request uses a whitelisted method.
#     """
# 
#     if settings.AXES_NEVER_LOCKOUT_GET and request.method == "GET":
#         return True
# 
#     return False
# 
# def is_user_attempt_whitelisted(request, credentials: dict = None) -> bool:
#     """
#     Check if the given request or credentials refer to a whitelisted username.
# 
#     This method invokes the ``settings.AXES_WHITELIST`` callable
#     with ``request`` and ``credentials`` arguments.
# 
#     This function could use the following implementation for checking
#     the lockout flags from a specific property in the user object:
# 
#     .. code-block: python
# 
#        username_value = get_client_username(request, credentials)
#        username_field = getattr(
#            get_user_model(),
#            "USERNAME_FIELD",
#            "username"
#        )
#        kwargs = {username_field: username_value}
# 
#        user_model = get_user_model()
#        user = user_model.objects.get(**kwargs)
#        return user.nolockout
#     """
# 
#     whitelist_callable = settings.AXES_WHITELIST_CALLABLE
#     if whitelist_callable is None:
#         return False
#     if callable(whitelist_callable):
#         return whitelist_callable(request, credentials)  # pylint: disable=not-callable
#     if isinstance(whitelist_callable, str):
#         return import_string(whitelist_callable)(request, credentials)
# 
#     raise TypeError(
#         "settings.AXES_WHITELIST_CALLABLE needs to be a string, callable, or None."
#     )


# Path: axes/handlers/base.py
import re
from abc import ABC, abstractmethod
from django.urls import reverse
from django.urls.exceptions import NoReverseMatch
from axes.conf import settings
from axes.helpers import (
    get_failure_limit,
    is_client_ip_address_blacklisted,
    is_client_ip_address_whitelisted,
    is_client_method_whitelisted,
    is_user_attempt_whitelisted,
)

        """

        if is_user_attempt_whitelisted(request, credentials):
            return True

        if is_client_ip_address_whitelisted(request):
            return True

        if is_client_method_whitelisted(request):
            return True

        return False

    def is_locked(self, request, credentials: dict = None) -> bool:
        """
        Checks if the request or given credentials are locked.
        """

        if settings.AXES_LOCK_OUT_AT_FAILURE:
            # get_failures will have to be implemented by each specialized handler
            return self.get_failures(  # type: ignore
                request, credentials
            ) >= get_failure_limit(request, credentials)

        return False

    def is_admin_site(self, request) -> bool:
        """
        Checks if the request is for admin site.
        """

        if settings.AXES_ONLY_ADMIN_SITE and hasattr(request, "path"):