Codebase list django-axes / 50dbb9d
Merge tag 'upstream/3.0.3' Upstream version 3.0.3 James Valleroy 6 years ago
15 changed file(s) with 68 addition(s) and 60 deletion(s). Raw diff Collapse all Expand all
11 language: python
22 cache: pip
33 python:
4 - 3.6
4 - 2.7
5 - 3.4
6 - 3.5
7 - 3.6
58 install: pip install tox-travis
69 script: tox
710 after_success:
912 deploy:
1013 provider: pypi
1114 user: jazzband
12 distributions: "sdist bdist_wheel"
15 server: https://jazzband.co/projects/django-axes/upload
16 distributions: sdist bdist_wheel
1317 password:
14 secure: VD+63Tnv0VYNfFQv9f1KZ0k79HSX8veNk4dTy42Hriteci50z5uSQdZMnqqD83xQJa4VF6N7DHkxHnBVOWLCqGQZeYqR/5BuDFNUewcr6O14dk31HvxMsWDaN1KW0Qwtus8ZrztwGhZtZ/92ODA6luHI4mCTzqX0gcG0/aKd75s=
18 secure: TCH5tGIggL2wsWce2svMwpEpPiwVOYqq1R3uSBTexszleP0OafNq/wZk2KZEReR5w1Aq68qp5F5Eeh2ZjJTq4f9M4LtTvqQzrmyNP55DYk/uB1rBJm9b4gBgMtAknxdI2g7unkhQEDo4suuPCVofM7rrDughySNpmvlUQYDttHQ=
1519 on:
1620 tags: true
1721 repo: jazzband/django-axes
00 Changes
11 =======
2
3 3.0.3 (2017-11-23)
4 ------------------
5
6 - Test against Python 2.7.
7 [mbaechtold]
8
9 - Test against Python 3.4.
10 [pope1ni]
11
12
13 3.0.2 (2017-11-21)
14 ------------------
15
16 - Added form_invalid decorator. Fixes #265
17 [camilonova]
18
219
320 3.0.1 (2017-11-17)
421 ------------------
0 __version__ = '3.0.1'
0 __version__ = '3.0.3'
11
22 default_app_config = 'axes.apps.AppConfig'
33
77 from django.contrib.auth.views import LoginView
88 from django.utils.decorators import method_decorator
99
10 from axes.decorators import watch_login
10 from axes import signals # we must load signals
11 from axes.decorators import axes_dispatch
12 from axes.decorators import axes_form_invalid
1113
12 LoginView.dispatch = method_decorator(watch_login)(LoginView.dispatch)
14 LoginView.dispatch = method_decorator(axes_dispatch)(LoginView.dispatch)
15 LoginView.form_invalid = method_decorator(axes_form_invalid)(LoginView.form_invalid)
00 from datetime import timedelta
1 from functools import wraps
12 import json
23 import logging
34
910 from axes.conf import settings
1011 from axes.attempts import is_already_locked
1112 from axes.utils import iso8601
12 from axes.signals import * # load all signals
1313
1414
1515 log = logging.getLogger(settings.AXES_LOGGER)
3737 )
3838
3939
40 def watch_login(func):
40 def axes_dispatch(func):
4141 def inner(request, *args, **kwargs):
42 # If the request is currently under lockout, do not proceed to the
43 # login function, go directly to lockout url, do not pass go, do not
44 # collect messages about this login attempt
4542 if is_already_locked(request):
4643 return lockout_response(request)
4744
48 # call the login function
4945 return func(request, *args, **kwargs)
46
47 return inner
48
49
50 def axes_form_invalid(func):
51 @wraps(func)
52 def inner(self, *args, **kwargs):
53 if is_already_locked(self.request):
54 return lockout_response(self.request)
55
56 return func(self, *args, **kwargs)
5057
5158 return inner
5259
3939 if settings.AXES_NEVER_LOCKOUT_WHITELIST and ip_in_whitelist(ip_address):
4040 return
4141
42 failures = 1
42 failures = 0
4343 attempts = get_user_attempts(request)
4444 cache_hash_key = get_cache_key(request)
4545 cache_timeout = get_cache_timeout()
1212
1313 SITE_ID = 1
1414
15 MIDDLEWARE_CLASSES = (
15 MIDDLEWARE = (
1616 'django.middleware.common.CommonMiddleware',
1717 'django.contrib.sessions.middleware.SessionMiddleware',
1818 'django.contrib.auth.middleware.AuthenticationMiddleware',
2727 'django.contrib.sites',
2828 'django.contrib.messages',
2929 'django.contrib.admin',
30
31 'axes.apps.AppConfig',
30 'axes',
3231 )
3332
3433 TEMPLATES = [
7473
7574 LOGIN_REDIRECT_URL = '/admin/'
7675
77 AXES_LOGIN_FAILURE_LIMIT = 10
76 AXES_FAILURE_LIMIT = 10
0 try:
1 from unittest.mock import patch
2 except ImportError:
3 from mock import patch
0 from unittest.mock import patch
10 import datetime
21 import hashlib
32 import json
1413 from axes.attempts import get_cache_key
1514 from axes.models import AccessAttempt, AccessLog
1615 from axes.signals import user_locked_out
16 from axes.tests.compatibility import patch
1717 from axes.utils import reset
1818
1919
131131
132132 if attempts:
133133 count = attempts.count()
134 from axes.decorators import get_cache_key
134 # import should be here to avoid circular dependency with get_ip
135 from axes.attempts import get_cache_key
135136 for attempt in attempts:
136137 cache_hash_key = get_cache_key(attempt)
137138 if cache.get(cache_hash_key):
2424 You have a couple options available to you to customize ``django-axes`` a bit.
2525 These should be defined in your ``settings.py`` file.
2626
27 * ``AXES_LOGIN_FAILURE_LIMIT``: The number of login attempts allowed before a
27 * ``AXES_FAILURE_LIMIT``: The number of login attempts allowed before a
2828 record is created for the failed logins. Default: ``3``
2929 * ``AXES_LOCK_OUT_AT_FAILURE``: After the number of allowed login attempts
3030 are exceeded, should we lock out this IP (and optional user agent)?
1111 --------
1212
1313 .. toctree::
14 :maxdepth: 2
14 :maxdepth: 2
1515
1616 installation
1717 configuration
1818 usage
1919 requirements
2020 development
21 issues
2221 captcha
2322
2423 Indices and tables
+0
-33
docs/issues.rst less more
0 .. _issues:
1
2 Issues
3 ======
4
5 Not being locked out after failed attempts
6 ------------------------------------------
7
8 You may find that Axes is not capturing your failed login attempts. It may
9 be that you need to manually add watch_login to your login url.
10
11 For example, in your urls.py::
12
13 ...
14 from my.custom.app import login
15 from axes.decorators import watch_login
16 ...
17 urlpatterns = patterns('',
18 (r'^login/$', watch_login(login)),
19 ...
20
21
22 Locked out without reason
23 -------------------------
24
25 It may happen that you have suddenly become locked out without a single failed
26 attempt. One possible reason is that you are using some custom login form and the
27 username field is named something different than "username", e.g. "email". This
28 leads to all users attempts being lumped together. To fix this add the following
29 to your settings:
30
31 AXES_USERNAME_FORM_FIELD = "email"
32
1616 author_email='codekoala@gmail.com',
1717 maintainer='Alex Clark',
1818 maintainer_email='aclark@aclark.net',
19 url='https://github.com/django-pci/django-axes',
19 url='https://github.com/jazzband/django-axes',
2020 license='MIT',
2121 package_dir={'axes': 'axes'},
2222 install_requires=['pytz', 'django-appconf'],
2626 'Development Status :: 5 - Production/Stable',
2727 'Environment :: Web Environment',
2828 'Framework :: Django',
29 'Framework :: Django :: 1.11',
30 'Framework :: Django :: 2.0',
2931 'Intended Audience :: Developers',
3032 'Intended Audience :: System Administrators',
3133 'License :: OSI Approved :: MIT License',
3234 'Operating System :: OS Independent',
3335 'Programming Language :: Python',
36 'Programming Language :: Python :: 2',
37 'Programming Language :: Python :: 2.7',
3438 'Programming Language :: Python :: 3',
39 'Programming Language :: Python :: 3.4',
40 'Programming Language :: Python :: 3.5',
41 'Programming Language :: Python :: 3.6',
3542 'Topic :: Internet :: Log Analysis',
3643 'Topic :: Security',
3744 'Topic :: System :: Logging',
00 [tox]
11 envlist =
2 py{36}-django-111
3 py{36}-django-20
4 py{36}-django-master
2 py{27,34,35,36}-django-111
3 py{34,35,36}-django-20
4 py{35,36}-django-master
55
66 [testenv]
77 deps =
8 py27: mock
89 django-appconf
910 coveralls
1011 django-111: Django>=1.11,<2.0
1213 django-master: https://github.com/django/django/archive/master.tar.gz
1314 usedevelop = True
1415 ignore_outcome =
15 django-20: True
1616 django-master: True
1717 commands =
1818 coverage run -a --source=axes runtests.py -v2