feat(server): add persistent authentication and production build (#6)

Protect HTTP and WebSocket API routes with scrypt password login and signed persistent sessions. Restrict forwarded identity and HTTPS detection to configured proxies, and serve optional web assets with SPA fallback.

Add @fastify/static for Fastify-compatible static file handling and esbuild to bundle TypeScript core source while retaining native dependencies externally.
This commit is contained in:
Florian Schmidt
2026-11-16 00:07:18 +01:00
parent d06f4336ae
commit af331177ac
10 changed files with 817 additions and 3 deletions
+14 -1
View File
@@ -3,5 +3,18 @@ import { buildApp } from "./app";
const host = process.env.SHELLBOOK_HOST ?? "127.0.0.1";
const port = Number(process.env.SHELLBOOK_PORT ?? 8080);
const app = await buildApp({ logger: true });
const proxies = process.env.SHELLBOOK_TRUSTED_PROXIES?.split(",").map(ip => ip.trim()).filter(Boolean) ?? [];
const app = await buildApp({
logger: true,
trustProxy: proxies,
staticDir: process.env.SHELLBOOK_STATIC_DIR,
auth: {
dataDir: process.env.SHELLBOOK_DATA_DIR ?? "data",
sessionMaxAgeSeconds: Number(process.env.SHELLBOOK_SESSION_SECONDS ?? 2592000),
forwardAuth: process.env.SHELLBOOK_FORWARD_AUTH_HEADER ? {
header: process.env.SHELLBOOK_FORWARD_AUTH_HEADER,
trustedProxyIps: proxies,
} : undefined,
},
});
await app.listen({ host, port });