Commit graph

54 commits

Author SHA1 Message Date
Maksim Zayakin
0823584b02 refactor: fix prospector errors 2023-05-13 14:04:14 +03:00
Maksim Zayakin
1e3d41228d feat!: implement reset_request using get_lockout_parameters 2023-05-13 14:04:14 +03:00
Aleksi Häkli
621dfa6882 Fix code formatting 2022-05-16 10:41:07 +03:00
Hasan Ramezani
4da7eb9fc1 Add Optional to type of params with default value equal to None 2022-04-13 17:48:32 +03:00
Petr Dlouhý
bf69a0a89e changes requested by aleksihakli 2020-08-21 17:17:57 +03:00
Petr Dlouhý
71ee9239d9 add missing tests; refactor reset_request() 2020-08-21 17:17:57 +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
Petr Dlouhý
c3c2786d57 add reset_request helper function to internalize reset logic into django-axis 2020-08-21 17:17:57 +03:00
Aleksi Häkli
d8c6632384
Make reset for attempts and logs pluggable
Fixes #454
2019-07-11 15:31:14 +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
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
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
aec59a97bc
Fix mypy errors in the utils module
Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-22 19:55:50 +02:00
Aleksi Häkli
a0b672be6e
Cleanup imports
Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-22 19:55:49 +02:00
Aleksi Häkli
f8949ce984
Add configurable client IP attribute on requests
Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-22 19:55:47 +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
cd56631865
Refactor attempts and add NEVER_LOCKOUT_GET flag
- Move cache and cool off utility functions to the axes.utils module
- Clean up axes.attempts duplicate code in attempt and cache calculations
- Add stable implementation for AccessAttempt attribute calculation
  in the axes.attempts.get_filter_kwargs function

Fixes #398

Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-13 18:20:04 +02:00
Aleksi Häkli
77103c42fe
Add type annotations to utils module 2019-02-13 14:06:55 +02:00
Aleksi Häkli
a926e74f5d
Add check for empty tuple in get_client_str
Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-12 23:11:37 +02:00
Aleksi Häkli
0b6d84762a
Remove deprecated Six usages
Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-10 21:47:02 +02:00
Aleksi Häkli
fcef40748a
Deprecate old signature for AXES_USERNAME_CALLABLE and update documentation
Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-07 22:09:21 +02:00
Aleksi Häkli
715dedc069
Use PEP257 compliant docstrings
Unify docstring representations based on PEP 257

https://www.python.org/dev/peps/pep-0257/

Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-07 18:42:54 +02:00
Aleksi Häkli
3c2fb2b335
Improve line separator conventions
Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-07 18:42:53 +02:00
Aleksi Häkli
030810df79
Drop Python 2.7 and Python 3.4 support
Fixes #395

Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-07 17:28:26 +02:00
Aleksi Häkli
99175dc57f
Use middleware, backends, and signals for lockouts
Fixes #389

Remove monkey-patching from the application loader phase
and use the Django authentication stack for lockout signals.

Utilize custom AUTHENTICATION_BACKENDS and MIDDLEWARE with signals
with backwards compatible implementation of features.

Update documentation, configuration and migration instructions
to match the new configuration and improve the code commentation.

Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-03 16:03:30 +02:00
Aleksi Häkli
d33a55b927
Use single quotes for strings
Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-03 16:03:30 +02:00
Aleksi Häkli
7c3e21166e
Backwards compatibility fixes for credentials
Revert some of the PR changes to tests to make sure that all of the
old format function invocations work with the old and new tests.

Implement small enchancements to documentation and credentials resolving
for usability and flexibility with custom authentication backends.

Update documentation to indicate that backwards compatibility
is supported as well as the new format credentials invocations.

Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2018-12-23 02:58:53 +02:00
Benedikt Bauer
41b532c882 Fix problem with Django Admin -> It always uses username as the username field 2018-12-20 16:48:10 +01:00
Benedikt Bauer
306dd3c596 Use credentials whenever possible in favor of request.POST 2018-12-19 15:05:09 +01:00
jd
4684a1a04f Add a setting to supply a callable that can return a correct username given a request object #318 2018-05-22 14:54:45 -07:00
Aleksi Häkli
1013369ebe Clean up module imports 2018-04-21 00:33:44 +03:00
Aleksi Häkli
a6d2b16294 Remove unnecessary cache import from utils 2018-04-21 00:33:44 +03:00
Aleksi Häkli
db13d45e29 Remove unnecessary else branches from conditionals 2018-04-21 00:33:44 +03:00
Aleksi Häkli
df8feb4f69
Backport unicode string literals for Python 2.7
Fixes #328
2018-04-18 15:21:09 +03:00
Aleksi Häkli
512452e580
Add proxy precendence and count configuration
Fixes #286
2018-04-13 13:48:08 +03:00
Mark Davidoff
8580c404e3 add an authentication backend to check if user is locked out. 2018-04-06 16:01:23 -07:00
JWvDronkelaar
a88750c144 Added AXES_CACHE setting for specifying axes cache
DummyCache can be used to disable caching
2018-02-17 16:06:27 +02:00
Camilo Nova
ef7c5d5e73
Merge pull request #296 from jazzband/windows
Fix inet_pton can't be imported on windows
2018-01-19 09:11:54 -05:00
hsiao yi
2844d65092
Fix inet_pton can't be imported on windows 2018-01-15 12:54:58 +02:00
Aleksi Häkli
44cb07814e
Refactor AccessAttempt reset utility
Remove cache key deletion because cache resets
are already done in the delete_cache_after_delete
signal handler after AccessAttempt object deletion

Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2018-01-14 12:47:48 +02:00
Camilo Nova
da0c4b429a Added django-ipware 2017-12-13 14:35:19 -05:00
Camilo Nova
04f9b43221 Fixes bad import 2017-11-21 16:59:42 -05:00
Camilo Nova
ba37442252 Added support for Django signals, big code refactor and improvements 2017-11-17 17:15:34 -05:00
Jorge Galvis
f277007e46 Delete cache key in reset command line 2016-12-06 20:01:44 -05:00
Camilo Nova
08f40bc13b 🔥 Cleaning 2016-06-24 09:42:18 -05:00
Artur Mullakhmetov
dfe7d84907 Fix ISO8601 time duration format. 2016-06-20 17:40:17 +03:00
Artur Mullakhmetov
7444c4e3b3 Add iso8601 translator. 2016-05-30 15:59:48 +03:00
Camilo Nova
cf1091d411 Improved axes_reset command. Fixes #52 2013-07-27 12:16:54 -05:00