steid

@jamesgill /

steid/README.md
Markdown23.0 KBRendered·Source·Blame·History·Raw
1# Steid
2
3A personal gitforge, in Rust. It hosts your repositories, and it is meant to become the
4place your work as a whole lives — code, writing, projects — under one identity you
5control.
6
7Steid is **portfolio-first**. Gitea and Forgejo are GitHub scaled down; their unit is the
8repository and the profile is a directory listing bolted to the side. Steid inverts that:
9the profile page at `/{handle}` is the product, and git repositories are one kind of
10thing that appears on it. That framing wins every tie-break in the design.
11
12It runs as a single binary with a SQLite database, shells out to `git` for everything
13git-shaped, and is small enough to host on the cheapest VPS you can find.
14
15## What works today
16
17Honestly and only:
18
19- **Identity and sessions.** One user. The instance is claimed on first run with a setup
20 token, then you sign in with a password. There is no registration — see
21 [limitations]#current-limitations.
22- **The profile page** at `/{handle}`, listing what you have.
23- **Repositories.** Created through the browser, or imported by cloning a URL. Stored as
24 bare repos on disk and records in SQLite. Public or private, renameable, pinnable,
25 archivable, deletable, with a default branch you choose.
26- **Clone and push over HTTPS**, through `git http-backend`, authenticated with personal
27 access tokens over HTTP Basic. Private repositories require a token to clone; public
28 ones are anonymous.
29- **Personal access tokens** — issue with an expiry (30 days, 90, a year, or never), see
30 when each was last used, revoke, at `/{handle}/settings/tokens`.
31- **Browsing** — file tree with a per-file **last-commit column**, file contents with
32 syntax highlighting, commit log, a commit and its **highlighted diff**, a three-dot
33 comparison of two revisions, blame, branches and tags, and the README rendered on the
34 repository page with `#12` and bare shas linked to the issue and commit they name.
35- **A file's own history** at `/{handle}/repos/{name}/log/{rev}/-/{path}`, which
36 **follows renames**, so a file's past does not stop where its name changed.
37- **Markdown files render as documents**, with `?view=source` for the text; headings get
38 ids, so a link to `notes.md#usage` lands on the section it names. Submodule rows link
39 to their upstream at the sha they are pinned to, and symlink rows say where they point.
40- **Code search** over a revision, at `/{handle}/repos/{name}/search`.
41- **Archive download** — `zip` and `tar.gz` of any revision, and of every tag.
42- **Issues** — open, comment, edit, close and reopen, with labels from a palette of
43 eight colours, and filtering by label and state.
44- **Pull requests** — branch to branch inside one repository, with a Conversation, the
45 commits and the changed files under their own tabs, the same labels the issues wear,
46 and a merge box that says whether the branches actually merge before it offers a
47 button. Merge as a merge commit, a fast-forward or a squash, optionally deleting the
48 source branch afterwards; a merge fires the same webhooks a push does, and
49 `Closes #4` in the title or body closes issue 4 and says so on it.
50- **Webhooks** — a signed JSON POST per push, with a delivery log you can page through,
51 redeliver an attempt from, and switch a hook off in.
52- **Atom feeds** — a repository's commits and its issues, and the owner's push activity
53 across repositories, linked from the pages they belong to and autodiscovered.
54- **Every long list pages**, with `?page=N`, clamped to the nearest page that exists
55 rather than refused.
56- **A JSON API** — `/api/me`, `/api/users/{handle}`, `/api/users/{handle}/repos`. Not a
57 separate product; every use case gets a second surface where that makes sense, which is
58 what keeps the use-case layer honest.
59
60Writing (markdown posts), multi-user, organizations, code review and SSH transport are
61**not built yet**. The plan for them is in [`plans/ROADMAP.md`]plans/ROADMAP.md.
62
63## Requirements
64
65- Linux, x86_64 or aarch64, with systemd. The releases are built against glibc 2.31, so
66 Debian 11 and Ubuntu 20.04 or newer.
67- **`git` on `PATH`.** Not optional: Steid runs `git init --bare` to create a repository
68 and `git http-backend` to serve every clone and push. One `apt-get install git`.
69 **git 2.38 or newer to merge a pull request from the web** — that is when `git
70 merge-tree --write-tree` arrived, which is how a merge is computed without a working
71 tree; everything else works on any git, and where it is older the merge box says so
72 instead of offering a button. Debian 12 and Ubuntu 22.04 and newer are fine.
73- **A TLS-terminating reverse proxy, and a domain name for it.** Also not optional.
74 Steid speaks plain HTTP — the web framework it is built on (Topcoat 0.5) has no TLS
75 support at all: no rustls, no ACME, no HTTPS listener. And because git authenticates
76 with HTTP Basic, an instance served over plain HTTP leaks your access token to every
77 hop on the network, on every push. The installer sets Caddy up for you.
78- About 100 MB of disk before any repositories, plus whatever you push.
79
80## Install
81
82### One command
83
84```sh
85curl -fsSL https://REPLACE-ME.example.com/steid/install.sh | sh -s -- --domain git.example.com
86```
87
88Point the domain's DNS at the machine first, and make sure ports 80 and 443 are open —
89Caddy needs both to obtain a certificate.
90
91That does the following, and nothing else:
92
931. installs `git`, `curl` and `ca-certificates`
942. downloads the release tarball for your architecture and **verifies its SHA-256**
953. unpacks it to `/opt/steid` — the binary with its `assets/` directory beside it
964. creates a `steid` system user and `/var/lib/steid` for state, owned by it
975. writes `/etc/steid/steid.env`, and a systemd unit that listens on `127.0.0.1:3000`
986. installs Caddy and writes a Caddyfile that terminates TLS for your domain and proxies
99 to that loopback port
1007. starts both
101
102Re-run it with a newer `--version` to upgrade. It is idempotent: it replaces the binary
103and assets, leaves `/var/lib/steid` alone, and will not overwrite `/etc/steid/steid.env`
104once it exists.
105
106Options: `--version`, `--port`, `--flavour musl|gnu` (`gnu` is what is built), and
107`--no-caddy` if you are bringing your own proxy. `sh install.sh --help` lists them.
108
109**On piping a URL into a shell.** It is a real trust decision, and "it's convenient" is
110not an answer to it. Download and read it first if you would rather:
111
112```sh
113curl -fsSL https://REPLACE-ME.example.com/steid/install.sh -o install.sh
114less install.sh
115sudo sh install.sh --domain git.example.com
116```
117
118Or do it by hand — the manual path below is the same steps, written out.
119
120### Manually
121
122Every command as root, on Debian or Ubuntu. Adjust paths and package manager to taste;
123nothing here is specific to a distribution except `apt-get`.
124
125```sh
126# 1. Prerequisites. git is mandatory — Steid shells out to it for everything.
127apt-get update
128apt-get install -y git curl ca-certificates
129
130# 2. Fetch and verify the release for your architecture.
131VERSION=0.1.0
132TARGET=x86_64-unknown-linux-gnu # or aarch64-unknown-linux-gnu
133BASE=https://REPLACE-ME.example.com/steid/releases/download
134curl -fsSLO "$BASE/v$VERSION/steid-$VERSION-$TARGET.tar.gz"
135curl -fsSLO "$BASE/v$VERSION/steid-$VERSION-$TARGET.tar.gz.sha256"
136sha256sum -c "steid-$VERSION-$TARGET.tar.gz.sha256"
137tar -xzf "steid-$VERSION-$TARGET.tar.gz"
138
139# 3. Install. `assets/` MUST end up beside the binary: at startup Steid walks up
140# from its own executable looking for `assets/manifest.toml`, and exits if it
141# is not there. Moving the binary on its own gives you a program that will not
142# boot.
143mkdir -p /opt/steid
144cp "steid-$VERSION-$TARGET/steid" /opt/steid/steid
145cp -r "steid-$VERSION-$TARGET/assets" /opt/steid/assets
146chmod 755 /opt/steid/steid
147
148# 4. A user to run as, and one directory for all state.
149useradd --system --home-dir /var/lib/steid --shell /usr/sbin/nologin steid
150mkdir -p /var/lib/steid/repos
151chown -R steid:steid /var/lib/steid
152chmod 750 /var/lib/steid
153
154# 5. Configuration.
155mkdir -p /etc/steid
156cat > /etc/steid/steid.env <<'EOF'
157STEID_DATABASE_URL=sqlite:/var/lib/steid/steid.db?mode=rwc
158STEID_DATA_DIR=/var/lib/steid/repos
159HOST=127.0.0.1
160PORT=3000
161EOF
162chmod 640 /etc/steid/steid.env
163chown root:steid /etc/steid/steid.env
164
165# 6. The service. deploy/steid.service in this repo is the file to copy.
166cp deploy/steid.service /etc/systemd/system/steid.service
167systemctl daemon-reload
168systemctl enable --now steid
169
170# 7. The proxy. deploy/Caddyfile is a working starting point — change the
171# hostname on its first line to yours.
172apt-get install -y caddy # or follow https://caddyserver.com/docs/install
173cp deploy/Caddyfile /etc/caddy/Caddyfile
174$EDITOR /etc/caddy/Caddyfile
175systemctl reload caddy
176```
177
178There is **no migration step**. Steid runs its migrations itself on every boot.
179
180## First run: claiming the instance
181
182A fresh instance has no owner. On startup it prints a setup token to its log:
183
184```
185 This steid has no owner yet. Claim it at /auth/setup with:
186
187 <token>
188```
189
190Two things about that token that will bite you otherwise:
191
192- It is printed **only while the instance is unclaimed**. Once you have claimed it, it is
193 never shown again — because it no longer exists.
194- It lives **in memory only**. Every restart mints a new one, and the one in an older log
195 line is dead.
196
197So read it from the current run's journal:
198
199```sh
200journalctl -u steid --no-pager | tail -n 30
201```
202
203Then open `https://git.example.com/auth/setup`, paste it in, and choose your handle and
204password. After that, `/auth/login`.
205
206**Passwords must be at least 12 characters.** That is the only rule — no required digit
207or symbol, because length is the part that measurably helps and composition rules mostly
208make people write theirs down. The same rule applies to a password reset and to changing
209one in settings; accounts created before it keep working until their owner changes them.
210
211### Or set the token yourself
212
213If reading a log line during the first minute of a scripted install is awkward, set the
214token instead and skip the race:
215
216```sh
217STEID_SETUP_TOKEN=$(head -c 32 /dev/urandom | base64)
218```
219
220It is only consulted while the instance is unclaimed, it is never printed, and Steid
221**refuses to start** if it is weak — at least 32 characters, no whitespace, and at least
222eight distinct characters, so `abababab…` is rejected rather than accepted.
223
224## Using it
225
2261. Create a repository at `/{handle}/repos/new`. Public or private.
2272. Issue a personal access token at `/{handle}/settings/tokens`. It is shown once.
2283. Push:
229
230```sh
231git remote add origin https://git.example.com/me/repos/my-project.git
232git push -u origin main
233```
234
235Git will ask for a username and password. The token goes in the **password** field; the
236username is ignored (a token pasted as the username with an empty password also works,
237because people do that).
238
239You only type it once. Git's credential helper stores it and answers every later push —
240which is the whole reason pushing to GitHub feels like it needs no credentials. Use the
241one that keeps secrets in your operating system's keystore:
242
243```sh
244git config --global credential.helper osxkeychain # macOS (usually already set)
245git config --global credential.helper manager # Windows
246git config --global credential.helper libsecret # Linux
247```
248
249**Not `credential.helper store`.** It writes the token in clear text to
250`~/.git-credentials`, and a token is a password that never expires. Steid keeps only a
251hash of it precisely so that a stolen database contains nothing anyone can present;
252storing the plaintext on your laptop hands back what that was protecting.
253
254**Do not put the token in the remote URL** (`https://user:token@host/...`) either. It
255goes into `.git/config` in clear text and shows up in `git remote -v`, in shell history,
256and in any log that records the URL.
257
258Cloning a public repository needs no credentials at all.
259
260## Configuration
261
262Environment variables, read from `/etc/steid/steid.env` by the systemd unit.
263
264| Variable | Default | What it is |
265|---|---|---|
266| `STEID_DATABASE_URL` | `sqlite:steid.db?mode=rwc` | SQLite connection string. The directory must be writable, not just the file — SQLite writes `-wal` and `-shm` siblings. |
267| `STEID_DATA_DIR` | `./data` | Where bare repositories live, as `{data_dir}/{handle}/{name}.git`. |
268| `STEID_INSECURE_COOKIES` | unset (false) | **Never set this in production.** It strips `Secure` from the session cookie so it survives plain-HTTP localhost, and exists only for local development. |
269| `HOST` | `127.0.0.1` in the shipped unit | Bind address. Read by the framework, so deliberately *not* `STEID_`-prefixed. Keep it on loopback; the proxy is the way in. |
270| `PORT` | `3000` | Likewise not `STEID_`-prefixed. |
271| `STEID_TRUSTED_PROXY` | unset (false) | Whether to believe `X-Forwarded-For` / `X-Real-IP` when telling one rate-limited caller from another. `install.sh` sets it `true`, because that install puts Caddy in front. Leave it off for anything serving Steid straight to the internet — see [Operator surface]#operator-surface. |
272| `STEID_OPERATOR_TOKEN` | unset | A bearer token for the operator surface. Unset means that surface does not exist. |
273
274Restart after editing: `systemctl restart steid`.
275
276## Operator surface
277
278Two JSON routes for driving an instance without a browser — a control plane provisioning
279a machine, a monitoring poll, a scripted install. No session, no cookie, no HTML.
280Authenticated by `STEID_OPERATOR_TOKEN` as a bearer token, compared in constant time.
281**With no token configured the surface does not exist**: those calls answer as if
282unauthenticated, and nothing advertises that a token could be set.
283
284### `GET /api/instance`
285
286Unauthenticated, it answers the one fact that is safe to tell anybody — and the one a
287provisioner needs, so it can wait for a machine to finish booting before handing its owner
288a claim link:
289
290```sh
291$ curl -s https://steid.example.com/api/instance
292{"claimed":false}
293```
294
295With the operator token it adds what the machine is and how big it has become:
296
297```sh
298$ curl -s -H "Authorization: Bearer $STEID_OPERATOR_TOKEN" \
299 https://steid.example.com/api/instance
300{"claimed":true,"version":"0.4.0","git_version":"2.47","merge_supported":true,
301 "repositories":3,"users":1,"uptime_seconds":8421}
302```
303
304A wrong or missing token is not an error — it is the public answer. `git_version` is
305absent where git could not be run at all, which is the same case that leaves
306`merge_supported` false.
307
308The unauthenticated form is rate limited to 60 calls a minute per caller (600 across
309everyone), which is about one poll a second. The authenticated form is not: a caller
310holding the token has already proved it is the control plane.
311
312### `POST /api/setup`
313
314The claim form, headless. Same rules as the page at `/auth/setup`: the setup token is
315checked before anything is written, a claimed instance cannot be claimed again, and the
316password must be at least 12 characters.
317
318```sh
319$ curl -s -X POST https://steid.example.com/api/setup \
320 -H 'content-type: application/json' \
321 -d '{"setup_token":"…","email":"you@example.com","handle":"you","password":"…"}'
322{"handle":"you"}
323```
324
325201 on success, and **no session** — a control plane is not signing in, so sign in through
326the browser afterwards like anyone else. A password short of the minimum is refused like
327everything else here — the same opaque `404`, with the reason in the server log — because
328a response that named the password would tell a stranger guessing tokens that they had
329guessed one. Every failure is the same `404` with the same
330body, whether the token was wrong or the instance was already claimed: telling those two
331apart would say whether there is still something worth guessing. It shares the sign-in
332rate limit — 10 attempts a minute per caller, 60 across everyone — because it is the same
333secret being attacked.
334
335Pair it with `STEID_SETUP_TOKEN` (see [Or set the token yourself]#or-set-the-token-yourself)
336so the whole install is scriptable: the token goes into the environment, the machine boots,
337`GET /api/instance` says `{"claimed":false}`, and one POST claims it.
338
339### `STEID_TRUSTED_PROXY`
340
341The rate limiters have to tell one caller from another, and the web framework Steid is
342built on (Topcoat 0.5) discards the peer address when it accepts a connection — a handler
343sees request headers and nothing else. So the only thing available is
344`X-Forwarded-For`.
345
346Behind a proxy that is sound: the proxy *appends* the address it accepted the connection
347from, so the rightmost entry is the one the client cannot forge. Exposed directly, nothing
348appends anything, and a caller can invent a fresh header per request to buy itself a fresh
349budget every time.
350
351`STEID_TRUSTED_PROXY` says which situation you are in, and defaults to the safe answer.
352Left off, no header is read at all and every caller shares one window — a forged header
353buys nothing, at the cost of one flood exhausting the shared budget for a minute. Turn it
354on only when something in front of Steid is appending the header; `install.sh` does,
355because it installs Caddy.
356
357## Backup and restore
358
359The entire backup surface is **two paths**:
360
361- `/var/lib/steid/steid.db` — the SQLite database (users, repositories, tokens, sessions)
362- `/var/lib/steid/repos` — the bare git repositories
363
364Which is to say: back up `/var/lib/steid`. `rsync` is enough.
365
366```sh
367systemctl stop steid
368rsync -a /var/lib/steid/ backup-host:/backups/steid/
369systemctl start steid
370```
371
372Stopping first is the honest version: SQLite in WAL mode leaves `-wal` and `-shm` files,
373and copying them while a write is in flight can capture a torn state. If you would rather
374not stop the service, snapshot the database properly and copy the repositories live —
375they are only written during a push:
376
377```sh
378sqlite3 /var/lib/steid/steid.db ".backup '/tmp/steid-backup.db'"
379rsync -a /tmp/steid-backup.db /var/lib/steid/repos backup-host:/backups/steid/
380```
381
382To restore: install Steid as above, stop it, drop both paths back into `/var/lib/steid`,
383`chown -R steid:steid /var/lib/steid`, start it. Migrations run on boot, so a database
384from an older version is brought forward automatically.
385
386## Building from source
387
388```sh
389cargo install topcoat-cli --version 0.5.0 --locked
390topcoat asset bundle --release
391```
392
393**`cargo build --release` on its own is not enough.** It produces a binary that will not
394boot: `AssetBundle::load()` walks up from the executable looking for
395`assets/manifest.toml`, and `build.rs` does not write one. `topcoat asset bundle` runs
396`cargo build` itself and then writes the bundle to `target/assets`. The binary at
397`target/release/steid` needs that directory beside it.
398
399Requires rustc ≥ 1.95 — Topcoat 0.5 demands it, and on an older toolchain `cargo add
400topcoat` silently resolves to an empty `v0.0.0` placeholder instead of failing.
401
402For development, `topcoat dev` does the bundling for you, and a local `.env` with
403`STEID_INSECURE_COOKIES=true` is needed for the session cookie to survive plain-HTTP
404localhost.
405
406### Cutting a release
407
408```sh
409./release.sh --target x86_64-unknown-linux-gnu
410```
411
412Produces `dist/steid-<version>-<target>.tar.gz` and a `.sha256` beside it. The tarball
413extracts to a self-contained directory: the binary, `assets/`, and this README. Building
414a Linux artefact on macOS needs a container (the script uses Docker) or a cross
415toolchain; `--native` builds for the host instead, which is useful for checking the
416artefact layout and not for releasing.
417
418A container image also exists — see [`Dockerfile`]Dockerfile — but the supported
419artefact is the plain binary.
420
421## Current limitations
422
423Deliberately blunt. Steid is early.
424
425- **Single user.** One account, claimed on first run. No registration, no invites, no
426 organizations yet. Issues exist, but only the owner may open or comment on one, which
427 is the same assumption showing.
428- **No TLS of its own.** A reverse proxy is mandatory, not recommended — see
429 [requirements]#requirements.
430- **No encryption at rest.** The database and repositories are plain files. Anyone with
431 the disk has everything. Token *values* are hashed, and passwords are Argon2, but
432 repository contents are not encrypted.
433- **Rate limiting covers `/auth/login`, `/auth/setup` and token authentication on the
434 git routes** — 10 attempts a minute per client for the first two, 60 for the third,
435 each with a global backstop. An anonymous clone of a public repository is not limited
436 at all, and neither is an archive download, which is the most expensive thing a
437 stranger can ask for.
438- **Rate limiting keys on forwarded headers, because Topcoat 0.5 does not expose the
439 peer address at all.** Behind a reverse proxy — the supported deployment — that works.
440 Exposed directly to the internet with no proxy, a caller can vary the header and get a
441 fresh budget each time, leaving only the global cap. Run it behind the proxy.
442- **Nothing sweeps expired tokens and nothing warns before one expires.** A token that
443 has expired authenticates exactly like one that never existed, and the tokens page is
444 where you find out.
445- **No CI/CD**, no code review, no SSH transport, no federation. Pull requests exist but
446 are bare: no assignees, reviewers or milestones, and only the owner may open or merge
447 one — the single-user assumption again.
448- **No writing yet** — posts and markdown are the next milestone, and they are the point
449 of the whole thing.
450- **Light mode is half-checked.** The repository landing page, a tree and a blob were
451 looked at and were fine; the profile, the settings pages and the log were not. Either
452 way there is no way for a visitor to choose — the layout is hardcoded dark.
453- **Not battle-tested.** It has not run under load, has not been audited, and has been
454 deployed by approximately one person. Do not put anything irreplaceable in it that is
455 not also somewhere else.
456
457More, in unflattering detail, in [`plans/current.md`]plans/current.md.
458
459## Project layout
460
461`plans/` is the source of truth for intent, not the code:
462
463| File | Holds |
464|---|---|
465| [`plans/ROADMAP.md`]plans/ROADMAP.md | vision, stack, the milestone ladder |
466| [`plans/current.md`]plans/current.md | the active milestone, and every known gap |
467| [`plans/progress.md`]plans/progress.md | what shipped, and the decisions worth not rediscovering |
468| [`plans/architecture.md`]plans/architecture.md | layer rules and conventions |
469| [`plans/decisions/`]plans/decisions/ | ADRs |
470
471The code is a single crate in three layers — `domain`, `application`, `infrastructure` —
472with dependencies pointing inward. Every use case takes an `Actor` and authorizes before
473any side effect.
474
475## Licence
476
477Copyright (C) 2026 James Gill.
478
479Steid is free software under the **GNU Affero General Public License v3.0** — see
480[LICENSE]LICENSE. You may use, modify and redistribute it, including commercially.
481
482The reason for AGPL rather than a permissive licence is section 13: if you modify Steid
483and offer it to others **over a network**, you must make your modified source available
484to those users. Running an unmodified copy — which is what self-hosting is — carries no
485such obligation. In other words: host it for yourself freely, fork it privately for
486yourself freely, but a modified public service has to share what it changed.
487
488Worth being straightforward about what this does *not* do: it does not stop anyone
489running Steid as a commercial hosted service. AGPL is a copyleft licence, not a
490non-compete.
491