diff --git a/API.md b/API.md index dad6815..b24f7cc 100644 --- a/API.md +++ b/API.md @@ -28,14 +28,14 @@ capped (100 per bookmark/tag/collection share, 200 per shared date). | GET, POST | `/api/auth/callback/authelia` | **501**, client-owned callback stub | The browser's NextAuth `/api/auth/*` endpoints remain on the Next server. -Direct Go API consumers use the `computer_session` cookie from login. +Direct Go API consumers use the `superbrain_session` cookie from login. Go login accepts JSON and rejects foreign browser origins. Login and signup are throttled per client IP (429 with `Retry-After`), plus a consecutive-failure lockout per IP+email on login. Login applies to every peer, loopback included; signup exempts only a direct loopback peer. Browser traffic arrives through the trusted Next proxy, which -forwards the observed client IP in `X-Computer-Client-Ip` signed with -HMAC-SHA256 under the shared secret (`X-Computer-Client-Sig`); Go buckets on +forwards the observed client IP in `X-superbrain-Client-Ip` signed with +HMAC-SHA256 under the shared secret (`X-superbrain-Client-Sig`); Go buckets on that identity only when the signature verifies and falls back to the direct peer otherwise, so proxied browsers neither share one bucket nor forge another identity. @@ -135,7 +135,7 @@ Page hierarchy, internal links and live collection embeds are ordinary Markdown contained in the page body; the server rebuilds the resolved graph in the same transaction as every content save: -- `[label](computer:page/)` links to another page. `/pages?id=` +- `[label](superbrain:page/)` links to another page. `/pages?id=` and `page/` are accepted as hand-written aliases. Only owned targets are stored, so a backlink can never reveal another account's page title; self-links are ignored. diff --git a/Dockerfile b/Dockerfile index 9665110..d2b4583 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,12 +6,12 @@ COPY go.mod go.sum ./ RUN go mod download COPY main.go ./ COPY internal ./internal -RUN CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o /out/computer . +RUN CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o /out/superbrain . FROM scratch COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ COPY --from=build /usr/share/zoneinfo /usr/share/zoneinfo -COPY --from=build /out/computer /computer +COPY --from=build /out/superbrain /superbrain USER 65532:65532 EXPOSE 8080 -ENTRYPOINT ["/computer"] +ENTRYPOINT ["/superbrain"] diff --git a/Makefile b/Makefile index 2f25b57..65d26c5 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ stop docker-down: db-up: docker compose up -d db db-shell: - docker compose exec db psql -U computer -d computer + docker compose exec db psql -U superbrain -d superbrain build: go build ./internal/... . vet: @@ -59,7 +59,7 @@ logs: migrate: docker compose run --rm migrate seed: - docker compose exec -e SEED_EMAIL -e SEED_PASSWORD -e SEED_NAME app /computer --seed + docker compose exec -e SEED_EMAIL -e SEED_PASSWORD -e SEED_NAME app /superbrain --seed # Target-agnostic server deploy; requires HOST, DOMAIN and CERTBOT_EMAIL # (no defaults). See README "Deploying to a server". deploy: diff --git a/docker-compose.yml b/docker-compose.yml index 8981251..360da84 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,17 +1,17 @@ -name: computer +name: superbrain services: db: image: postgres:16.15-alpine restart: unless-stopped environment: - POSTGRES_DB: computer - POSTGRES_USER: computer + POSTGRES_DB: superbrain + POSTGRES_USER: superbrain POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?Set POSTGRES_PASSWORD in .env} volumes: - pgdata:/var/lib/postgresql/data - ./db/schema.sql:/docker-entrypoint-initdb.d/01-schema.sql:ro healthcheck: - test: [CMD-SHELL, pg_isready -h 127.0.0.1 -U computer -d computer] + test: [CMD-SHELL, pg_isready -h 127.0.0.1 -U superbrain -d superbrain] interval: 3s timeout: 3s retries: 20 @@ -25,8 +25,8 @@ services: environment: PGPASSWORD: ${POSTGRES_PASSWORD:?Set POSTGRES_PASSWORD in .env} DB_HOST: db - DB_USER: computer - DB_NAME: computer + DB_USER: superbrain + DB_NAME: superbrain volumes: - ./db:/db:ro command: [sh, /db/migrate.sh] @@ -38,7 +38,7 @@ services: depends_on: migrate: {condition: service_completed_successfully} environment: - DATABASE_URL: postgres://computer:${POSTGRES_PASSWORD:?Set POSTGRES_PASSWORD in .env}@db:5432/computer?sslmode=disable + DATABASE_URL: postgres://superbrain:${POSTGRES_PASSWORD:?Set POSTGRES_PASSWORD in .env}@db:5432/superbrain?sslmode=disable AUTH_SECRET: ${AUTH_SECRET:?Set AUTH_SECRET in .env} NEXTAUTH_SECRET: ${AUTH_SECRET} # Optional dedicated key for stored integration credentials (review @@ -57,7 +57,7 @@ services: OIDC_CLIENT_SECRET: ${OIDC_CLIENT_SECRET:-} ports: ["127.0.0.1:${APP_HOST_PORT:-8080}:8080"] healthcheck: - test: [CMD, /computer, --healthcheck] + test: [CMD, /superbrain, --healthcheck] interval: 3s timeout: 4s retries: 20 @@ -117,7 +117,7 @@ services: - ./db:/src/db:ro tmpfs: ["/tmp:exec"] environment: - TEST_DATABASE_URL: postgres://computer:${POSTGRES_PASSWORD:?Set POSTGRES_PASSWORD in .env}@db:5432/computer?sslmode=disable + TEST_DATABASE_URL: postgres://superbrain:${POSTGRES_PASSWORD:?Set POSTGRES_PASSWORD in .env}@db:5432/superbrain?sslmode=disable GOCACHE: /tmp/go-cache GOMODCACHE: /tmp/go-mod command: [go, test, -race, -count=1, -v, ./internal/...] @@ -133,7 +133,7 @@ services: environment: PGPASSWORD: ${POSTGRES_PASSWORD:?Set POSTGRES_PASSWORD in .env} DB_HOST: db - DB_USER: computer + DB_USER: superbrain volumes: - ./db:/db:ro command: [sh, /db/check-convergence.sh] @@ -141,7 +141,7 @@ services: volumes: pgdata: - name: ${POSTGRES_VOLUME:-computer_pgdata} + name: ${POSTGRES_VOLUME:-superbrain_pgdata} external: ${POSTGRES_VOLUME_EXTERNAL:-false} networks: backend: diff --git a/go.mod b/go.mod index 6137775..38cf9a3 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/andrew/go-computer +module github.com/andrew/superbrain go 1.26.0 diff --git a/main.go b/main.go index 091a3fb..164c7eb 100644 --- a/main.go +++ b/main.go @@ -3,11 +3,11 @@ package main import ( "context" "errors" - "github.com/andrew/go-computer/internal/config" - "github.com/andrew/go-computer/internal/db" - "github.com/andrew/go-computer/internal/http" - "github.com/andrew/go-computer/internal/scripts" - "github.com/andrew/go-computer/internal/signals" + "github.com/andrew/superbrain/internal/config" + "github.com/andrew/superbrain/internal/db" + "github.com/andrew/superbrain/internal/http" + "github.com/andrew/superbrain/internal/scripts" + "github.com/andrew/superbrain/internal/signals" "log" stdhttp "net/http" "os"