jsocol/django-ratelimit

Alias function for is_ratelimited

Open

#308 aperta il 30 ott 2023

Vedi su GitHub
 (2 commenti) (0 reazioni) (0 assegnatari)Python (180 fork)batch import
help wanted

Metriche repository

Star
 (904 star)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

Hey,

Is_ratelimited is a great function, but the name is quite missleading for incrementing. You'd expect it only to be a boolean, but yet it can also increment. That's great, but I feel we should have also a new function like increment_ratelimit or some sort of increment function which is just a function rather than decorator, that allows you to increment whenever.

At the moment I want to only increment the ratelimit when the user does an unsuccessful login attempt. So i have

is_ratelimited(
                request, group="login_incorrect", key="ip", rate="5/5m", increment=True
)

But instead of that, i'd quite like something like:

increment_ratelimit(request, group="login_incorrect")

Instead i've created my own function that just does the same thing, but it'd be nice to see this in the official version.

Or I may have just missed it 🤷‍♂️

Happy to hear opinions, let me know if i'm just being blind :)

Guida contributor