Create conditional throttles (re-opened with further comments/use case)

Re-opened with use case clarification

Hi @ktheory.

I don't think that solution(your comment in the closed pull request )will work for us. In theory, (, we could see whether a certain email address was previously throttled

Rack::Attack.throttles['email'].get_count(....

But the problem is that in our scenario, we still want to conditionally throttle, and there does not seem to be a way around that.

Here is our use case

We have web logins that we want to lock out after a certain number of failed attempts. We might want to configure this to be such that if you enter 5 consecutive invalid passwords within a given time period (i.e an hour) we lock you out of your account (for an hour). In that scenario, we want to increment that counter after each failed login attempt (meaning that we have to process the request). After that, when another request comes in, we reject it outright until the value in redis expires.

The reason the approach above will not work is because what we really want to do is throttle based on a processed request, not just an incoming on (in our case, increment every time login fails).