mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 06:39:28 +08:00
Add an off-by-default `security_guard` setting (system.json, with DEEPTUTOR_GUARD_* deployment overrides) that mounts fastapi-guard's pure-ASGI middleware in front of the routers: per-address rate limit, IP allow/deny lists, ban list and an attack-pattern scan of path, query and headers. Request bodies, WebSocket handshakes, Redis, CORS and security headers are left alone. The guard is added before the access-log and CORS middlewares so CORS stays outermost and 429/403 responses carry CORS headers. When disabled the package is never imported. When enabled without the package the backend fails at startup with an install hint. fastapi-guard ships as the optional `guard` extra (requirements/guard.txt, DEEPTUTOR_EXTRAS).