rack / rack-attack

Rack middleware for blocking & throttling
MIT License
5.57k stars 337 forks source link

How do you add a rule without restarting the app? #660

Closed alexsmartens closed 5 months ago

alexsmartens commented 5 months ago

Somewhat related to https://github.com/rack/rack-attack/issues/241.

A dynamically added rule is being ignored, steps to reproduce:

Additional info from the console:

> Rails.application.middleware.include? Rack::Attack
=> true

> Rack::Attack.blocklists
=>
{"blocklist from localhost"=>
  #<Rack::Attack::Blocklist:0x000000011327da80
   @block=#<Proc:0x000000011327d9e0 (irb):17>,
   @name="blocklist from localhost",
   @type=:blocklist>}
alexsmartens commented 5 months ago

Everything works:

My mistake was trying to add a rule in console. 🤦‍♂️ When modifying Rack::Attack rules in the console, these changes are not reflected in the running server because the console and server operate as separate processes with their own environments.