Home:ALL Converter>django-axes lockout not working

django-axes lockout not working

Ask Time:2014-12-09T02:17:07         Author:Jim

Json Formatter

Has anyone here successfully configured django-axes? Axes is a module which provides you with the ability to lock out a user after a specified number of unsuccessful login attempts. I'm having three problems which I haven't been able to solve. First, my application continues to allow me to try to login even if I've exceeded the failure limit, second my site isn't displaying the lockout template if I exceed the failure limit, and third my administrative site isn't showing any login failures. I've read the docs on Github but I still don't see what I'm doing wrong. My files are shown below. Thanks for your help.

# Relevant settings in settings.py
INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'login',
    'axes',
)
# MIDDLEWARE_CLASSES contains usual classes
MIDDLEWARE_CLASSES += (
    'axes.middleware.FailedLoginMiddleware',
)
AXES_LOGIN_FAILURE_LIMIT = 1
import datetime as dt
delta = dt.timedelta(minutes=1)
AXES_COOLOFF_TIME = delta
AXES_LOCKOUT_URL = '/accounts/locked_out/'
AXES_LOCKOUT_TEMPLATE = 'registration/locked_out.html'

# Relevant routes in urls.py
urlpatterns = patterns('',
    # This is my login view, nothing special there
    url(r'^$', 'login.views.firewall_login'),
    # The view for Axes lockout
    url(r'^accounts/locked_out/$', 
        'login.views.locked_out',
        {'template': 'registration/locked_out.html'}),
    url(r'^admin/', include(admin.site.urls)),
)

# views.py
def locked_out(request, template):
    """User is redirected here after they're locked out."""
    return render(request, template)

Author:Jim,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/27364296/django-axes-lockout-not-working
lolly :

Add this to your setting.py:\nAUTHENTICATION_BACKENDS = [\n # AxesBackend should be the first backend in the AUTHENTICATION_BACKENDS list.\n 'axes.backends.AxesBackend',\n\n # Django ModelBackend is the default authentication backend.\n 'django.contrib.auth.backends.ModelBackend',\n]\n",
2021-12-07T16:42:12
yy