@@ -23,54 +23,54 @@ class Rack::Attack
23
23
# Throttle all requests by IP (60rpm)
24
24
#
25
25
# 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
29
29
30
30
# Throttle POST requests to */services by IP address
31
31
#
32
32
# Key: "rack::attack:#{Time.now.to_i/:period}:signups/ip:#{req.ip}"
33
33
34
34
# FIXME: temporarily loosened this from 2 to 50 due to
35
35
# 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
41
41
42
42
# FIXME: temporarily loosened this from 5 to 50 due to
43
43
# 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
56
56
57
57
# FIXME: temporarily loosened this from 5 to 50 due to
58
58
# 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
65
65
66
66
# FIXME: temporarily loosened this from 5 to 500 due to
67
67
# 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
74
74
75
75
76
76
@@ -86,11 +86,11 @@ class Rack::Attack
86
86
# Throttle POST requests to /login by IP address
87
87
#
88
88
# 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
94
94
95
95
# Throttle POST requests to /login by email param
96
96
#
@@ -100,12 +100,12 @@ class Rack::Attack
100
100
# throttle logins for another user and force their login requests to be
101
101
# denied, but that's not very common and shouldn't happen to you. (Knock
102
102
# 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
109
109
110
110
### Custom Throttle Response ###
111
111
0 commit comments