mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-02-10 06:45:28 -05:00
### Why? 🤔 <!-- Clearly explain the need for these changes: --> We need to prevent sensitive data (authentication tokens, API keys, user credentials, personal information) from being cached by browsers and proxies. Following the principle of "secure by default", we're switching from a deny list to an allow list approach for cache control. ### Changes 🛠️ <!-- Concisely describe all of the changes made in this pull request: --> - **Refactored cache control middleware from deny list to allow list approach** - By default, ALL endpoints now have `Cache-Control: no-store, no-cache, must-revalidate, private` headers - Only explicitly allowed paths (static assets, health checks, public store pages) can be cached - This ensures new endpoints are automatically protected without developers having to remember to add them to a list - **Updated `SecurityHeadersMiddleware` in `/backend/backend/server/middleware/security.py`** - Renamed `SENSITIVE_PATHS` to `CACHEABLE_PATHS` - Inverted the logic in `is_cacheable_path()` method - Cache control headers are now applied to all paths NOT in the allow list - **Updated test suite to match new behavior** - Tests now verify that most endpoints have cache control headers by default - Tests verify that only allowed paths (static assets, health endpoints, etc.) can be cached - **Updated documentation in `CLAUDE.md`** - Documented the new allow list approach - Added instructions for developers on how to allow caching for new endpoints ### Checklist 📋 #### For code changes: - [x] I have clearly listed my changes in the PR description - [x] I have made a test plan - [x] I have tested my changes according to the test plan: <!-- Put your test plan here: --> - [x] Test modified endpoints work still - [x] Test modified endpoints correctly have no cache rules --------- Co-authored-by: Swifty <craigswift13@gmail.com>