Migrate auth to AuthGuard, retiring local Postgres-backed accounts
Same pattern as GameStream (commit 6a46007), adapted for CollabTable being genuinely multi-user (not single-admin): admin user management (list/create/update/delete, role reassignment, superadmin protection) is fully proxied to AuthGuard, which already enforces the same rules CollabTable checked locally. Cookie forwarding, no local session token, AUTHGUARD_URL optional (unset = auth fully disabled), transport failures always surface as errAuthGuardUnavailable rather than ever letting a request through - proven with live tests against a closed socket. CollabTable's device-sync API token feature (separate from browser sessions) is deliberately left local-only regardless of AUTHGUARD_URL, keyed by a new currentUserID helper (AuthGuard's id when enabled, the shared placeholder id 0 when disabled) - a real, functional token either way, not faked data. Real bug found and fixed: api_tokens.user_id had a hard FK into the local auth_users table, which would reject new tokens once accounts stop being written locally. Dropped the now-invalid FK. Known, accepted gap (same as GameStream): self-service profile editing for non-admin accounts is lost, since AuthGuard only exposes an admin endpoint, no self-edit. TOTP QR issuer branding now comes from AuthGuard rather than CollabTable. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a1c29728f0
commit
9a6ec940f7
48 files changed
+12401
-511
No files matched your search
+17
-5
@@ -8,8 +8,10 @@ Svelte dashboard and the Android synchronization API from one container.
|
||||
- REST API for lists, fields, items, and item values
|
||||
- Transactional HTTP synchronization with soft-delete tombstones
|
||||
- Notification polling for background refreshes
|
||||
- Single-admin browser session with bcrypt-hashed credentials
|
||||
- Long-lived bearer API token for Android and other sync clients
|
||||
- Multi-user browser sessions (with per-account roles/admin user management) authenticated
|
||||
through AuthGuard, a centralized identity service shared across projects (optional -- see
|
||||
`AUTHGUARD_URL` below)
|
||||
- Long-lived bearer API token for Android and other sync clients (independent of AuthGuard)
|
||||
- Embedded SvelteKit dashboard
|
||||
- Idempotent PostgreSQL schema initialization
|
||||
|
||||
@@ -21,11 +23,12 @@ docker build -f docker/Dockerfile -t collabtable-server .
|
||||
docker run -d --name collabtable-server --restart unless-stopped \
|
||||
-p 3000:3000 \
|
||||
-e DATABASE_URL=postgres://user:password@host:5432/collabtable \
|
||||
-e AUTHGUARD_URL=https://auth.example.com \
|
||||
-e COOKIE_SECURE=false \
|
||||
collabtable-server
|
||||
```
|
||||
|
||||
Open `http://localhost:3000` to create the administrator account. Generate an API token from
|
||||
Open `http://localhost:3000` to create the first account. Generate an API token from
|
||||
the dashboard's Settings menu and enter it in the Android app.
|
||||
|
||||
## Local development
|
||||
@@ -73,8 +76,13 @@ notification events.
|
||||
- `GET /api/auth/token/status`
|
||||
- `POST /api/auth/token/regenerate`
|
||||
|
||||
Browser authentication uses the `collabtable_session` HTTP-only cookie. There is one admin
|
||||
account per database. API tokens are hashed at rest and shown only when generated.
|
||||
Browser authentication proxies to AuthGuard (`AUTHGUARD_URL`), which sets and reads its own
|
||||
`auth_session` HTTP-only cookie; CollabTable itself mints no session token. Any number of
|
||||
accounts can exist, with `user`/`admin`/`superadmin` roles managed via `/api/auth/users`.
|
||||
`AUTHGUARD_URL` is optional: leaving it unset disables authentication entirely (no login
|
||||
screen, nothing gated) rather than falling back to any local account store -- only use that for
|
||||
local development or a deployment you are certain does not need access control. API tokens are
|
||||
unrelated to AuthGuard (see below), hashed at rest, and shown only when generated.
|
||||
|
||||
### Data
|
||||
|
||||
@@ -104,6 +112,10 @@ account per database. API tokens are hashed at rest and shown only when generate
|
||||
- `APP_VERSION` — optional version displayed in the dashboard, default `dev`
|
||||
- `COOKIE_SECURE` — set to `true` when served over HTTPS
|
||||
- `DATABASE_URL` — PostgreSQL connection string, required
|
||||
- `AUTHGUARD_URL` — base URL of the AuthGuard identity service CollabTable authenticates
|
||||
against, default unset (auth disabled). Leaving it unset does not fall back to any local
|
||||
account store -- it disables authentication entirely, treating every request as
|
||||
authenticated with nothing gated.
|
||||
- `DB_INIT_RETRY_INTERVAL_MS` — startup retry delay, default `5000`
|
||||
- `DB_INIT_RETRY_MAX_ATTEMPTS` — maximum startup attempts, `0` retries forever
|
||||
- `SYNC_MAX_FUTURE_SKEW_MS` — allowed client timestamp skew, default `0`
|
||||
|
||||
Reference in new issue
Block a user