Description:
Create a built-in middleware that automatically sets essential HTTP security headers on every response. This is a critical security feature that modern frameworks should provide out-of-the-box.
Proposed Headers:
Content-Security-Policy - Prevents XSS attacks
X-Frame-Options - Prevents clickjacking
X-Content-Type-Options - Prevents MIME-sniffing
X-XSS-Protection - XSS filter (legacy but still useful)
Strict-Transport-Security (HSTS) - Enforces HTTPS
Referrer-Policy - Controls referrer information
Proposed API:
import AppRoutes from './modules/app/AppRoutes';
import { defineBootstrap } from 'gaman';
defineBootstrap(async (app) => {
app.mount(appRoutes, {
security: {
contentSecurityPolicy: "default-src 'self'",
xFrameOptions: 'DENY',
hsts: true, // max-age in seconds
}
});
})
Description:
Create a built-in middleware that automatically sets essential HTTP security headers on every response. This is a critical security feature that modern frameworks should provide out-of-the-box.
Proposed Headers:
Content-Security-Policy- Prevents XSS attacksX-Frame-Options- Prevents clickjackingX-Content-Type-Options- Prevents MIME-sniffingX-XSS-Protection- XSS filter (legacy but still useful)Strict-Transport-Security(HSTS) - Enforces HTTPSReferrer-Policy- Controls referrer informationProposed API: