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 |
|
| GET, POST | `/api/auth/callback/authelia` | **501**, client-owned callback stub |
|
||||||
|
|
||||||
The browser's NextAuth `/api/auth/*` endpoints remain on the Next server.
|
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
|
Go login accepts JSON and rejects foreign browser origins. Login and signup
|
||||||
are throttled per client IP (429 with `Retry-After`), plus a
|
are throttled per client IP (429 with `Retry-After`), plus a
|
||||||
consecutive-failure lockout per IP+email on login. Login applies to every
|
consecutive-failure lockout per IP+email on login. Login applies to every
|
||||||
peer, loopback included; signup exempts only a direct loopback peer. Browser
|
peer, loopback included; signup exempts only a direct loopback peer. Browser
|
||||||
traffic arrives through the trusted Next proxy, which
|
traffic arrives through the trusted Next proxy, which
|
||||||
forwards the observed client IP in `X-Computer-Client-Ip` signed with
|
forwards the observed client IP in `X-superbrain-Client-Ip` signed with
|
||||||
HMAC-SHA256 under the shared secret (`X-Computer-Client-Sig`); Go buckets on
|
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
|
that identity only when the signature verifies and falls back to the direct
|
||||||
peer otherwise, so proxied browsers neither share one bucket nor forge
|
peer otherwise, so proxied browsers neither share one bucket nor forge
|
||||||
another identity.
|
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
|
Markdown contained in the page body; the server rebuilds the resolved graph
|
||||||
in the same transaction as every content save:
|
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
|
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;
|
are stored, so a backlink can never reveal another account's page title;
|
||||||
self-links are ignored.
|
self-links are ignored.
|
||||||
|
|||||||
+3
-3
@@ -6,12 +6,12 @@ COPY go.mod go.sum ./
|
|||||||
RUN go mod download
|
RUN go mod download
|
||||||
COPY main.go ./
|
COPY main.go ./
|
||||||
COPY internal ./internal
|
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
|
FROM scratch
|
||||||
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
||||||
COPY --from=build /usr/share/zoneinfo /usr/share/zoneinfo
|
COPY --from=build /usr/share/zoneinfo /usr/share/zoneinfo
|
||||||
COPY --from=build /out/computer /computer
|
COPY --from=build /out/superbrain /superbrain
|
||||||
USER 65532:65532
|
USER 65532:65532
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
ENTRYPOINT ["/computer"]
|
ENTRYPOINT ["/superbrain"]
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ stop docker-down:
|
|||||||
db-up:
|
db-up:
|
||||||
docker compose up -d db
|
docker compose up -d db
|
||||||
db-shell:
|
db-shell:
|
||||||
docker compose exec db psql -U computer -d computer
|
docker compose exec db psql -U superbrain -d superbrain
|
||||||
build:
|
build:
|
||||||
go build ./internal/... .
|
go build ./internal/... .
|
||||||
vet:
|
vet:
|
||||||
@@ -59,7 +59,7 @@ logs:
|
|||||||
migrate:
|
migrate:
|
||||||
docker compose run --rm migrate
|
docker compose run --rm migrate
|
||||||
seed:
|
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
|
# Target-agnostic server deploy; requires HOST, DOMAIN and CERTBOT_EMAIL
|
||||||
# (no defaults). See README "Deploying to a server".
|
# (no defaults). See README "Deploying to a server".
|
||||||
deploy:
|
deploy:
|
||||||
|
|||||||
+11
-11
@@ -1,17 +1,17 @@
|
|||||||
name: computer
|
name: superbrain
|
||||||
services:
|
services:
|
||||||
db:
|
db:
|
||||||
image: postgres:16.15-alpine
|
image: postgres:16.15-alpine
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
environment:
|
environment:
|
||||||
POSTGRES_DB: computer
|
POSTGRES_DB: superbrain
|
||||||
POSTGRES_USER: computer
|
POSTGRES_USER: superbrain
|
||||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?Set POSTGRES_PASSWORD in .env}
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?Set POSTGRES_PASSWORD in .env}
|
||||||
volumes:
|
volumes:
|
||||||
- pgdata:/var/lib/postgresql/data
|
- pgdata:/var/lib/postgresql/data
|
||||||
- ./db/schema.sql:/docker-entrypoint-initdb.d/01-schema.sql:ro
|
- ./db/schema.sql:/docker-entrypoint-initdb.d/01-schema.sql:ro
|
||||||
healthcheck:
|
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
|
interval: 3s
|
||||||
timeout: 3s
|
timeout: 3s
|
||||||
retries: 20
|
retries: 20
|
||||||
@@ -25,8 +25,8 @@ services:
|
|||||||
environment:
|
environment:
|
||||||
PGPASSWORD: ${POSTGRES_PASSWORD:?Set POSTGRES_PASSWORD in .env}
|
PGPASSWORD: ${POSTGRES_PASSWORD:?Set POSTGRES_PASSWORD in .env}
|
||||||
DB_HOST: db
|
DB_HOST: db
|
||||||
DB_USER: computer
|
DB_USER: superbrain
|
||||||
DB_NAME: computer
|
DB_NAME: superbrain
|
||||||
volumes:
|
volumes:
|
||||||
- ./db:/db:ro
|
- ./db:/db:ro
|
||||||
command: [sh, /db/migrate.sh]
|
command: [sh, /db/migrate.sh]
|
||||||
@@ -38,7 +38,7 @@ services:
|
|||||||
depends_on:
|
depends_on:
|
||||||
migrate: {condition: service_completed_successfully}
|
migrate: {condition: service_completed_successfully}
|
||||||
environment:
|
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}
|
AUTH_SECRET: ${AUTH_SECRET:?Set AUTH_SECRET in .env}
|
||||||
NEXTAUTH_SECRET: ${AUTH_SECRET}
|
NEXTAUTH_SECRET: ${AUTH_SECRET}
|
||||||
# Optional dedicated key for stored integration credentials (review
|
# Optional dedicated key for stored integration credentials (review
|
||||||
@@ -57,7 +57,7 @@ services:
|
|||||||
OIDC_CLIENT_SECRET: ${OIDC_CLIENT_SECRET:-}
|
OIDC_CLIENT_SECRET: ${OIDC_CLIENT_SECRET:-}
|
||||||
ports: ["127.0.0.1:${APP_HOST_PORT:-8080}:8080"]
|
ports: ["127.0.0.1:${APP_HOST_PORT:-8080}:8080"]
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: [CMD, /computer, --healthcheck]
|
test: [CMD, /superbrain, --healthcheck]
|
||||||
interval: 3s
|
interval: 3s
|
||||||
timeout: 4s
|
timeout: 4s
|
||||||
retries: 20
|
retries: 20
|
||||||
@@ -117,7 +117,7 @@ services:
|
|||||||
- ./db:/src/db:ro
|
- ./db:/src/db:ro
|
||||||
tmpfs: ["/tmp:exec"]
|
tmpfs: ["/tmp:exec"]
|
||||||
environment:
|
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
|
GOCACHE: /tmp/go-cache
|
||||||
GOMODCACHE: /tmp/go-mod
|
GOMODCACHE: /tmp/go-mod
|
||||||
command: [go, test, -race, -count=1, -v, ./internal/...]
|
command: [go, test, -race, -count=1, -v, ./internal/...]
|
||||||
@@ -133,7 +133,7 @@ services:
|
|||||||
environment:
|
environment:
|
||||||
PGPASSWORD: ${POSTGRES_PASSWORD:?Set POSTGRES_PASSWORD in .env}
|
PGPASSWORD: ${POSTGRES_PASSWORD:?Set POSTGRES_PASSWORD in .env}
|
||||||
DB_HOST: db
|
DB_HOST: db
|
||||||
DB_USER: computer
|
DB_USER: superbrain
|
||||||
volumes:
|
volumes:
|
||||||
- ./db:/db:ro
|
- ./db:/db:ro
|
||||||
command: [sh, /db/check-convergence.sh]
|
command: [sh, /db/check-convergence.sh]
|
||||||
@@ -141,7 +141,7 @@ services:
|
|||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
pgdata:
|
pgdata:
|
||||||
name: ${POSTGRES_VOLUME:-computer_pgdata}
|
name: ${POSTGRES_VOLUME:-superbrain_pgdata}
|
||||||
external: ${POSTGRES_VOLUME_EXTERNAL:-false}
|
external: ${POSTGRES_VOLUME_EXTERNAL:-false}
|
||||||
networks:
|
networks:
|
||||||
backend:
|
backend:
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
module github.com/andrew/go-computer
|
module github.com/andrew/superbrain
|
||||||
|
|
||||||
go 1.26.0
|
go 1.26.0
|
||||||
|
|
||||||
|
|||||||
@@ -3,11 +3,11 @@ package main
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"github.com/andrew/go-computer/internal/config"
|
"github.com/andrew/superbrain/internal/config"
|
||||||
"github.com/andrew/go-computer/internal/db"
|
"github.com/andrew/superbrain/internal/db"
|
||||||
"github.com/andrew/go-computer/internal/http"
|
"github.com/andrew/superbrain/internal/http"
|
||||||
"github.com/andrew/go-computer/internal/scripts"
|
"github.com/andrew/superbrain/internal/scripts"
|
||||||
"github.com/andrew/go-computer/internal/signals"
|
"github.com/andrew/superbrain/internal/signals"
|
||||||
"log"
|
"log"
|
||||||
stdhttp "net/http"
|
stdhttp "net/http"
|
||||||
"os"
|
"os"
|
||||||
|
|||||||
Reference in New Issue
Block a user