diff --git a/axes/handlers/base.py b/axes/handlers/base.py index dadf488..c6a1963 100644 --- a/axes/handlers/base.py +++ b/axes/handlers/base.py @@ -51,7 +51,7 @@ class AbstractAxesHandler(ABC): raise NotImplementedError("get_failures should be implemented") -class AxesBaseHandler: +class AxesBaseHandler: # pylint: disable=unused-argument """ Handler API definition for implementations that are used by the ``AxesProxyHandler``. @@ -94,7 +94,7 @@ class AxesBaseHandler: return True - def is_blacklisted(self, request, credentials: dict = None) -> bool: # pylint: disable=unused-argument + def is_blacklisted(self, request, credentials: dict = None) -> bool: """ Checks if the request or given credentials are blacklisted from access. """ @@ -104,7 +104,7 @@ class AxesBaseHandler: return False - def is_whitelisted(self, request, credentials: dict = None) -> bool: # pylint: disable=unused-argument + def is_whitelisted(self, request, credentials: dict = None) -> bool: """ Checks if the request or given credentials are whitelisted for access. """ @@ -127,9 +127,9 @@ class AxesBaseHandler: if settings.AXES_LOCK_OUT_AT_FAILURE: # get_failures will have to be implemented by each specialized handler - return self.get_failures(request, credentials) >= get_failure_limit( # type: ignore + return self.get_failures( # type: ignore request, credentials - ) + ) >= get_failure_limit(request, credentials) return False @@ -146,7 +146,7 @@ class AxesBaseHandler: return False - def reset_attempts(self, *, ip_address: str = None, username: str = None) -> int: # pylint: disable=unused-argument + def reset_attempts(self, *, ip_address: str = None, username: str = None) -> int: """ Resets access attempts that match the given IP address or username. @@ -157,7 +157,7 @@ class AxesBaseHandler: """ return 0 - def reset_logs(self, *, age_days: int = None) -> int: # pylint: disable=unused-argument + def reset_logs(self, *, age_days: int = None) -> int: """ Resets access logs that are older than given number of days. @@ -169,10 +169,11 @@ class AxesBaseHandler: return 0 -class AxesHandler(AbstractAxesHandler, AxesBaseHandler): # pylint: disable=unused-argument +class AxesHandler(AbstractAxesHandler, AxesBaseHandler): """ Signal bare handler implementation without any storage backend. """ + def user_login_failed(self, sender, credentials: dict, request=None, **kwargs): pass @@ -183,4 +184,4 @@ class AxesHandler(AbstractAxesHandler, AxesBaseHandler): # pylint: disable=unuse pass def get_failures(self, request, credentials: dict = None) -> int: - return 0 \ No newline at end of file + return 0 diff --git a/axes/handlers/cache.py b/axes/handlers/cache.py index 6b7c799..49a2d8d 100644 --- a/axes/handlers/cache.py +++ b/axes/handlers/cache.py @@ -16,7 +16,7 @@ from axes.helpers import ( log = getLogger(settings.AXES_LOGGER) -class AxesCacheHandler(AbstractAxesHandler, AxesBaseHandler): # pylint: disable=too-many-locals +class AxesCacheHandler(AbstractAxesHandler, AxesBaseHandler): """ Signal handler implementation that records user login attempts to cache and locks users out if necessary. """ @@ -25,7 +25,6 @@ class AxesCacheHandler(AbstractAxesHandler, AxesBaseHandler): # pylint: disable self.cache = get_cache() self.cache_timeout = get_cache_timeout() - def get_failures(self, request, credentials: dict = None) -> int: cache_key = get_client_cache_key(request, credentials) return self.cache.get(cache_key, default=0) diff --git a/axes/handlers/database.py b/axes/handlers/database.py index 03de92c..b265699 100644 --- a/axes/handlers/database.py +++ b/axes/handlers/database.py @@ -25,7 +25,7 @@ from axes.helpers import ( log = getLogger(settings.AXES_LOGGER) -class AxesDatabaseHandler(AbstractAxesHandler, AxesBaseHandler): # pylint: disable=too-many-locals +class AxesDatabaseHandler(AbstractAxesHandler, AxesBaseHandler): """ Signal handler implementation that records user login attempts to database and locks users out if necessary. @@ -250,4 +250,4 @@ class AxesDatabaseHandler(AbstractAxesHandler, AxesBaseHandler): # pylint: disa When needed, all post_delete actions for this backend should be located here. - """ \ No newline at end of file + """ diff --git a/axes/handlers/dummy.py b/axes/handlers/dummy.py index cf8f11a..0e40ace 100644 --- a/axes/handlers/dummy.py +++ b/axes/handlers/dummy.py @@ -1,7 +1,7 @@ from axes.handlers.base import AxesBaseHandler, AbstractAxesHandler -class AxesDummyHandler(AbstractAxesHandler, AxesBaseHandler): # pylint: disable=unused-argument +class AxesDummyHandler(AbstractAxesHandler, AxesBaseHandler): """ Signal handler implementation that does nothing and can be used to disable signal processing. """ diff --git a/axes/tests/test_handlers.py b/axes/tests/test_handlers.py index cb38506..ca5e489 100644 --- a/axes/tests/test_handlers.py +++ b/axes/tests/test_handlers.py @@ -14,7 +14,6 @@ from axes.tests.base import AxesTestCase @override_settings(AXES_HANDLER="axes.handlers.base.AxesHandler") class AxesHandlerTestCase(AxesTestCase): - @override_settings(AXES_IP_BLACKLIST=["127.0.0.1"]) def test_is_allowed_with_blacklisted_ip_address(self): self.assertFalse(AxesProxyHandler.is_allowed(self.request))