Skip to content

Commit

Permalink
fix: throttle contact search endpoint to prevent abuse (#8919)
Browse files Browse the repository at this point in the history
Throttle contact_search endpoint to prevent abuse/maintain db perf
ref: https://discord.com/channels/897869226579222540/899920096972111883/1206919316402999326
  • Loading branch information
vishnu-narayanan committed Feb 13, 2024
1 parent 1ce5cbe commit 96b781b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions config/initializers/rack_attack.rb
Expand Up @@ -148,6 +148,12 @@ def path_without_extentions
match_data[:account_id] if match_data.present?
end

## Prevent abuse of contact search api
throttle('/api/v1/accounts/:account_id/contacts/search', limit: 5, period: 1.minute) do |req|
match_data = %r{/api/v1/accounts/(?<account_id>\d+)/contacts/search}.match(req.path)
match_data[:account_id] if match_data.present?
end

## ----------------------------------------------- ##
end

Expand Down

0 comments on commit 96b781b

Please sign in to comment.