Commit graph

98 commits

Author SHA1 Message Date
Aleksi Häkli
93bb73552e
Upgrade CI tooling to use automatic code formatting 2019-09-28 19:28:17 +03:00
Aleksi Häkli
eb43ab4151
Remove tests for get_version 2019-08-30 07:00:55 +03:00
Aleksi Häkli
99a5405b1a Support callables for AXES_COOLOFF_TIME
Fixes #475
2019-08-05 22:02:49 +03:00
Aleksi Häkli
d8c6632384
Make reset for attempts and logs pluggable
Fixes #454
2019-07-11 15:31:14 +02:00
Hasan Ramezani
0f3b3527be Remove unused imports. 2019-07-09 14:50:09 +02:00
Aleksi Häkli
0a708ae3ea
Rename logs reset command 2019-07-09 12:55:28 +02:00
Aleksi Häkli
4113fc57d9
Handler import and module loading errors in checks 2019-07-09 12:54:55 +02:00
tlebrize
1253d6aeaa added delete_access_logs management commands as well as tests for it #455 2019-07-09 12:12:54 +02:00
Adam Johnson
fa83253056 Don't trigger axes.W003 for subclasses of AxesBackend
The [usage documentation](https://django-axes.readthedocs.io/en/latest/3_usage.html) advises to create subclass of `AxesBackend` to ignore the lack of `request` if necessary. I've done this in a project using `django-oauth-toolkit`, which doesn't pass `request` (though it should as per [this PR](https://github.com/jazzband/django-oauth-toolkit/pull/643)).

This meant that the axes.W003 check was being triggered, so I've fixed it to check for subclasses of `AxesBackend` as well as the class itself.
2019-07-09 12:10:26 +02:00
Hasan Ramezani
6f2048f7ca Added AXES_ONLY_ADMIN_SITE flag. 2019-07-09 08:12:33 +02:00
Aleksi Häkli
4efbace713
Merge #452 into django-axes master
Fixes #451
Fixes #450 merge conflicts
2019-06-14 17:08:07 +03:00
Bo Bayles
9a043a23d8 Add str import also 2019-06-14 16:48:17 +03:00
Bo Bayles
dbc0c13029 Allow callable failure limit 2019-06-14 16:48:17 +03:00
Morgan Zolob
71708eff5a Stop showing lockout message when lockout is disabled 2019-06-13 16:29:26 -07:00
Aleksi Häkli
47ae68b0c0 Deprecate AXES_DISABLE_SUCCESS_ACCESS_LOG flag
Fixes #446
2019-05-25 20:45:21 +03:00
Aleksi Häkli
d0b21d3803 Use term warning instead of error in check module code 2019-05-25 20:45:21 +03:00
Aleksi Häkli
a151b9c8e2 Add tests for AXES_ENABLED flag 2019-05-19 18:32:40 +03:00
Aleksi Häkli
3152b4d7e9 Improve lockout and request handling
The old architecture used exceptions in the signal handler
which prevented transactions from running smoothly
and signal handlers from running after Axes handlers.

The new architecture changes the request approach to request flagging
and moves the exception handling into the middleware call method.

This allows users to more flexibly run their own signal handlers
and optionally use the Axes middleware if they want to do so.

Fixes #440
Fixes #442
2019-05-19 18:32:40 +03:00
Aleksi Häkli
30184e2e52
Fix regression with empty IP addresses
Cache backend threw an error with OAuth2 backends
missing IP address in the cache key generation.

Fixes #437
2019-05-09 19:08:18 +03:00
Aleksi Häkli
af0c60910e
Add tests for django.contrib.auth login and logout
Changes introduced in version 5.0 release broke compatibility
with some external Django applications and plugins,
which use login and logout methods internally.
2019-05-08 13:57:42 +03:00
Aleksi Häkli
816676f68d Add settings flag for disabling Axes
AXES_ENABLED = False can be used to toggle
the plugin off in tests which use the built-in
Django test client login, force_login and logout
methods which do not supply a request views.

Fixes #433
2019-05-07 23:37:48 +03:00
Aleksi Häkli
c34a2daa1b
Improve check structure and types
Django core uses warnings and mostly no objects in checks
Adopting the same style for check readability purposes
2019-05-01 15:23:16 +03:00
Aleksi Häkli
d5096a6464 Add checks for django-axes configuration flags 2019-05-01 14:30:21 +03:00
Aleksi Häkli
d4dc3ba246 Improve documentation
Fixes #410
2019-04-27 18:51:02 +03:00
Aleksi Häkli
430946a9d1 Rename AxesBaseHandler to AxesHandler 2019-04-27 18:51:02 +03:00
Aleksi Häkli
9df4f858ed
Add tests for cool off thresholds
Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-03-09 21:49:45 +02:00
Aleksi Häkli
b46e7cce01
Drop Python 3.5 support
Most of our users are already running on Python 3.6+
and dropping 3.5 and below in a future oriented release
allows us to focus on implementing more readable codebases.

Fixes #417

Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-03-09 21:49:45 +02:00
Aleksi Häkli
3bece1aaaa
Set Axes request attributes in middleware
Fixes #415

Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-03-03 22:13:13 +02:00
Aleksi Häkli
488cd04856
Use LocMemCache in the development setup
Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-26 16:49:35 +02:00
Aleksi Häkli
62c9dc73e7
Fix cache test parametrization
Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-26 16:39:58 +02:00
Aleksi Häkli
7d9265cd3c
Add check test for missing case branch
Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-26 12:45:37 +02:00
Aleksi Häkli
ff6cb8bffd
Move utils to helpers module
In order to offer backwards compatible import path for the
axes.utils.reset function it has to have a separate
implementation that can be imported independently from
the axes.helpers functions that are used by the
AxesBaseHandler implementation.

Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-25 22:54:40 +02:00
Aleksi Häkli
8b3c5e7b5a
Refactor cache checks
Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-25 21:05:18 +02:00
Aleksi Häkli
677d4c48f4
Improve documentation
- Add information on handlers
- Document configuration options and precedences
- Restructure documentation for better readability

Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-25 17:04:03 +02:00
Aleksi Häkli
1ab8d89869
Fix bug in missing cache backends
Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-25 16:45:56 +02:00
Aleksi Häkli
13b807d647
Add dummy handler implementation
A handler is always loaded if Axes is active,
and the dummy handler is intended for use when
the user wishes to use either the middleware
or authentication backends but does not want
Axes to handle or emit signals from
authentication events.

Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-24 22:37:23 +02:00
Aleksi Häkli
46fc538193
Add cache handler and refactor tests
Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-23 20:19:37 +02:00
Aleksi Häkli
ccace29270
Clean up handler naming and documentation
Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-22 20:13:20 +02:00
Aleksi Häkli
42f8c86997
Improve handler design
Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-22 19:56:05 +02:00
Aleksi Häkli
864bfe3f00
Clean up database handler code and queries
Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-22 19:56:03 +02:00
Aleksi Häkli
e69d479f6a
Refactor handlers to a more pluggable format
- 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>
2019-02-22 19:55:57 +02:00
Aleksi Häkli
b07a513b30
Cleanup for utils
Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-22 19:55:45 +02:00
Aleksi Häkli
a4c4ba6fb7
Refactor utils and attempts internal API
Clean up internal implementations and tests while keeping the
APIs as similar as possible where feasible.

The goal of this change is to not change any documented
or stable APIs that might be in use by users, but to improve
the internal implementations for maintainability and usability.

Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-22 19:55:41 +02:00
Aleksi Häkli
bc24d12975
Add support for string type AXES_USERNAME_CALLABLE
Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-22 19:55:39 +02:00
Aleksi Häkli
97410a7b06
Clean up old test code
Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-22 19:55:37 +02:00
Aleksi Häkli
8b4c522f5b
Rename Axes appconfig startup method to initialize
Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-22 19:55:22 +02:00
Aleksi Häkli
d1eb64679b
Add support for reconfiguring handlers in tests
Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-22 19:55:17 +02:00
Aleksi Häkli
b120fc6fde
Remove redundant AccessAttempt.failures property
Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-22 19:55:10 +02:00
Aleksi Häkli
5a78d41828
Fix buggy test case and improve test speed
- Cool off time was overly long on a number of test
- Cool off time on test was fetched with the wrong method
  resulting in bugs on non-integer second cool off values

Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-22 07:58:28 +02:00
Aleksi Häkli
c17db16253
Use pytest for test runner
Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-20 23:05:21 +02:00