dragonflight/services/mam-api/test/routes
Zac Gaetano 96effaaa3c fix(mam-api): TRUST_PROXY boot warning + CSRF integration tests + bounded rate-limit map
Fixes three issues in the authentication system:

C1: Add boot-time warning when AUTH_ENABLED=true but TRUST_PROXY!=true.
    Without TRUST_PROXY=true behind nginx, req.ip becomes the proxy IP for all
    clients, collapsing per-IP rate limiting into a shared pool. Operators must
    explicitly set TRUST_PROXY=true to make per-IP rate limiting effective.

C2: Mount requireUiHeader middleware in test helpers (auth.test.js,
    users.test.js, tokens.test.js). The CSRF header validation was not being
    exercised in the test suite. Tests now send X-Requested-With: dragonflight-ui
    headers that are actually validated by the middleware.

I1: Implement bounded rate-limit Map with MAX_ENTRIES=10000 and LRU eviction.
    Unbounded Maps are vulnerable to spray attacks: attackers can force memory
    exhaustion by requesting with distinct IPs. Now we evict the oldest entry
    (by insertion order) when the map reaches capacity.
2026-05-27 15:03:35 -04:00
..
auth.test.js fix(mam-api): TRUST_PROXY boot warning + CSRF integration tests + bounded rate-limit map 2026-05-27 15:03:35 -04:00
tokens.test.js fix(mam-api): TRUST_PROXY boot warning + CSRF integration tests + bounded rate-limit map 2026-05-27 15:03:35 -04:00
users.test.js fix(mam-api): TRUST_PROXY boot warning + CSRF integration tests + bounded rate-limit map 2026-05-27 15:03:35 -04:00