Sicherheit: HTTP-Security-Header und Origin-Prüfung für schreibende Routen
- X-Frame-Options/CSP frame-ancestors gegen Clickjacking, nosniff, Referrer-Policy, Permissions-Policy - Origin-Check als CSRF-Defense-in-Depth für /api/admin/users und /logout (zusätzlich zu SameSite=Lax-Cookies und JSON-Content-Type)
This commit is contained in:
+22
-1
@@ -1,7 +1,28 @@
|
||||
import type { NextConfig } from "next";
|
||||
|
||||
// HTTP-Security-Header für alle Routen.
|
||||
// HTTPS/HSTS übernimmt im Live-Betrieb der Reverse-Proxy.
|
||||
const securityHeaders = [
|
||||
// Verhindert Einbettung in fremde Seiten (Clickjacking)
|
||||
{ key: "X-Frame-Options", value: "DENY" },
|
||||
{ key: "Content-Security-Policy", value: "frame-ancestors 'none'" },
|
||||
// Browser darf Content-Types nicht "erraten"
|
||||
{ key: "X-Content-Type-Options", value: "nosniff" },
|
||||
// Keine vollständigen URLs an fremde Seiten weitergeben
|
||||
{ key: "Referrer-Policy", value: "strict-origin-when-cross-origin" },
|
||||
// Sensorische APIs werden nicht benötigt
|
||||
{ key: "Permissions-Policy", value: "camera=(), microphone=(), geolocation=()" },
|
||||
];
|
||||
|
||||
const nextConfig: NextConfig = {
|
||||
/* config options here */
|
||||
async headers() {
|
||||
return [
|
||||
{
|
||||
source: "/(.*)",
|
||||
headers: securityHeaders,
|
||||
},
|
||||
];
|
||||
},
|
||||
};
|
||||
|
||||
export default nextConfig;
|
||||
|
||||
Reference in New Issue
Block a user