mirror of
https://github.com/jazzband/django-axes.git
synced 2026-05-16 19:41:07 +00:00
- Define a base handler API with method signatures - Move proxy handler to a separate path for importability - Implement a database handler with clean external dependencies - Change the authentication backend and decorators to use the authentication backend This enables clean pluggable authentication backend definitions that users can override and specialize with e.g. cached handlers in their own packages. Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
26 lines
642 B
Python
26 lines
642 B
Python
from functools import wraps
|
|
|
|
from axes.handlers.proxy import AxesProxyHandler
|
|
from axes.utils import get_lockout_response
|
|
|
|
|
|
def axes_dispatch(func):
|
|
def inner(request, *args, **kwargs):
|
|
if AxesProxyHandler.is_allowed_to_authenticate(request):
|
|
return func(request, *args, **kwargs)
|
|
|
|
return get_lockout_response(request)
|
|
|
|
return inner
|
|
|
|
|
|
def axes_form_invalid(func):
|
|
@wraps(func)
|
|
def inner(self, *args, **kwargs):
|
|
if AxesProxyHandler.is_allowed_to_authenticate(self.request):
|
|
return func(self, *args, **kwargs)
|
|
|
|
return get_lockout_response(self.request)
|
|
|
|
|
|
return inner
|