jazzband / django-axes

Keep track of failed login attempts in Django-powered sites.
MIT License
1.49k stars 346 forks source link

feat: pass request to `AXES_COOLOFF_TIME` callback #1222

Closed browniebroke closed 2 days ago

browniebroke commented 1 month ago

What does this PR do?

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:

Past references of this:

This PR should be backwards compatible with previous behaviour: if the AXES_COOLOFF_TIME is a callable that takes no argument, it will be called without parameters.

Before submitting

browniebroke commented 1 month ago

Looks like the test failures are the same as another PR (https://github.com/jazzband/django-axes/pull/1221) and they don't look related to my change so I'm going to ignore them for this. Any idea how to fix them? I'll try to take a look if I find time

aleksihakli commented 1 week ago

Looks like the test failures are the same as another PR (#1221) and they don't look related to my change so I'm going to ignore them for this. Any idea how to fix them? I'll try to take a look if I find time

There was a failing test that was produced by a change in the Django upstream implementation that limits header sizes. I updated the test, if you rebase this PR changeset on top of jazzband/django-axes repository master branch the test should be fixed in this branch as well.

browniebroke commented 3 days ago

I've pushed more updates, trying to me more granular with my commits. I didn't rebase anything yet to help you keep track of the changes you already reviewed, and the new ones I've added. I can rebase them when/if you want me to.

browniebroke commented 2 days ago

I think it's all done now. Let me know if I should update the changelog with some "unreleased changes".

aleksihakli commented 2 days ago

Yeah looks good to me, thank you 👍 I'll merge and bake a changelog and a release for this.

aleksihakli commented 2 days ago

Hey @browniebroke I made a release version 7.0.0 with associated changelog and notes for upgrading, do let me know if there's anything missing.

I also missed your earlier comment regarding e.g. SSO logins, please check it out and let me know if you have any thoughts on that.

Cheers for the good PR 👍

browniebroke commented 2 days ago

Thanks a lot for the quick feedback and very prompt release!