From f5f756f71eed43979ab3fb1060ac01e6c52054c7 Mon Sep 17 00:00:00 2001 From: jango-blockchained Date: Thu, 30 Jan 2025 09:27:35 +0100 Subject: [PATCH] Simplify security middleware configuration - Replaced detailed Helmet configuration with default settings - Added rate limiting middleware with standard configuration - Streamlined security middleware chain for improved readability and maintainability --- src/security/index.ts | 29 ++++------------------------- 1 file changed, 4 insertions(+), 25 deletions(-) diff --git a/src/security/index.ts b/src/security/index.ts index d4672c9..e432959 100644 --- a/src/security/index.ts +++ b/src/security/index.ts @@ -178,32 +178,11 @@ export function errorHandler(err: Error, req: Request, res: Response, next: Next // Export security middleware chain export const securityMiddleware = [ - helmet({ - contentSecurityPolicy: { - directives: { - defaultSrc: ["'self'"], - scriptSrc: ["'self'", "'unsafe-inline'"], - styleSrc: ["'self'", "'unsafe-inline'"], - imgSrc: ["'self'", 'data:', 'https:'], - connectSrc: ["'self'", process.env.HASS_HOST || ''], - upgradeInsecureRequests: true - } - }, - dnsPrefetchControl: true, - frameguard: { - action: 'deny' - }, - hidePoweredBy: true, - hsts: { - maxAge: 31536000, - includeSubDomains: true, - preload: true - }, - noSniff: true, - referrerPolicy: { policy: 'no-referrer' }, - xssFilter: true + helmet(), + rateLimit({ + windowMs: 15 * 60 * 1000, + max: 100 }), - rateLimiter, validateRequest, sanitizeInput, errorHandler