fix(security): harden security headers across API and Web apps
- API: set X-Frame-Options to DENY via frameguard, add Permissions-Policy header, widen CSP connect-src for Swagger CDN - Web: add HSTS header (1yr, includeSubDomains, preload), add payment=(self) to Permissions-Policy, make localhost:3001 in CSP connect-src dev-only Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -61,7 +61,7 @@ async function bootstrap() {
|
||||
scriptSrc: ["'self'", "'unsafe-inline'", 'https://cdn.jsdelivr.net'],
|
||||
styleSrc: ["'self'", "'unsafe-inline'", 'https://cdn.jsdelivr.net'],
|
||||
imgSrc: ["'self'", 'data:', 'https:', 'blob:'],
|
||||
connectSrc: ["'self'"],
|
||||
connectSrc: ["'self'", 'https://cdn.jsdelivr.net'],
|
||||
fontSrc: ["'self'", 'data:'],
|
||||
objectSrc: ["'none'"],
|
||||
frameSrc: ["'none'"],
|
||||
@@ -72,11 +72,21 @@ async function bootstrap() {
|
||||
crossOriginEmbedderPolicy: true,
|
||||
crossOriginOpenerPolicy: true,
|
||||
crossOriginResourcePolicy: { policy: 'same-origin' },
|
||||
frameguard: { action: 'deny' },
|
||||
hsts: { maxAge: 31536000, includeSubDomains: true, preload: true },
|
||||
referrerPolicy: { policy: 'strict-origin-when-cross-origin' },
|
||||
}),
|
||||
);
|
||||
|
||||
// ── Permissions-Policy Header ──
|
||||
app.use((_req: unknown, res: { setHeader: (name: string, value: string) => void }, next: () => void) => {
|
||||
res.setHeader(
|
||||
'Permissions-Policy',
|
||||
'camera=(), microphone=(), geolocation=(self), payment=(self)',
|
||||
);
|
||||
next();
|
||||
});
|
||||
|
||||
// ── Cookie Parser (required for CSRF double-submit pattern) ──
|
||||
app.use(cookieParser());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user