Commit graph

37 commits

Author SHA1 Message Date
Bruno Alla
510c8d18f5 feat: pass the request to get dynamic cool off period 2024-10-02 20:15:31 +03:00
Bruno Alla
2fb4c81243 feat: pass username to AXES_COOLOFF_TIME callback
If the AXES_COOLOFF_TIME is a callable or path to a callable taking
an argument, pass the username to it.

This should enable users to customize the cool off to be user dependant,
and possibly implement a growing cool-off time:

- First lockout cools off after 5 mins
- Second one after 10 mins
- etc...
2024-10-02 20:15:31 +03:00
Maksim Zayakin
73c4e4501b chore: adjust types: use list instead of iterables and nested lists instead of tuples 2023-05-13 14:04:14 +03:00
Maksim Zayakin
476d3f52bc chore: use get_lockout_parameters in handlers 2023-05-13 14:04:14 +03:00
Aleksi Häkli
c3cfb5150a Refactor cache backend to use cache.incr method for request tracking
The old cache.set method has problems with correctness as well as
performance on higher traffic sites where there are
multiple parallel web servers running at the same time
which can overwrite each others shared cache
2023-05-01 21:27:47 +03:00
Aleksi Häkli
9924077a2a Rename get_cache_key to get_cache_keys 2023-05-01 21:27:47 +03:00
Hasan Ramezani
5c7bea2a42 Update mypy to 0.990 2022-11-14 18:22:04 +02:00
Hasan Ramezani
4da7eb9fc1 Add Optional to type of params with default value equal to None 2022-04-13 17:48:32 +03:00
Antoine Dujardin
9c2ceb7eb7 Add option to keep current behavior for cooloff reset 2022-04-08 22:17:05 +03:00
Antoine Dujardin
1015bad451 Don't reset cooloff time in case of login attempt during lockout 2022-04-08 22:17:05 +03:00
Hasan Ramezani
d674fa6296 Bump prospector from 1.3.1 to 1.5.3 2021-12-08 09:00:51 +01:00
Vasyl Dizhak
8c5c43f482 #750, fix lockout failure when providing AXES_USERNAME_CALLABLE 2021-10-11 20:59:06 +03:00
sarahboyce
403076ef51 feat(helpers): update get_client_str to accept request object
Use case: include more info about the user in the client_str.
username is already included in the arguments but that would require a separate DB call.
https://github.com/jazzband/django-axes/issues/782
2021-09-02 17:40:05 +03:00
Yuta Okamoto
945754eb15 make failures_since_start accessible to the views 2021-08-31 21:24:26 +03:00
Aleksi Häkli
ac86d4b213 Adjust commentation and log messages 2021-06-29 17:50:37 +03:00
Hasan Ramezani
6b2da1f152 Add support for Django 3.2 2021-04-06 20:11:14 +03:00
Nat Gordon
d4e97123f2 Add support to reset attempts on the cache handler 2021-02-15 20:20:49 +02:00
Aleksi Häkli
b6b26e492f Optimize imports as part of cleanup round 2021-01-07 18:23:33 +02:00
Clifton Barnes
cff3a9254c Prevent cache entry for None username 2021-01-06 23:23:21 +02:00
Aleksi Häkli
b569cdb991 Deprecate settings.AXES_LOGGER configuration flag
Fixes #634

The Django import system seems to produce errors
in certain configurations and especially when
MIGRATION_MODULES configuration is set globally.

This is most probably caused by misbehaving or cyclic
Python module imports in the Django application
instrumentatation chain that come up when the
MIGRATION_MODULES configuration is altered.

This patch migrates to the standard Python logging system
use and has less overhead and complexity for users as well.

Having a configurable logging prefix does not produce
a lot of benefits and is less flexible than having
all individual module logging configurations accessible
through the module __name__ parameter in Axes.

For example axes.handlers.* or axes.backends.*
are separately configurable in the new scheme
whereas they would have been both bundled under
the AXES_LOGGER log configuration.
2020-09-26 21:44:56 +03:00
Petr Dlouhý
128d01158c add LOCK_OUT_BY_USER_OR_IP option
store all AccessAttempt records
2020-08-21 17:17:57 +03:00
Jorge Galvis
45109341be Make code Black's compliant. 2020-07-28 20:21:34 +03:00
Jorge Galvis
c786c53e9b Make all handlers to use the AxesBaseHandler mixin. 2020-07-28 20:21:34 +03:00
Jorge Galvis
9bb04a01b8 Only AxesHandler needs to follow a contract 2020-07-28 20:21:34 +03:00
Jorge Galvis
e9fe8e4b90 Make AxesCacheHandler class to be a concrete class of AxesHandler 2020-07-28 20:21:34 +03:00
Aleksi Häkli
93bb73552e
Upgrade CI tooling to use automatic code formatting 2019-09-28 19:28:17 +03: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
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
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
88699cf619
Allow non-Axes requests in the handler backends 2019-05-08 13:28:22 +03:00
Aleksi Häkli
430946a9d1 Rename AxesBaseHandler to AxesHandler 2019-04-27 18:51:02 +03: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
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
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
7564603d9b
Clean up cache handler implementation
Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-24 22:17:01 +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