···11-// adapted from https://github.com/haileyok/atproto-oauth-golang
11+// adapted from https://tangled.sh/icyphox.sh/atproto-oauth
2233package main
44
-15
cmd/keyfetch/format.go
···11-package main
22-33-import (
44- "fmt"
55-)
66-77-func formatKeyData(repoguardPath, gitDir, logPath, endpoint string, data []map[string]interface{}) string {
88- var result string
99- for _, entry := range data {
1010- result += fmt.Sprintf(
1111- `command="%s -base-dir %s -user %s -log-path %s -internal-api %s",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty %s`+"\n",
1212- repoguardPath, gitDir, entry["did"], logPath, endpoint, entry["key"])
1313- }
1414- return result
1515-}
-46
cmd/keyfetch/main.go
···11-// This program must be configured to run as the sshd AuthorizedKeysCommand.
22-// The format looks something like this:
33-// Match User git
44-// AuthorizedKeysCommand /keyfetch -internal-api http://localhost:5444 -repoguard-path /home/git/repoguard
55-// AuthorizedKeysCommandUser nobody
66-//
77-// The command and its parent directories must be owned by root and set to 0755. Hence, the ideal location for this is
88-// somewhere already owned by root so you don't have to mess with directory perms.
99-1010-package main
1111-1212-import (
1313- "encoding/json"
1414- "flag"
1515- "fmt"
1616- "io"
1717- "log"
1818- "net/http"
1919-)
2020-2121-func main() {
2222- endpoint := flag.String("internal-api", "http://localhost:5444", "Internal API endpoint")
2323- repoguardPath := flag.String("repoguard-path", "/home/git/repoguard", "Path to the repoguard binary")
2424- gitDir := flag.String("git-dir", "/home/git", "Path to the git directory")
2525- logPath := flag.String("log-path", "/home/git/log", "Path to log file")
2626- flag.Parse()
2727-2828- resp, err := http.Get(*endpoint + "/keys")
2929- if err != nil {
3030- log.Fatalf("error fetching keys: %v", err)
3131- }
3232- defer resp.Body.Close()
3333-3434- body, err := io.ReadAll(resp.Body)
3535- if err != nil {
3636- log.Fatalf("error reading response body: %v", err)
3737- }
3838-3939- var data []map[string]interface{}
4040- err = json.Unmarshal(body, &data)
4141- if err != nil {
4242- log.Fatalf("error unmarshalling response body: %v", err)
4343- }
4444-4545- fmt.Print(formatKeyData(*repoguardPath, *gitDir, *logPath, *endpoint, data))
4646-}
···3333knotserver: git/service: improve error checking in upload-pack
3434```
35353636-The affected package/directory can be truncated down to just the relevant dir
3737-should it be far too long. For example `pages/templates/repo/fragments` can
3838-simply be `repo/fragments`.
39364037### general notes
4138···4340using `git am`. At present, there is no squashing -- so please author
4441your commits as they would appear on `master`, following the above
4542guidelines.
4343+- If there is a lot of nesting, for example "appview:
4444+pages/templates/repo/fragments: ...", these can be truncated down to
4545+just "appview: repo/fragments: ...". If the change affects a lot of
4646+subdirectories, you may abbreviate to just the top-level names, e.g.
4747+"appview: ..." or "knotserver: ...".
4848+- Keep commits lowercased with no trailing period.
4649- Use the imperative mood in the summary line (e.g., "fix bug" not
4750"fixed bug" or "fixes bug").
4851- Try to keep the summary line under 72 characters, but we aren't too
4952fussed about this.
5353+- Follow the same formatting for PR titles if filled manually.
5054- Don't include unrelated changes in the same commit.
5155- Avoid noisy commit messages like "wip" or "final fix"โrewrite history
5256before submitting if necessary.
+8-8
docs/hacking.md
···3232nix run .#watch-tailwind
3333```
34343535-## running a knotserver
3535+## running a knot
36363737-An end-to-end knotserver setup requires setting up a machine
3838-with `sshd`, `repoguard`, `keyfetch`, a git user, which is
3939-quite cumbersome and so the nix flake provides a
3737+An end-to-end knot setup requires setting up a machine with
3838+`sshd`, `AuthorizedKeysCommand`, and git user, which is
3939+quite cumbersome. So the nix flake provides a
4040`nixosConfiguration` to do so.
41414242To begin, head to `http://localhost:3000` in the browser and
4343-generate a knotserver secret. Replace the existing secret in
4343+generate a knot secret. Replace the existing secret in
4444`flake.nix` with the newly generated secret.
45454646You can now start a lightweight NixOS VM using
···5252# hit Ctrl-a + c + q to exit the VM
5353```
54545555-This starts a knotserver on port 6000 with `ssh` exposed on
5656-port 2222. You can push repositories to this VM with this
5757-ssh config block on your main machine:
5555+This starts a knot on port 6000 with `ssh` exposed on port
5656+2222. You can push repositories to this VM with this ssh
5757+config block on your main machine:
58585959```bash
6060Host nixos-shell