From 39df3dd7d509bec2c19b42d9692a6f5461c4a773 Mon Sep 17 00:00:00 2001 From: Alexander Whitestone <8633216+AlexanderWhitestone@users.noreply.github.com> Date: Sun, 1 Mar 2026 11:47:11 -0500 Subject: [PATCH] feat: add security middleware suite - CSRF, security headers, and request logging (#104) Implements three security middleware components with full test coverage: - CSRF Protection: Token generation/validation, safe method allowlist, auto-exempt webhooks, constant-time comparison for timing attack prevention - Security Headers: X-Content-Type-Options, X-Frame-Options, CSP, Permissions-Policy, Referrer-Policy, HSTS (production) - Request Logging: Method/path/status/duration logging with correlation IDs, configurable path exclusions, X-Forwarded-For support Also fixes Discord test isolation issue where settings.discord_token was not being properly reset between tests. New files: - src/dashboard/middleware/{csrf,security_headers,request_logging}.py - tests/dashboard/middleware/test_{csrf,security_headers,request_logging}.py Addresses design review recommendations R3, R8, R9, R4. All tests pass: 1950 passed, 40 skipped Co-authored-by: Alexander Payne