README.org
136 lines · 5702 bytes
1#+title: gitbay
2#+author: Christian Cleberg
3
4[[https://gitbay.org/krz/gitbay/builds][file:https://gitbay.org/krz/gitbay/badge/build.svg]]
5
6Support gitbay through [[https://github.com/sponsors/ccleberg][GitHub Sponsors]].
7
8A CLI-first git forge. One binary, SQLite, and the system =git= — designed
9so the command line is the product and the web UI is a rendering of state
10the CLI already manages. Runs at [[https://gitbay.org]].
11
12* Design
13
14SSH is the API. The server authenticates by public key, then dispatches the
15requested command: =git-upload-pack= / =git-receive-pack= stream the git
16transport, anything else is a control command. The control plane is fully
17usable from stock OpenSSH with no client installed:
18
19#+begin_src sh
20ssh git@gitbay.org repo create you/project --private
21ssh git@gitbay.org issue create you/project --title "bug" --file - < body.md
22ssh git@gitbay.org repo log you/project --json
23#+end_src
24
25The =gitbay= CLI is ergonomics on top — instance profiles, repo inference
26from the origin remote, =$EDITOR= for long text — never a requirement. A
27registry test enforces that every command stays reachable over bare ssh.
28
29Properties that follow from the design:
30
31- pushing is SSH-only. HTTPS and =git://= serve anonymous reads of public
32 repositories; a push over HTTPS is answered with a pkt-line ERR that
33 every git version prints as =remote error:= — no credential prompt,
34 ever. Private repositories answer 404/not-found identically to
35 nonexistent ones on every surface.
36- commit signatures (OpenPGP and SSHSIG) are verified against registered
37 keys and verified emails, with six distinct states — =verified=,
38 =signed_unknown_key=, =signed_email_mismatch=, =signed_key_expired=,
39 =signed_key_revoked=, =bad_signature=, =unsigned= — cached and
40 invalidated by a global key epoch, so registering a key retroactively
41 verifies old commits.
42- there is no server signing key. Server-created commits (web edits,
43 merge/squash/rebase commits) display honestly as unsigned, and branches
44 with =require_signed_commits= accept only fast-forward merges of
45 verified commits — enforced at push time and merge time.
46- the web UI is server-rendered with no JavaScript required. In
47 =view_only= mode the mutating routes are never registered on the mux;
48 browser sessions, where enabled, are minted over SSH (=web login=) —
49 there are no passwords.
50
51* Features
52
53- repositories with per-branch protection, forks, and organizations
54 (shared owner namespace, membership-derived access)
55- issues and merge requests (fast-forward, merge-commit, squash, rebase)
56 entirely over ssh, with reviews that go stale on force-push
57- merge request heads are fetched /into/ the target repository, so an MR
58 survives deletion of its source fork
59- =repo import= mirrors from any http(s)/git URL, tokens via stdin only
60- registration modes: =closed= (admin creates users), =invite=, =open=
61 with SMTP email verification
62- signed outbound webhooks with retries, dead-lettering, and SSRF
63 guarding; a JSON API (=POST /api/v1/cmd=) fronting the same command
64 registry, with scoped, revocable bearer tokens
65- built-in ACME (Let's Encrypt) TLS; =admin backup= produces one
66 restore-tested archive (database snapshot first, then repositories)
67
68* Server quickstart
69
70#+begin_src sh
71# /etc/gitbay/config.toml
72[server]
73root = "/var/lib/gitbay"
74site_url = "https://forge.example.org"
75
76[http]
77acme_email = "you@example.org"
78#+end_src
79
80#+begin_src sh
81gitbayd --config /etc/gitbay/config.toml check-config
82gitbayd --config /etc/gitbay/config.toml admin user create you \
83 --key ~/.ssh/id_ed25519.pub --email you@example.org --verified --admin
84gitbayd --config /etc/gitbay/config.toml serve
85#+end_src
86
87The embedded SSH listener takes port 22 (move the host sshd, or set
88=ssh.mode = "system"= to run under it via =AuthorizedKeysCommand=). See
89=deploy/= for a cloud-init file, hardened systemd unit, and nightly
90backup timer.
91
92* Client quickstart
93
94#+begin_src sh
95gitbay remote add myforge forge.example.org --default
96gitbay auth whoami
97gitbay repo create you/project
98gitbay repo clone you/project && cd project
99gitbay issue create --title "first issue" # repo inferred from origin
100gitbay mr checkout 4 # fetches refs/merge-requests/4/head
101#+end_src
102
103Every read command takes =--json=; stdout is data, stderr is messages;
104exit codes are stable (0 ok, 2 usage, 3 not found, 4 denied). Man pages
105via =gitbay man=, completions via =gitbay completion <shell>=.
106
107* Documentation
108
109Docs live in [[https://gitbay.org/krz/gitbay/wiki][the wiki]], dogfooding the
110wiki feature:
111
112- [[https://gitbay.org/krz/gitbay/wiki/Users][user guide]] — accounts, keys, verified commits, repos, issues, MRs, scripting
113- [[https://gitbay.org/krz/gitbay/wiki/Admin][admin guide]] — install, full configuration reference, backup/restore, security
114- [[https://gitbay.org/krz/gitbay/wiki/API][API and webhooks]] — the JSON API contract, tokens, webhook payloads and HMAC
115- [[https://gitbay.org/krz/gitbay/wiki/Threat-Model][threat model]] — what the forge trusts and never does
116
117* Contributing
118
119See [[file:CONTRIBUTING.org][CONTRIBUTING]]. Development happens on gitbay.org itself.
120
121* Development
122
123#+begin_src sh
124go build ./...
125go test ./... # e2e drives real git, ssh, sshd, and gpg binaries
126#+end_src
127
128Layout: =cmd/gitbay= (CLI), =cmd/gitbayd= (daemon, hooks, admin),
129=internal/control= (command registry — the single source of truth fronted
130by ssh and the JSON API), =internal/sshd= / =httpd= / =gitd= (transports),
131=internal/sig= (signature verification), =internal/policy= (access rules),
132=internal/store= (SQLite, migrations), =e2e/= (integration tests).
133
134* License
135
1360BSD.