Skip to content

Commit a0c73ca

Browse files
disable Rack Attack in dev DO NOT MERGE ref #1168
1 parent 1ec29fc commit a0c73ca

File tree

1 file changed

+43
-43
lines changed

1 file changed

+43
-43
lines changed

config/initializers/rack_attack.rb

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -23,54 +23,54 @@ class Rack::Attack
2323
# Throttle all requests by IP (60rpm)
2424
#
2525
# Key: "rack::attack:#{Time.now.to_i/:period}:req/ip:#{req.ip}"
26-
throttle('req/ip', limit: 300, period: 5.minutes) do |req|
27-
req.ip # unless req.path.start_with?('/assets')
28-
end
26+
# throttle('req/ip', limit: 300, period: 5.minutes) do |req|
27+
# req.ip # unless req.path.start_with?('/assets')
28+
# end
2929

3030
# Throttle POST requests to */services by IP address
3131
#
3232
# Key: "rack::attack:#{Time.now.to_i/:period}:signups/ip:#{req.ip}"
3333

3434
# FIXME: temporarily loosened this from 2 to 50 due to
3535
# https://github.com/tosdr/edit.tosdr.org/issues/929#issuecomment-743216243
36-
throttle('services/ip', limit: 50, period: 10.minutes) do |req|
37-
if req.path.end_with?('/services') && req.post?
38-
req.ip
39-
end
40-
end
36+
# throttle('services/ip', limit: 50, period: 10.minutes) do |req|
37+
# if req.path.end_with?('/services') && req.post?
38+
# req.ip
39+
# end
40+
# end
4141

4242
# FIXME: temporarily loosened this from 5 to 50 due to
4343
# https://github.com/tosdr/edit.tosdr.org/issues/929#issuecomment-743216243
44-
throttle('points/ip', limit: 50, period: 10.minutes) do |req|
45-
match = req.path.match(/^\/points\/(\w+)/)
46-
if (req.patch? || req.put?) && !match.nil?
47-
req.ip
48-
end
49-
end
50-
51-
throttle('throttle document creation', limit: 5, period: 10.minutes) do |req|
52-
if req.path.end_with?('/documents') && req.post?
53-
req.ip
54-
end
55-
end
44+
# throttle('points/ip', limit: 50, period: 10.minutes) do |req|
45+
# match = req.path.match(/^\/points\/(\w+)/)
46+
# if (req.patch? || req.put?) && !match.nil?
47+
# req.ip
48+
# end
49+
# end
50+
51+
# throttle('throttle document creation', limit: 5, period: 10.minutes) do |req|
52+
# if req.path.end_with?('/documents') && req.post?
53+
# req.ip
54+
# end
55+
# end
5656

5757
# FIXME: temporarily loosened this from 5 to 50 due to
5858
# https://github.com/tosdr/edit.tosdr.org/issues/929#issuecomment-743216243
59-
throttle('throttle document updates', limit: 50, period: 10.minutes) do |req|
60-
match = req.path.match(/^\/documents\/(\w+)/)
61-
if (req.patch? || req.put?) && !match.nil?
62-
req.ip
63-
end
64-
end
59+
# throttle('throttle document updates', limit: 50, period: 10.minutes) do |req|
60+
# match = req.path.match(/^\/documents\/(\w+)/)
61+
# if (req.patch? || req.put?) && !match.nil?
62+
# req.ip
63+
# end
64+
# end
6565

6666
# FIXME: temporarily loosened this from 5 to 500 due to
6767
# https://github.com/tosdr/edit.tosdr.org/issues/929#issuecomment-743216243
68-
throttle('document crawling + creation for specific services', limit: 500, period: 10.minutes) do |req|
69-
match = req.path.match(/^\/documents\/(\w+)/)
70-
if req.post? && !match.nil?
71-
req.ip
72-
end
73-
end
68+
# throttle('document crawling + creation for specific services', limit: 500, period: 10.minutes) do |req|
69+
# match = req.path.match(/^\/documents\/(\w+)/)
70+
# if req.post? && !match.nil?
71+
# req.ip
72+
# end
73+
# end
7474

7575

7676

@@ -86,11 +86,11 @@ class Rack::Attack
8686
# Throttle POST requests to /login by IP address
8787
#
8888
# Key: "rack::attack:#{Time.now.to_i/:period}:logins/ip:#{req.ip}"
89-
throttle('logins/ip', limit: 5, period: 60.seconds) do |req|
90-
if req.path == 'users/sign_in' && req.post?
91-
req.ip
92-
end
93-
end
89+
# throttle('logins/ip', limit: 5, period: 60.seconds) do |req|
90+
# if req.path == 'users/sign_in' && req.post?
91+
# req.ip
92+
# end
93+
# end
9494

9595
# Throttle POST requests to /login by email param
9696
#
@@ -100,12 +100,12 @@ class Rack::Attack
100100
# throttle logins for another user and force their login requests to be
101101
# denied, but that's not very common and shouldn't happen to you. (Knock
102102
# on wood!)
103-
throttle("logins/email", limit: 5, period: 60.seconds) do |req|
104-
if req.path == 'users/sign_in' && req.post?
105-
# return the email if present, nil otherwise
106-
req.params['email'].presence
107-
end
108-
end
103+
# throttle("logins/email", limit: 5, period: 60.seconds) do |req|
104+
# if req.path == 'users/sign_in' && req.post?
105+
# # return the email if present, nil otherwise
106+
# req.params['email'].presence
107+
# end
108+
# end
109109

110110
### Custom Throttle Response ###
111111

0 commit comments

Comments
 (0)