Add a content security policy and expire mailed export links.

Responses had no CSP, the 48-hour download token never changed, and short share slugs could be guessed without a miss limit.
This commit is contained in:
adilallo committed 2026-11-21 11:46:16 -07:00
1 parent 0fe2624002
commit 75649a9a42
18 files changed
+249 -19

No files matched your search

+23
View File
@@ -0,0 +1,23 @@
import { describe, expect, it } from "vitest";
import nextConfig from "../../next.config.mjs";
describe("security headers", () => {
it("drops X-Powered-By and sends a same-origin CSP", async () => {
expect(nextConfig.poweredByHeader).toBe(false);
const rows = await nextConfig.headers();
const globalHeaders = rows.find((row) => row.source === "/(.*)")?.headers;
expect(globalHeaders).toBeDefined();
const byKey = Object.fromEntries(
(globalHeaders ?? []).map((header) => [header.key, header.value]),
);
expect(byKey["Content-Security-Policy"]).toContain("default-src 'self'");
expect(byKey["Content-Security-Policy"]).toContain("script-src 'self'");
expect(byKey["Content-Security-Policy"]).toContain("style-src 'self'");
expect(byKey["Content-Security-Policy"]).toContain("font-src 'self'");
expect(byKey["Content-Security-Policy"]).toContain("img-src 'self'");
expect(byKey["Permissions-Policy"]).toBe(
"camera=(), microphone=(), geolocation=()",
);
expect(byKey["Referrer-Policy"]).toBe("same-origin");
});
});