anderson-ufrj commited on
Commit
ac4a861
·
1 Parent(s): 71ebb65

fix: expand header whitelist for API authentication and caching headers

Browse files

Added essential HTTP headers to the security middleware skip list:
- authorization, x-api-key: Required for API authentication
- content-type, content-length: Standard HTTP headers
- cookie: Session management
- cache-control, pragma, expires: HTTP caching headers
- if-none-match, if-modified-since: Conditional request headers

These headers are commonly used in legitimate API requests and should
not be validated for suspicious patterns. This resolves the "Invalid
request headers" error when the frontend tries to communicate with
the backend API.

Files changed (1) hide show
  1. src/api/middleware/security.py +4 -1
src/api/middleware/security.py CHANGED
@@ -235,7 +235,10 @@ class RequestValidator:
235
  "user-agent", "accept", "accept-language", "accept-encoding",
236
  "referer", "origin", "x-direct-url", "x-forwarded-for",
237
  "x-forwarded-proto", "x-forwarded-host", "x-real-ip",
238
- "host", "connection", "upgrade-insecure-requests"
 
 
 
239
  }
240
  for name, value in request.headers.items():
241
  if name.lower() in skip_headers:
 
235
  "user-agent", "accept", "accept-language", "accept-encoding",
236
  "referer", "origin", "x-direct-url", "x-forwarded-for",
237
  "x-forwarded-proto", "x-forwarded-host", "x-real-ip",
238
+ "host", "connection", "upgrade-insecure-requests",
239
+ "authorization", "x-api-key", "content-type", "content-length",
240
+ "cookie", "cache-control", "pragma", "expires",
241
+ "if-none-match", "if-modified-since"
242
  }
243
  for name, value in request.headers.items():
244
  if name.lower() in skip_headers: