@@ -46,12 +46,21 @@ class Rack::Attack
46
46
{ controller : "multifactor_auths" , action : "update" }
47
47
]
48
48
49
+ protected_api_key_actions = [
50
+ { controller : "api/v1/api_keys" , action : "show" } ,
51
+ { controller : "api/v1/api_keys" , action : "create" } ,
52
+ { controller : "api/v1/api_keys" , action : "update" } ,
53
+
54
+ # not technically API key, but it's the only other action that uses authenticate_or_request_with_http_basic
55
+ # and we don't want to make it easy to guess user passwords (or figure out who has mfa enabled...)
56
+ { controller : "api/v1/profiles" , action : "me" }
57
+ ]
58
+
49
59
protected_api_mfa_actions = [
50
60
{ controller : "api/v1/deletions" , action : "create" } ,
51
61
{ controller : "api/v1/owners" , action : "create" } ,
52
- { controller : "api/v1/owners" , action : "destroy" } ,
53
- { controller : "api/v1/api_keys" , action : "show" }
54
- ]
62
+ { controller : "api/v1/owners" , action : "destroy" }
63
+ ] + protected_api_key_actions
55
64
56
65
protected_ui_owners_actions = [
57
66
{ controller : "owners" , action : "resend_confirmation" } ,
@@ -162,10 +171,8 @@ def self.protected_route?(protected_actions, path, method)
162
171
User . normalize_email ( req . params [ 'session' ] [ 'who' ] ) . presence if protected_route && req . params [ 'session' ]
163
172
end
164
173
165
- protected_api_key_action = [ { controller : "api/v1/api_keys" , action : "show" } ]
166
-
167
174
throttle ( "api_key/basic_auth" , limit : REQUEST_LIMIT , period : LIMIT_PERIOD ) do |req |
168
- if protected_route? ( protected_api_key_action , req . path , req . request_method )
175
+ if protected_route? ( protected_api_key_actions , req . path , req . request_method )
169
176
action_dispatch_req = ActionDispatch ::Request . new ( req . env )
170
177
who = ActionController ::HttpAuthentication ::Basic . user_name_and_password ( action_dispatch_req ) . first
171
178
User . normalize_email ( who ) . presence
0 commit comments