Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi-level throttling #504

Closed
bwillis opened this issue Nov 11, 2020 · 0 comments
Closed

Multi-level throttling #504

bwillis opened this issue Nov 11, 2020 · 0 comments

Comments

@bwillis
Copy link

bwillis commented Nov 11, 2020

👋 Hello and thanks for the great work on rack-attack!

I have a question: Is there a way to separate different levels of throttling?

The basic use-case is to have throttling before authentication and after authentication so that we don't have to perform some sort of authentication within rack-attack itself, like the solution proposed in #47.

We've used some form of the following before:

# application_controller
request.env["authenticated_user"] = current_user
raise 'Sloooow down' if Rack::Attack.throttles.any? { |_name, throttle| throttle.matched_by?(request) }

# rack_attack
throttle('throttle authenticated users', limit: 200, period: 60.seconds) do |req|
  next unless req.env["authenticated_user"]

  req.env["authenticated_user"].id
end

I'd be curious if others have looked into solving this type of problem before. Thanks!

@grzuy grzuy closed this as completed Mar 21, 2021
@rack rack locked and limited conversation to collaborators Mar 21, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Projects
None yet
Development

No branches or pull requests

2 participants