Docs Platform
Security
How tenants are isolated and secrets, files and webhooks are protected.
Isolation#
- The tenant always comes from the credential, never from the request.
- Composite foreign keys make cross-tenant references impossible at the database level.
- Resources that belong to someone else return
404, so ids can’t be probed.
Row-level security#
Behind those, Postgres itself refuses to show a tenant anyone else’s rows. Every table that has a tenant_id carries a row-level security policy, and the API stamps the caller’s tenant onto each database connection as it is handed out and clears it when it goes back to the pool.
The point is to survive our own mistakes: a query that forgets where tenant_id = ? still only sees the caller’s rows, and a connection with no tenant set sees nothing at all. A few background jobs (webhook delivery, expiring enrollments) and three lookups that start from a secret rather than a tenant (API key, invitation token, certificate verification code) run in an explicit system scope. Every use is deliberate and few.
This only holds if the API connects as an ordinary database role, because Postgres superusers skip every policy. See Deployment. The API warns at startup when it is connected as a role that bypasses the policies, and can refuse to start.
Credentials#
- Passwords are hashed. Login failures are indistinguishable (same
401) so accounts can’t be enumerated. - API keys store only a hash. The secret is shown once.
- Invitation tokens store only a hash and expire after 7 days.
- Webhook signing secrets are encrypted at rest (AES-GCM).
Webhooks#
Deliveries are HMAC-signed with a timestamp. Endpoints must be https, can’t resolve to private, loopback or link-local addresses, and redirects are not followed, which guards against server-side request forgery.
Files#
An allow-list of content types, SVG and HTML refused, generated storage keys, sanitised names, nosniff and download disposition on every response.
Learners can’t see the answer key#
Quiz papers are sent in their public form. Answers and the key are included only when the quiz’s feedbackMode allows.
Audit#
Every successful change made through the API is recorded: who made it (a signed-in user or an API key), what they did, which record it touched, when, and from which address. Request bodies are kept with passwords, tokens and secrets removed. Entries are append-only; the database role the API runs as cannot edit or delete them.
Admins read the history with GET /audit-log. API keys can’t, so a stolen key can’t be used to check what it did.
Before you go live#
Warning
The defaults for JWT_SECRET and ENCRYPTION_KEY exist only so local development works. Set real values in production. See Deployment.
Also: serve over HTTPS, restrict CORS_ORIGINS to your own sites, and keep PLATFORM_TOKEN unset unless you need to create tenants.
Reporting a vulnerability#
Contact details will be published here before launch.