Add per-user rate limits for namespace update, archive and restore
What does this MR do and why?
Applies per-user limits to updating projects and groups (120 per minute), archiving and unarchiving projects (60 per minute) and restoring projects and groups (30 per minute). Each limit is checked after authorization, so rejected requests do not count. Groups keep their existing, configurable archive limit (group_archive_unarchive_api).
The existing update_namespace_name counter is unchanged. It is not a request limit: update_to_customerdot_blocked? uses it to stop syncing group names to CustomersDot, so this MR does not count it anywhere new.
This keeps the limits for these actions consistent across the REST API, GraphQL and the web interface, in line with the existing limits on similar actions. The limits are fixed, like the existing delete limits, and are enforced behind the namespace_update_rate_limit feature flag, which is disabled by default.
References
- Rollout issue: #635775
Closes #635733
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_update_rate_limit) -
As a user with access, update a project (
PUT /api/v4/projects/:id) more than 120 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_update_rate_limit)
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist.