forge

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 29, 2026 License: BSD-3-Clause Imports: 0 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

forge

go-vcs forge

Go Reference License CI Landing Docs

Light, secure Git forge: hosting, web UI, admin gRPC, Actions runners via GARM.

Status: v0.1.0, milestone 4 (push over SSH, see below) complete. The admin gRPC API and its CLI, read-only git clone and git fetch over SSH and smart HTTP (protocol v2), OIDC sign-in through the go-authn bridge, and a read-only web UI are implemented. With --web-listen and --repos-root the web listener serves, for each repository the viewer may read (owner, or exported with git-daemon-export-ok; anything else is a 404), the tree, blob, raw file, commit log and commit diff pages; every git command runs with a deadline, a bounded output and a bounded concurrency. git push over SSH is served with an in-process policy (permission, protected refs, atomic updates, size limits). Pull requests are still design only. Read docs/design.md for the goals, the security invariants, how the work is split between go-vcs/forge, go-vcs/gitproto and go-vcs/actions, and the milestones.

docs/agent-vcs.md designs (not yet implemented) an agent-oriented layer on top of git: writes and reads without a clone, change ids stable across rebase, merges only on a CI verdict for the exact merged commit, path-scoped leases, one local daemon per machine, and atomic changes across repositories. Git stays the storage and interchange format. The first milestone is the local daemon against GitHub, before the forge hosts anything.

Administration with a FIDO2 key

Two binaries, both pure Go (CGO_ENABLED=0):

  • forge serve runs the admin API (gRPC over TLS 1.3) and the local enrolment socket.
  • forgectl administers it: enrol, credentials list|revoke, users create|list|disable, identities bind|list|unbind.

Every change is signed by the administrator's hardware key, one touch and one user verification per call, bound to the TLS connection and to a single-use server nonce. Reads open a short session with one touch. The byte layout and the list of refusals are in docs/admin-api.md.

forge serve --db forge.db --tls-cert cert.pem --enrol-socket /run/forge/enrol.sock \
    --rp-id forge.example --aaguid <model AAGUID> --mds-blob blob.jwt
forgectl enrol --socket /run/forge/enrol.sock --rp-id forge.example --name laptop-key
forgectl --server forge.example:8443 --rp-id forge.example --credential-id <hex> users create alice

The TLS key is read from --tls-key or the systemd credential tls.key; no secret is accepted on the command line, in the environment or in a URL. Enrolment is possible only over the Unix socket, and only for a key whose attestation chains to the FIDO MDS3 blob (verified at start) and whose AAGUID is on the allowlist; there is no switch to relax either.

Clone and fetch over SSH

ssh-keygen -t ed25519 -N '' -f ssh_host_key        # the host key is never generated
forge serve ... --ssh-listen :2222 --ssh-host-key ssh_host_key --repos-root /srv/repos
git clone ssh://git@forge.example:2222/alice/project.git

Repositories are bare, at <repos-root>/<owner>/<name>.git. A user authenticates with a public key registered through the admin API; only git-upload-pack (protocol v2) and git-receive-pack run (no shell, pty, forwarding or agent). A reader must own the repository, be one of its collaborators, or the repository must contain a git-daemon-export-ok file; a missing and a forbidden repository answer alike.

Push over SSH

forgectl ... repo add-collaborator alice/project bob
forgectl ... repo protect alice/project refs/heads/main
forgectl ... repo protect alice/project 'refs/tags/*'
git push ssh://git@forge.example:2222/alice/project.git main

The owner and the collaborators may push; a reader who is neither gets permission denied. The policy runs in the forge process, with no hook.

What is refused:

  • a protected ref (an exact name, or a prefix ending in /*) cannot be deleted or rewritten, only fast-forwarded; the branch HEAD points to cannot be deleted; a branch must point to a commit;
  • a new ref name that folds (case, Unicode form) to a protected or existing ref, that has a component ending in .lock (git holds refs/heads/main as main.lock while it updates it, and main.LOCK is that file on a case-insensitive file system), that holds a default-ignorable code point (U+200C, U+200D, U+FEFF and the like) or that is not ASCII; deleting an existing ref of that kind stays allowed;
  • a ref outside refs/heads/* and refs/tags/*;
  • an object a new tip needs that is missing (connectivity is checked in a quarantine, so a refused push leaves no object behind), and a tree entry with a backslash in its name; received objects are also checked by git (--strict).

An atomic push applies all its commands or none. Each ref update is a compare-and-swap under a per-repository lock, so two pushes racing on one ref cannot both win. An SSH connection lasts at most one hour and ends when its account is disabled.

Bounds, all refused cleanly. Per push: 100 commands, 1 KiB ref names and 1 MiB of commands. Per pack: --push-max-pack-bytes (512 MiB) and --push-max-objects (1,000,000). One byte budget per push charges every inflated byte: 1 GiB in total, 100 MiB for one object or one delta result. Delta streams are charged for what they produce, and the bases of a thin pack are charged twice their size (read from the repository before git unpacks anything). At start the forge removes the stale ref lock files a killed git left in the repositories it serves. The session limits of the clone path also apply.

Not done yet: there is no global cap across concurrent pushes (each push is bounded, 64 at once at the defaults are not); flooding a push with absent thin-pack bases costs about 28 s of CPU per million ids; the tree check has no deadline of its own. The list is in forge#26.

git-receive-pack is not served over HTTP: HTTP here is anonymous and read-only, and a push needs an account, so the answer names SSH. The access data is administered through the admin API (docs/admin-api.md). The host key is read from --ssh-host-key or the systemd credential ssh_host_key (ed25519, no passphrase, owner-only permissions). Bounds: --git-timeout per request, --git-sessions in total and --git-sessions-per-account, plus fixed caps on authentication tries, connections per host, request bytes and pkt-line count.

Clone and fetch over HTTPS

forge serve ... --http-listen :8444 --repos-root /srv/repos
git clone https://forge.example:8444/alice/project.git

Anonymous and read-only: only repositories holding a git-daemon-export-ok file are served, over TLS 1.3 with the admin certificate. A request needs Git-Protocol: version=2 (git 2.26 or later does that by default); protocol versions 0 and 1, the dumb protocol and push (git-receive-pack, served over SSH only) are refused with a message that says so. A private and a missing repository both answer 404. Bounds: --git-timeout per request, --git-sessions in total and --git-sessions-per-account (per client address here), plus fixed caps on header size, body size (as sent and once decompressed), request bytes and pkt-line count. No credential is accepted in a URL.

Sign-in with OIDC

Web sign-in goes only through the go-authn bridge (OIDC); the forge has no passwords. The administrator registers the forge as a client of the bridge:

forgectl --server forge.example:8443 --rp-id forge.example --credential-id <hex> \
    oidc set-client --issuer https://login.example --client-id forge \
    --redirect-uri https://forge.example:8445/callback   # secret: no-echo prompt
forgectl ... oidc show                                        # never prints the secret
forge serve ... --web-listen :8445 --secrets-key secrets.key
  • Who may sign in. Only an account that the administrator has bound to an identity with forgectl identities bind <issuer> <subject> <login>. The key is the pair (iss, sub): a sign-in never creates an account, never links an identity to a session that exists, and never reads an e-mail address or a username. Every refusal is the same 403 page. --public registers a client without a secret (PKCE only).
  • The client secret is sealed with AES-256-GCM before it is stored, with a key from --secrets-key (mode 0600) or the systemd credential secrets.key; without a key a secret is refused, never stored in clear. It is read from a no-echo prompt or --secret-fd, never from argv, the environment or a URL, and it is never returned.
  • The flow is the authorization code with PKCE S256, state, nonce and the RFC 9207 issuer check, over TLS 1.3 only.
  • Sessions are server side. The cookie is __Host- prefixed, Secure, HttpOnly and SameSite=Lax, and only its SHA-256 is stored. A session ends after 30 minutes idle or 12 hours of age, and with the account or its binding.

Read-only web UI

With --web-listen and --repos-root, the web listener shows, for each repository the viewer may read, the home page, the tree, a blob, the raw file, the commit log and a commit with its diff. A repository is visible to its owner, or to anyone when it holds git-daemon-export-ok; any other repository, and any missing one, answers 404. Nothing can be changed from the web. Every response carries a strict CSP (no inline script or style), nosniff, no-referrer and HSTS; names, paths, refs, commit text and diff lines are escaped, and raw files are never served as a renderable type. Every git command runs with a deadline, a bounded output and bounded concurrency, and the path, ref and page parsers are fuzzed.

Documentation

Overview

Package forge is the go-vcs Git forge server. Nothing is implemented yet; docs/design.md holds the design and the milestones.

Directories

Path Synopsis
api
cmd
forge command
Command forge is the go-vcs forge server.
Command forge is the go-vcs forge server.
forgectl command
Command forgectl administers a go-vcs forge.
Command forgectl administers a go-vcs forge.
internal
adminauth
Package adminauth authenticates admin API calls with FIDO2 assertions.
Package adminauth authenticates admin API calls with FIDO2 assertions.
adminclient
Package adminclient is the client of the admin API: it builds the signed envelope of each mutating call and asks a Signer (a FIDO2 key) to sign it.
Package adminclient is the client of the admin API: it builds the signed envelope of each mutating call and asks a Signer (a FIDO2 key) to sign it.
adminsrv
Package adminsrv implements the admin gRPC API and the local enrolment API.
Package adminsrv implements the admin gRPC API and the local enrolment API.
attest
Package attest verifies the attestation of an admin credential at enrolment.
Package attest verifies the attestation of an admin credential at enrolment.
fidotest
Package fidotest is a software FIDO2 authenticator for tests, so that CI needs no hardware.
Package fidotest is a software FIDO2 authenticator for tests, so that CI needs no hardware.
githttp
Package githttp serves git clone and fetch over smart HTTP, protocol version 2 only, anonymously and for public repositories only (gitprotocol-http, gitprotocol-v2).
Package githttp serves git clone and fetch over smart HTTP, protocol version 2 only, anonymously and for public repositories only (gitprotocol-http, gitprotocol-v2).
gitpush
Package gitpush is the forge side of git push (git-receive-pack, gitprotocol-pack): it decides, in process, who may move which ref, from the parsed command list and the received pack, BEFORE any ref moves.
Package gitpush is the forge side of git push (git-receive-pack, gitprotocol-pack): it decides, in process, who may move which ref, from the parsed command list and the received pack, BEFORE any ref moves.
gitrepo
Package gitrepo maps a repository name received from a git client to a bare repository on disk, decides who may read it, and bounds how many fetches run at once.
Package gitrepo maps a repository name received from a git client to a bare repository on disk, decides who may read it, and bounds how many fetches run at once.
gitssh
Package gitssh serves git clone and fetch (protocol v2, git-upload-pack) and push (git-receive-pack, through package gitpush) over SSH, in process, with golang.org/x/crypto/ssh.
Package gitssh serves git clone and fetch (protocol v2, git-upload-pack) and push (git-receive-pack, through package gitpush) over SSH, in process, with golang.org/x/crypto/ssh.
gittest
Package gittest makes bare repositories with history for tests, with the real git binary.
Package gittest makes bare repositories with history for tests, with the real git binary.
gitview
Package gitview reads a bare repository for the web pages: a commit's tree, a blob, the log, one commit's diff.
Package gitview reads a bare repository for the web pages: a commit's tree, a blob, the log, one commit's diff.
secretbox
Package secretbox encrypts the few secrets the forge stores (the OIDC client secret) at rest: AES-256-GCM, a fresh random nonce per seal, and additional data naming what the secret is, so a ciphertext copied into another row or purpose does not open.
Package secretbox encrypts the few secrets the forge stores (the OIDC client secret) at rest: AES-256-GCM, a fresh random nonce per seal, and additional data naming what the secret is, so a ciphertext copied into another row or purpose does not open.
sshkeys
Package sshkeys parses and classifies the SSH public keys users register.
Package sshkeys parses and classifies the SSH public keys users register.
sshtest
Package sshtest makes SSH keys for tests.
Package sshtest makes SSH keys for tests.
store
Package store is the forge's SQLite storage (pure Go, no cgo), with schema migrations.
Package store is the forge's SQLite storage (pure Go, no cgo), with schema migrations.
web
Package web is the forge's web listener: OIDC sign-in through the identity bridge, server-side sessions, and the read-only repository pages.
Package web is the forge's web listener: OIDC sign-in through the identity bridge, server-side sessions, and the read-only repository pages.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL