## Description Consolidates all widget API throttles under the single `ENABLE_RACK_ATTACK_WIDGET_API` flag, each with its own independent kill switch and configurable limit, with defaults tuned from real prod traffic. Fixes https://linear.app/chatwoot/issue/INF-83 Related to https://linear.app/chatwoot/issue/INF-77 Parent flag stays default-true; installs that disabled it keep today's behavior (no widget throttling). Each endpoint adds `ENABLE_RACK_ATTACK_WIDGET_<X>` + `RATE_LIMIT_WIDGET_<X>`. - **conversations create**: keyed on (IP, website_token), 30/min (was per-IP 6/12h) - **messages create**: new throttle, (IP, website_token), 60/min (was unthrottled) - **contact update**: fixes a dormant bug. `resource :contact` gives the singular URL `/api/v1/widget/contact`, but the throttle checked plural `/api/v1/widget/contacts` so it never fired. Now active (60/1h per IP). - **widget load**: 5 to 200/1h, tuned from prod (real per-IP loads top out ~50/hr; the higher tail is crawlers/scrapers) - **transcript**: 5/1h retained Token precedence: the (IP, website_token) throttles read `website_token` via ActionDispatch (query wins), matching the controller, so a body-supplied token cannot fork the throttle bucket. ## Type of change - [x] Bug fix (non-breaking change which fixes an issue) ## How Has This Been Tested? `ruby -c` and rubocop clean. No spec added, matching this file's existing no-spec convention for throttles. --------- Co-authored-by: Sony Mathew <2040199+sony-mathew@users.noreply.github.com>
11 KiB
11 KiB