Commit graph

51 commits

Author SHA1 Message Date
Aleksi Häkli
d59a289407 Suppress mypy type errors
Update Mypy Python version to 3.14
2026-02-11 22:14:31 +02:00
kuldeepkhatke
01ccf5b213 Updated get_individual_attempt_expiry() func placement & renamed to get_attempt_expiration() 2025-07-05 16:19:19 +03:00
kuldeepkhatke
0fd9ccd1d4 Added individual attempt expiry feature 2025-07-05 16:19:19 +03:00
nefrob
bd3b56237d refactor: move db accessing attempt fns to handler methods 2025-05-10 13:46:09 +03:00
parul-aro
0115648a1d feat(cleanup): allow credentials in cleanup method 2025-04-23 11:54:17 +03:00
Bruno Alla
8ed0d82384 refactor: remove attempt_time parameter
As we pass down the whole request, we no longer need to extract the axes_attempt_time anymore.

This is a potential breaking change, but the impacted functions are not part of the documented API.
2024-10-02 20:15:31 +03:00
Bruno Alla
a304380853 feat: pass down the request in a few more places 2024-10-02 20:15:31 +03:00
Maksim Zayakin
8d4a0aa052 chore!: pass request and credentials to get_client_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
382468cef4 Add type hint for request variables 2022-05-02 18:21:03 +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
Aleksi Häkli
b6b26e492f Optimize imports as part of cleanup round 2021-01-07 18:23:33 +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ý
bf69a0a89e changes requested by aleksihakli 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
Aleksi Häkli
34d3b5a1f5
Pluggable user account whitelisting (#549)
Fixes #536
2019-12-29 23:43:55 +02:00
Aleksi Häkli
dbc7f54ac5
Update whitelisting documentation. 2019-12-29 16:53:41 +02:00
Aleksi Häkli
93bb73552e
Upgrade CI tooling to use automatic code formatting 2019-09-28 19:28:17 +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
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
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
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
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
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
6d83901031
Refactor attempt and handler implementations
Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-13 20:39:44 +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
8c73eed726
Introduce gradual typing with mypy 2019-02-13 01:14:26 +02:00
Aleksi Häkli
911de8f347
Refactor is_user_lockable
Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-13 00:58:17 +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
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
60f2a8ed71
Merge pull request #392 from jazzband/development
Remove AccessAttempt.trusted flag and clean up CI setup and README
2019-01-14 15:22:56 +02:00
Camilo Nova
e1bfc7d1fe Removed duplicated code 2019-01-11 12:43:11 -05:00
Aleksi Häkli
c7e79aeaf2 Remove unused AccessAttempt.trusted flag
Fixes #344
2018-12-25 18:55:15 +01: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
2e9754914b Use get_client_username instead of manual username lookup for cache key 2018-12-19 16:33:32 +01:00
Benedikt Bauer
306dd3c596 Use credentials whenever possible in favor of request.POST 2018-12-19 15:05:09 +01:00
Aleksi Häkli
8204032102
Add Python 3.7 to supported versions
Add Django 2.1 to the test matrix

Fixes #371

Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2018-12-10 19:48:46 +02:00
Arjen
ac4ab22183
Added setting to reset failed attempts on successful login. 2018-10-26 14:45:06 +02: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
f73ff57b6f
Merge pull request #332 from EvaSDK/unboundlocalerror-user-agent
Fix call to undefined variable ua in _get
2018-04-20 23:33:27 +03:00
Gilles Dartiguelongue
488a940c3e
Properly handle User-Agent when AXES_ONLY_USER_FAILURES is set
Fixes access to undefined variable in _query_user_attempts and
respects documentation of the settings.
2018-04-20 15:16:06 +02:00
Gilles Dartiguelongue
84b887902d
Simplify cooloff time type check 2018-04-20 13:55:27 +02: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
c89a48f2aa switch get_ip calls to use newer non-deprecated get_client_ip method 2018-03-13 09:39:19 -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
da0c4b429a Added django-ipware 2017-12-13 14:35:19 -05:00
Camilo Nova
d55af8e966 Improve tests and fix global lockout. Fixes #261 2017-11-17 18:12:30 -05:00