fix: address performance and security findings
- Add PostgreSQL-backed backend and frontend tests to CI - Harden Android API logging and disable app backups - Update the performance report with resolved findings
This commit is contained in:
1 parent
a84a36349b
commit
937f51b4fb
35 files changed
+2566
-332
No files matched your search
+53
-1
@@ -24,6 +24,7 @@ docker run -d --name collabtable-server --restart unless-stopped \
|
||||
-p 8080:8080 \
|
||||
-e DATABASE_URL=postgres://user:password@host:5432/collabtable \
|
||||
-e AUTHGUARD_URL=https://auth.example.com \
|
||||
-e SECRET=<long-random-shared-secret> \
|
||||
-e COOKIE_SECURE=false \
|
||||
collabtable-server
|
||||
```
|
||||
@@ -41,6 +42,10 @@ go test ./...
|
||||
go run .
|
||||
```
|
||||
|
||||
`go test ./...` skips the tests that need a database. To run them, set `TEST_DATABASE_URL` to a
|
||||
disposable PostgreSQL (a `postgres://` URL, never your real `DATABASE_URL`). Each test creates
|
||||
its own schema in it and drops the schema afterwards.
|
||||
|
||||
To build the dashboard for the embedded production binary:
|
||||
|
||||
```bash
|
||||
@@ -112,7 +117,19 @@ unrelated to AuthGuard (see below), hashed at rest, and shown only when generate
|
||||
|
||||
- `PORT` — HTTP port, default `8080`
|
||||
- `APP_VERSION` — optional version displayed in the dashboard, default `dev`
|
||||
- `COOKIE_SECURE` — set to `true` when served over HTTPS
|
||||
- `COOKIE_SECURE` — set to `true` when served over HTTPS. It marks only the cookies CollabTable
|
||||
clears on logout as `Secure`; the session cookie's attributes are set by AuthGuard.
|
||||
- `TRUSTED_PROXIES` — comma-separated IP addresses or CIDR ranges of reverse proxies, default
|
||||
unset (no proxy trusted). `X-Forwarded-For` is read for the client IP, used by the rate limits,
|
||||
only when the socket peer is in this list; `X-Forwarded-Proto` is honoured the same way.
|
||||
- `PRODUCTION` — set `true` for a production deployment, default `false`. Plain HTTP requests
|
||||
get 403 unless they arrive over TLS or through a `TRUSTED_PROXIES` proxy that sends
|
||||
`X-Forwarded-Proto: https` (`/health` stays open). Requires `TRUSTED_PROXIES`. With it unset,
|
||||
the server logs a warning that TLS is off.
|
||||
- `SECRET` — shared secret for the internal endpoints. Required unless `AUTH_DISABLED=true`:
|
||||
without it the auth status endpoint reports the missing secret and auth-gated routes return 500.
|
||||
- `ALLOWED_ORIGINS` — comma-separated browser origins allowed to call the API cross-origin with
|
||||
credentials, default unset (no CORS headers; the dashboard is same-origin).
|
||||
- `DATABASE_URL` — PostgreSQL connection string, required
|
||||
- `AUTHGUARD_URL` — optional bootstrap/override base URL of the AuthGuard identity service
|
||||
CollabTable authenticates against, default unset (pending). Leaving it unset does not disable
|
||||
@@ -129,6 +146,41 @@ unrelated to AuthGuard (see below), hashed at rest, and shown only when generate
|
||||
The Go server initializes the existing CollabTable tables in place, so switching from the
|
||||
previous server does not require a data export or schema conversion.
|
||||
|
||||
## Rate limits
|
||||
|
||||
The auth routes are throttled in process, per client IP (see `TRUSTED_PROXIES` for how the IP is
|
||||
resolved): setup, login, TOTP and token regeneration allow 30 requests per minute, after which
|
||||
the server answers 429 with `Retry-After`. Failed logins (401) are also counted per account
|
||||
identifier, and an account is locked for its 15-minute window after 10 failures. Anyone who knows
|
||||
an account name can therefore lock that account out for the window. Limits are per instance and
|
||||
reset on restart. AuthGuard applies its own limits; confirm them separately.
|
||||
The sync API is not throttled per request, because the bearer token is 256 bits and devices
|
||||
sync often.
|
||||
|
||||
## Security headers
|
||||
|
||||
Every response carries `X-Content-Type-Options: nosniff`, `X-Frame-Options: DENY`,
|
||||
`Referrer-Policy: strict-origin-when-cross-origin` and `Content-Security-Policy: frame-ancestors
|
||||
'none'`. The dashboard page (`index.html`, including the fallback for deep links) gets a full
|
||||
Content-Security-Policy instead: scripts only from this origin plus the page's own inline
|
||||
bootstrap script, whose hash is read from the embedded `index.html` at request time, so it
|
||||
follows every dashboard build. Styles allow `'unsafe-inline'` because the page shell uses a style
|
||||
attribute. `Strict-Transport-Security` is not set here; set it at the TLS proxy.
|
||||
|
||||
## Access model
|
||||
|
||||
There is one shared data set. Lists, fields, items and values have no owner and no per-list
|
||||
roles: any valid sync token can read, change and delete all of them, and any signed-in dashboard
|
||||
user can see all of them. Tokens are per account only so that each can be regenerated on its own.
|
||||
Deleting an item, field or list removes its values for good, while the rows themselves are soft
|
||||
deleted. Per-list access would need a membership table checked in every handler; that has not
|
||||
been decided.
|
||||
|
||||
When login is off (`AUTH_DISABLED=true`, or the login-required switch turned off in
|
||||
ProjectConfigurator), the dashboard data and user management need no session. Sync tokens are a
|
||||
separate matter: a caller without a session can only mint a token for the placeholder identity,
|
||||
and the sync API refuses that identity.
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
Reference in new issue
Block a user