* Remove Connect
* Remove more Connect specs
* Remove a lot more Connect code
* 🚮
* It all has to go
* Explicitly add httpclient
* Update application layout
* Remove messages association from User
* Start fixing specs
* reintroduce util function and refactor references
* Remove Connect Cypress test
* Fix more specs
* Remove Connect from listings
* Ignore contact_via_connect column on listings
* Remove contact_via_connect usages
* Ignore mod_chat_channel_id on tags
* Drop Connect tables
* Remove email_connect_messages from user notification settings
* Re-add httpclient 2.8.3
This was mistakenly removed as a merge conflict
* Don't need to exclude removed chat channel file
* Remove unneeded style for chat channels
* Remove unneeded channel list prop type
* Remove chat channels index/connect-link from getPageEntries
* Re-add comment from httpclient in Gemfile
* Remove connect references from mailers
Tag Moderators no longer have a chat channel
No longer will users be notified about new messages (there won't be
any)
No longer will users be notified about channel invites (you can't
invite anyone anymore)
* Don't configure Pusher and remove PUSHER_* from .env_sample
since it's removed from gemfile, the Pusher constant will not resolve, if this is
configured in the environment variables we'll fail to boot.
Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
Co-authored-by: Dan Uber <dan@forem.com>
50 lines
1.5 KiB
Ruby
50 lines
1.5 KiB
Ruby
Rack::Attack.throttled_response_retry_after_header = true
|
|
|
|
module Rack
|
|
class Attack
|
|
throttle("search_throttle", limit: 5, period: 1) do |request|
|
|
if request.path.starts_with?("/search/")
|
|
track_and_return_ip(request.env["HTTP_FASTLY_CLIENT_IP"])
|
|
end
|
|
end
|
|
|
|
throttle("api_throttle", limit: 3, period: 1) do |request|
|
|
if request.path.starts_with?("/api/") && request.get?
|
|
track_and_return_ip(request.env["HTTP_FASTLY_CLIENT_IP"])
|
|
end
|
|
end
|
|
|
|
throttle("api_write_throttle", limit: 1, period: 1) do |request|
|
|
if request.path.starts_with?("/api/") && (request.put? || request.post? || request.delete?)
|
|
Honeycomb.add_field("user_api_key", request.env["HTTP_API_KEY"])
|
|
ip_address = track_and_return_ip(request.env["HTTP_FASTLY_CLIENT_IP"])
|
|
if request.env["HTTP_API_KEY"].present?
|
|
"#{ip_address}-#{request.env['HTTP_API_KEY']}"
|
|
elsif ip_address.present?
|
|
ip_address
|
|
end
|
|
end
|
|
end
|
|
|
|
throttle("site_hits", limit: 40, period: 2) do |request|
|
|
track_and_return_ip(request.env["HTTP_FASTLY_CLIENT_IP"])
|
|
end
|
|
|
|
throttle("tag_throttle", limit: 2, period: 1) do |request|
|
|
if tag_request?(request)
|
|
track_and_return_ip(request.env["HTTP_FASTLY_CLIENT_IP"])
|
|
end
|
|
end
|
|
|
|
def self.track_and_return_ip(ip_address)
|
|
return if ip_address.blank?
|
|
|
|
Honeycomb.add_field("fastly_client_ip", ip_address)
|
|
ip_address.to_s
|
|
end
|
|
|
|
def self.tag_request?(request)
|
|
request.path.include?("/t/")
|
|
end
|
|
end
|
|
end
|