Add rate limits for namespace and topic listing endpoints
What does this MR do and why?
Applies per-user-or-IP limits to the namespace and topic endpoints: 200 per minute for listing and 400 per minute for single lookups. The values follow the existing group and project API limits.
This keeps the limits for these REST API endpoints in line with the existing limits on similar endpoints. The limits are fixed, like the existing delete limits, and are enforced behind the namespace_topic_read_rate_limit feature flag, which is disabled by default.
References
- Rollout issue: #635778
Closes #635737
Screenshots or screen recordings
Not applicable, there are no UI changes.
How to set up and validate locally
-
In the Rails console, enable the feature flag:
Feature.enable(:namespace_topic_read_rate_limit) -
As a user with access, list topics (
GET /api/v4/topics) more than 200 times in a minute. -
Confirm that requests over the limit receive a
429response. -
Disable the feature flag and confirm the requests are no longer limited:
Feature.disable(:namespace_topic_read_rate_limit)
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist.