Repository navigation
Releases
gitgate v0.1.0
The first release.
- A git smart-HTTP gateway for GitHub (github.com or GitHub Enterprise Server):
info/refsandgit-upload-pack/
git-receive-pack, streamed in both directions, with the upstream credential added by gitgate. Git LFS and (opt-in) a
GitHub API leg are proxied too; web pages are not. - Two modes, chosen by the URL (
/managed/<owner>/<repo>.git,/unmanaged/...; a URL that names none takes
GITGATE_DEFAULT_MODE, unmanaged unless set). Managed does everything the credential may. Unmanaged fetches and pushes
ordinary branches: its commands are read before a byte goes upstream, and a push that touches the default branch, a protected
branch (main,master,production,release/*,releases/*by default), a tag or anything outsiderefs/heads/is
refused whole, with git's own per-ref report. - Credentials: a personal access token (
GITGATE_TOKENor a file re-read every minute) or a GitHub App, whose installation
tokens are minted and renewed in memory. - Callers are admitted per mode by address (IPs and CIDRs, with
X-Forwarded-Forhonoured only from trusted proxies) or by a
secret sent as a Basic password or Bearer token. With nothing configured nobody is admitted. /healthz,/readyzand a small Prometheus/metrics.- A static musl Docker image on distroless, and release builds (Linux x86_64 and aarch64, macOS arm64 and x86_64) with a
signedSHA256SUMSand aninstall.sh.
Added since the pre-release builds
-
Named callers (
GITGATE_CALLERS_FILE): one identity per agent or machine, recognised by a SHA-256 of its secret and/or
its address, with the modes it may use. Revoke one by removing it or settingrevoked = true. The mode-wide*_FROMand
*_SECRETsettings keep working as callers namedmanagedandunmanaged. Caller names appear in logs, metrics and the
audit log. -
The real push outcome: gitgate reads the upstream's report-status (plain or side-band) from a copy of the response as it
streams, so a ref GitHub rejects (branch protection, rulesets, push protection) is logged and counted as rejected instead of
as a200. -
Push audit log: one JSON record per push (caller, address, mode, repository, each ref old -> new, gitgate's decision, the
upstream's per-ref result, bytes, duration, request id), in the log undergitgate::auditand optionally in
GITGATE_AUDIT_FILEand a signedGITGATE_AUDIT_WEBHOOK. Managed pushes are recorded too. -
Request ids:
X-Request-Idis accepted when plain, generated otherwise, returned, and logged. -
Refusals say what to do instead, and a push refused because the default branch could not be learned is now refused in
git's own per-ref report rather than with a bare503. -
A ref advertisement refused with
401/404right after an installation token was minted is asked again (0.5, 1, 2, 4 s,
minting anew once), because GitHub can take a few seconds to honour a new token. -
GitHub App settings
GITGATE_APP_PERMISSIONS_FETCH,GITGATE_APP_PERMISSIONS_UNMANAGED,
GITGATE_APP_PERMISSIONS_MANAGED(the permissions of each purpose's token) andGITGATE_APP_TOKEN_SCOPE(repository,
the default, orinstallationfor organizations that hit GitHub's mint rate limit). gitgate refuses to start if
GITGATE_APP_PERMISSIONS_UNMANAGEDnamesworkflows. -
Agent branch allowlist (
GITGATE_UNMANAGED_BRANCHES, per callerbranches): e.g.agent/{caller}/*; fails closed. -
Repository allowlists per mode (
GITGATE_MANAGED_REPOS,GITGATE_UNMANAGED_REPOS) and per caller (repos); a
repository outside the list answers404. -
Shallow pushes are accepted in unmanaged mode (
shallowlines before the commands), so--depth 1clones can push. -
Branch ownership (
GITGATE_UNMANAGED_BRANCH_OWNERSHIP,GITGATE_STATE_DIR): a branch is claimed by the caller whose
push creates it, atomically and before the push is forwarded; other callers cannot update it. State is an embedded redb file. -
GITGATE_UNMANAGED_ALLOW_DELETES=own: deletes only of the caller's own branches. -
Read-only switch for unmanaged pushes (
GITGATE_UNMANAGED_READ_ONLY, per callerread_only). -
Report-only rules (
GITGATE_POLICY_EVALUATE): new rules log and count would-be refusals without refusing. -
Per-caller rate limits (
GITGATE_RATE_LIMIT,GITGATE_RATE_BURST, per callerrate_per_minute):429with
Retry-After. -
The GitHub API leg (
GITGATE_API_LEG=true):/api/v3/...and/api/graphql, laid out as GitHub Enterprise Server,
so stockghworks through gitgate (GH_HOST,GH_ENTERPRISE_TOKEN; verified with gh 2.106.0gh pr create). Unmanaged
callers may read their repositories, open draft pull requests from branches they may push, comment, and edit their own
pull requests, with App tokens pinned to the repository that never write contents or workflows; GraphQL is parsed
(fragments, variables) and checked operation by operation. Managed callers pass through. Writes are audited
("kind":"api"). Thetoken <secret>authorization scheme is accepted for callers. -
Reload on
SIGHUP:.env, the callers file and the TLS files are read again and applied to new requests (revoke a
caller, switch unmanaged pushes off, change policy) without a restart; caches, metrics, buckets and the ledger carry over. -
Approve-then-repush holds (
GITGATE_HOLDS,GITGATE_HOLD_RULES): an unmanaged push refused by a holdable rule
(protected branches by default) gets a hold id bound to the exact update; a managed caller approves it with
POST /holds/<id>/approveand the same push then lands once. -
Richer metrics: request and upstream latency histograms by mode and service, bytes up and down, upstream status
classes, token mints and failures, default-branch cache hits, and GitHub's remaining rate limit as a gauge. -
Fetch cache (
GITGATE_CACHE_DIR,GITGATE_CACHE_MAX_BYTES): a bare mirror per repository serves clones and fetches
(protocol v0/v1 and v2, shallow, gzipped requests) through a localgit upload-pack. Ref discovery andls-refsstill go
upstream; before each fetch gitgate asks the upstream for the branches and tags, updates the mirror when they differ (one
git fetch --pruneat a time per repository), and serves only wants the upstream just advertised. Anything else, and any
failure, goes upstream as before. Least recently used mirrors are evicted over the size limit. NeedsgitonPATH
(a newcacheDockerfile target has it; the default image is unchanged). New countersgitgate_cache_requests_total,
gitgate_cache_updates_total,gitgate_cache_update_milliseconds_total,gitgate_cache_evictions_total. -
Built-in TLS (
GITGATE_TLS_CERT_FILE,GITGATE_TLS_KEY_FILE): rustls, HTTP/2 by ALPN, certificate reloaded when the
files change, handshakes in each connection's own task. -
Git LFS: the batch API (
POST .../info/lfs/objects/batch) and the locks API are proxied with gitgate's credential and
admitted like git, so LFS repositories clone and push through gitgate. A download takes the fetch token, an upload and
the locks API the mode's push token. In unmanaged mode,GITGATE_UNMANAGED_LFS_UPLOAD=falserefuses uploads and
GITGATE_LFS_MAX_OBJECT_BYTESrefuses objects over a size, each with a message git-lfs prints. Each upload batch is an
audit record (kind: "lfs_batch");gitgate_lfs_batches_total{mode,operation,decision}counts batches.
GITGATE_LFS_PROXY_TRANSFERS=truealso streams the object transfers through gitgate (/lfs-transfer/<id>), for clients
that can reach only gitgate. -
Pack content policy (
GITGATE_CONTENT_POLICY, off by default): an unmanaged push is spooled to disk
(GITGATE_SPOOL_DIR, at mostGITGATE_SPOOL_MAX_BYTES), indexed against a bare mirror of the repository, and its new
commits checked before it goes upstream: no changes toGITGATE_CONTENT_DENY_PATHS(default.github/workflows/*,
.github/actions/*; a merge counts only what differs from every parent), onlyGITGATE_CONTENT_ALLOW_PATHSwhen set, a
GITGATE_CONTENT_REQUIRE_TRAILERon every commit, no blob overGITGATE_CONTENT_MAX_BLOB_BYTES. Refusals are in git's
per-ref report and say what to do; a push that cannot be checked is refused;GITGATE_POLICY_EVALUATE=contentruns it
report-only. NeedsgitonPATH. New metricsgitgate_content_checks_total{result}and
gitgate_content_check_milliseconds_total.
Breaking, for deployments of the pre-release builds
- Unmanaged mode refuses branch deletes by default.
GITGATE_UNMANAGED_ALLOW_DELETESnow defaults tofalse(it was
true). Set it totruefor the old behaviour, orownto let agents delete only their own branches.
Changed since the pre-release builds
-
.envis no longer copied into the process environment; it is read as an overlay (the environment still wins), so it can
be read again onSIGHUP.GITGATE_LOGset only in.envnow works too. -
GitHub App tokens are now per repository and per purpose by default. Each token names the one repository it is for and
only its purpose's permissions: fetches{"contents":"read","metadata":"read"}, unmanaged pushes
{"contents":"write","metadata":"read"}(noworkflows, so GitHub itself refuses an unmanaged push that touches
.github/workflows/), managed pushesGITGATE_APP_PERMISSIONS_MANAGED, elseGITGATE_APP_PERMISSIONS, else everything
the installation has.GITGATE_APP_PERMISSIONStherefore no longer narrows fetches and unmanaged pushes. Tokens are
cached per repository and purpose (at most 2,000) and a slow mint no longer holds up other repositories. Check before
upgrading: the App must still have the permissions requested, at least Contents read/write and Metadata read (and
whatever the managed setting names); expect up to three mints per active repository per hour instead of one per
installa...