This commit is contained in:
@@ -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/<pageId>)` links to another page. `/pages?id=<id>`
|
||||
- `[label](superbrain:page/<pageId>)` links to another page. `/pages?id=<id>`
|
||||
and `page/<id>` 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.
|
||||
|
||||
+3
-3
@@ -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"]
|
||||
|
||||
@@ -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:
|
||||
|
||||
+11
-11
@@ -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:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
module github.com/andrew/go-computer
|
||||
module github.com/andrew/superbrain
|
||||
|
||||
go 1.26.0
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user