Add per-user rate limit for group link changes

What does this MR do and why?

Adds one limit of 200 requests per minute per user to sharing and unsharing groups and projects, and to updating or removing group links. The REST API and the web interface share the limit.

This brings these actions in line with the existing limits on similar actions.

  • The limit is a staged rule behind the group_link_rate_limit feature flag, which is disabled by default. While the flag is off, requests over the limit are logged but not blocked. With the flag on, they get 429.
  • The limit is checked after the group or project is found, so a request for something the user can't see returns 404 and doesn't count. The project share endpoints, DELETE /groups/:id/shared_projects/:project_id, Groups::GroupLinksController and Projects::GroupLinksController#update also check permission first. POST /groups/:id/share, DELETE /groups/:id/share/:group_id and Projects::GroupLinksController#destroy check permission in their services, after the limit, so a request without permission counts toward the caller's own limit. Both controllers look up the link after the limit, so an unknown link id counts too. Only the caller's own quota is spent.
  • Anonymous requests to remove a project's group link skip the limit. The controller lets them through to the service, which rejects them.
  • The rule has a contract entry in config/rate_limits/unowned.yaml, and the docs list it in the non-configurable rate limits.

Covered endpoints:

  • POST /groups/:id/share and DELETE /groups/:id/share/:group_id
  • DELETE /groups/:id/shared_projects/:project_id
  • POST /projects/:id/share and DELETE /projects/:id/share/:group_id
  • Groups::GroupLinksController and Projects::GroupLinksController update and destroy

Production traffic

Group link requests per user per minute on 2026-11-30, from the endpoints above:

Measure Value
Requests that day 84,535
Busiest minute for one user 637
Most successful shares by one user in a minute 161
Users over 200 in a 6-hour window 1 or 2
Requests that 200 would have rejected about 10,700
Successful shares in the minutes over 200 0

Most of the volume is automation sharing projects that are already shared. In one 6-hour window, 24,932 of 26,361 POST /projects/:id/share requests returned 409, each costing about 200 ms. The first proposal of 20 per minute would also have blocked real bulk sharing, so the limit sits above the busiest real use.

References

  • Rollout issue: #635773
  • Closes #635731

Screenshots or screen recordings

Not applicable, there are no UI changes.

How to set up and validate locally

  1. As a user who can share a project, share it with a group (POST /api/v4/projects/:id/share) more than 200 times in a minute.

  2. With the flag disabled, the requests aren't blocked. log/api_json.log shows applimiter_group_link_mutation:limit_group_link_changes_by_user_log in rate_limit_state.

  3. Enable the feature flag in the Rails console:

    Feature.enable(:group_link_rate_limit)
  4. Repeat the requests. Requests over the limit receive a 429 response.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Shubham Kumar

Merge request reports

Loading
Loading