Merge branch 'master' into new-admin

This commit is contained in:
Ken Cochrane 2015-01-28 20:21:41 -05:00
commit b50b05f1d2
6 changed files with 0 additions and 26 deletions

View file

@ -274,8 +274,6 @@ locked out.
* ``DEFENDER_REDIS_URL``: String: the redis url for defender.
Default: ``redis://localhost:6379/0``
(Example with password: ``redis://:mypassword@localhost:6379/0``)
* ``DEFENDER_PROTECTED_LOGINS``: Tuple: Used by ``ViewDecoratorMiddleware`` to decide
which login urls need protecting. Default: ``('/accounts/login/',)``
* ``DEFENDER_USE_CELERY``: Boolean: If you want to use Celery to store the login
attempt to the database, set to True. If False, it is saved inline.
Default: ``False``

View file

@ -48,7 +48,4 @@ USERNAME_FORM_FIELD = get_setting('DEFENDER_USERNAME_FORM_FIELD', 'username')
LOCKOUT_URL = get_setting('DEFENDER_LOCKOUT_URL')
PROTECTED_LOGINS = get_setting('DEFENDER_PROTECTED_LOGINS',
('/accounts/login/',))
USE_CELERY = get_setting('DEFENDER_USE_CELERY', False)

View file

@ -1,7 +1,6 @@
from django.contrib.auth import views as auth_views
from .decorators import watch_login
from .config import PROTECTED_LOGINS
class FailedLoginMiddleware(object):
@ -10,20 +9,3 @@ class FailedLoginMiddleware(object):
# watch the auth login
auth_views.login = watch_login(auth_views.login)
class ViewDecoratorMiddleware(object):
"""
When the django_axes middleware is installed, by default it watches the
django.auth.views.login.
This middleware allows adding protection to other views without the need
to change any urls or dectorate them manually.
Add this middleware to your MIDDLEWARE settings after
`defender.middleware.FailedLoginMiddleware` and before the django
flatpages middleware.
"""
def process_view(self, request, view_func, view_args, view_kwargs):
if request.path in PROTECTED_LOGINS:
return watch_login(view_func)(request, *view_args, **view_kwargs)
return None

View file

@ -15,7 +15,6 @@ MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'defender.middleware.FailedLoginMiddleware',
'defender.middleware.ViewDecoratorMiddleware',
)
ROOT_URLCONF = 'defender.test_urls'

View file

@ -501,7 +501,6 @@ class AccessAttemptTest(DefenderTestCase):
from .admin import AccessAttemptAdmin
AccessAttemptAdmin
@patch('defender.config.PROTECTED_LOGINS', (ADMIN_LOGIN_URL, ))
def test_decorator_middleware(self):
# because watch_login is called twice in this test (once by the
# middleware and once by the decorator) we have half as many attempts

View file

@ -15,7 +15,6 @@ MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'defender.middleware.FailedLoginMiddleware',
'defender.middleware.ViewDecoratorMiddleware',
)
ROOT_URLCONF = 'defender.test_urls'