rackattack

sync rack request and response

我的未来我决定 提交于 2019-12-13 21:26:44
问题 In my rails 4 app I'd like to response with html both for html and js request. At the moment when the request is html type the rendering works fine, but when the request is js then the html file doesn't get rendered on the screen (although in the command line it says it's rendered). There are different scenarios for limiting requests so the throttle code can be triggered by html POST and js POST request as well. Rack::Attack.throttle(key, limit: from_config(key, :limit), period: from_config

Rack-Attack: Array of IP addresses

本秂侑毒 提交于 2019-12-06 09:43:19
问题 I'm trying to create an array of IP addresses so that when the application is ran Rack-Attack can identify from the set of IP addresses that are allowed to access the application. So what I have done is as followed: a = "127.0.0.1" Rack::Attack.blacklist('allow from localhost') do |req| p "#{'127.0.0.1' == req.ip} " a != req.ip end The above works, so localhost can access the application but I have tried the following below which seems to not work what so ever: a = "127.0.0.1", "1.2.3.4" Rack

Rack-Attack: Array of IP addresses

故事扮演 提交于 2019-12-04 16:44:34
I'm trying to create an array of IP addresses so that when the application is ran Rack-Attack can identify from the set of IP addresses that are allowed to access the application. So what I have done is as followed: a = "127.0.0.1" Rack::Attack.blacklist('allow from localhost') do |req| p "#{'127.0.0.1' == req.ip} " a != req.ip end The above works, so localhost can access the application but I have tried the following below which seems to not work what so ever: a = "127.0.0.1", "1.2.3.4" Rack::Attack.blacklist('allow from localhost') do |req| a.select{|x| x != req.ip}.join("") end Can someone