Draft: Add Rails Gitaly proxy preauthorization
What does this MR do and why?
This adds the Rails preauthorization endpoint for the read-only Gitaly proxy in Workhorse, developed alongside !253414 and !253431. Rails identifies the calling service, applies its repository policy, and returns connection details that Workhorse binds to the proxy session. Orbit is the first consumer. The workhorse_gitaly_proxy kill switch and the orbit_gitaly_proxy per-namespace rollout flag gate new preauthorizations; both are disabled by default.
References
Related to gitlab-org/orbit/knowledge-graph#1252
Screenshots or screen recordings
Not applicable. This MR has no UI changes.
How to set up and validate locally
Run the focused authorizer and feature flag definition specs. The suite passed 48 examples.
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.
Implementation notes
- Workhorse authentication runs before consumer identification, rate limiting, project lookup, the
workhorse_gitaly_proxykill switch, and consumer authorization. Exactly one registered credential header must be present. - The Orbit authorizer checks
orbit_gitaly_proxywith the project's root namespace as the actor. This keeps rollout consistent across a namespace hierarchy. Disabling either flag stops new preauthorizations while existing sessions drain. - Both flags stay out of the
gitaly_*namespace thatFeature::Gitalyforwards to Gitaly. - Orbit validates the existing Knowledge Graph JWT, checks indexing eligibility, audits repository access, and returns a ten-minute read-only policy with an explicit RPC allowlist.
- The contract fixture is
spec/fixtures/gitaly_proxy/orbit.json; !253431 copies it into Workhorse test data. The endpoint is allowlisted for writes on GET because authorization emits an audit event. - The rate limiter uses keyed
consumerandsubjectcharacteristics instead of a positional pair. Public endpoint adapters wrap private API helpers for download checks, audit, and not-found responses. The endpoint reuses the existing Workhorse preauthorization granular-token exception. - Could I ask a backend API maintainer to confirm that a registry keyed by credential header is preferable to one endpoint per consumer? The alternative would require a Workhorse route and Cells rule for every consumer.
- Could I ask an Orbit domain reviewer to review the JWT, namespace gate, RPC allowlist, and audit integration?
- Could I ask AppSec to review rejection of multiple forwarded credential headers and the default repository download check? Workhorse can strip a header named by
Connection, but the surviving credential still selects and authenticates only its own consumer.