Draft: Backport of 'Count CI job token Git requests against the user's rate limit'

What does this MR do and why?

This MR backports the fix for https://gitlab.com/gitlab-org/gitlab/-/work_items/634147 to 19.4.

Git over HTTP requests that authenticate with a CI job token (gitlab-ci-token:<token>) skip throttle_authenticated_git_http. The rate limiter never resolves the job's user on Git paths, so these requests are only counted per IP. One bot account on a GitLab Dedicated instance drove about 955 req/s this way for weeks (S1, infradev, SLO missed). This change counts the requests against the job's user.

GitLab Dedicated needs it on 19.4. 19.4 lacks two earlier changes that the fix builds on, so this MR carries the changes of three merged master MRs, in order:

  1. !259720 (merged) "Count CI job tokens sent as basic auth or bearer against the job user".
  2. !261357 (merged) "Treat Git info/refs without .git as Git over HTTP in rate limits".
  3. !263309 (merged) "Count CI job token Git requests against the user's rate limit".

It replaces !272099 (closed), whose danger-review failed on commit messages with short references.

Differences from master

  • ee/lib/ee/gitlab/auth/request_authenticator.rb (259720): already on 19.4, so no change.
  • ee/lib/ee/gitlab/rate_limit/plan_rules.rb (261357): hunk dropped. The 19.4 unauthenticated rules have no git_http: false match to remove.
  • Labkit nre matcher (261357): not used. The 19.4 labkit gem rejects it (unknown type key :nre). throttle_unauthenticated_web keeps git_http: false and the git_http fact stays. git_path? still uses the new anchored repository_git_http_route_regex, so info/refs without .git is still classed as Git.

Specs

Applied: path_regex_spec, request_authenticator_spec, classified_request_spec, limiters_spec, throttle_registry_spec, rack_attack/request_spec, rack_attack_shared_context, labkit_rack_rate_limit_spec (CE), rack_attack_global_spec, and the EE request_authenticator_spec. The specs were applied as text edits and have not been run locally.

Not applied:

  • spec/requests/labkit_rack_rate_limit_git_ci_job_token_spec.rb: does not exist on 19.4.
  • EE plan_rules_spec: covers the dropped hunk.
  • EE labkit_rack_rate_limit_spec job token contexts: anchors differ on 19.4.
  • JWT job token and token-size contexts in request_authenticator_spec: 19.4 has neither Ci::JobToken::Jwt nor MAX_JOB_TOKEN_SIZE_BYTES.

Status

  • The earlier pipeline failed 20 limiters_spec examples on the nre error above. That is fixed in the latest commit, and the pipeline for it is still running.
  • The remaining danger-review output is warnings only (short references in older commit messages, no milestone, no EE: true trailer).
  • This MR is a draft until the pipeline is green.

References

MR acceptance checklist

  • This MR is backporting a bug fix, documentation update, or spec fix, previously merged in the default branch.
  • The MR that fixed the bug on the default branch has been deployed to GitLab.com. (Merged 2026-11-16: confirm the deploy before merging.)
  • The MR title is descriptive (e.g. "Backport of 'title of default branch MR'"). This is important, since the title will be copied to the patch blog post.
  • Required labels have been applied to this merge request
  • This MR has been approved by a maintainer (only one approval is required). This touches authentication, so ask an Authentication maintainer.
  • Ensure the e2e:test-on-omnibus-ee job has succeeded, or if it has failed, investigate the failures. If you determine the failures are unrelated, you may proceed.

Note to the merge request author and maintainer

If you have questions about the patch release process, please:

Edited by Navjot Bansal

Merge request reports

Loading
Loading