v7.8.2
Route-relative path resolution under root_path and mounts, Starlette and FastAPI floors (v7.8.2)
- Fixed -
StarletteGuardRequest.url_pathand the WebSocket adapter's_WebSocketGuardRequest.url_pathreturnedrequest.url.path/websocket.url.path, which under an ASGIroot_path(uvicorn --root-path, or a mounted sub-app) includes the mount prefix. guard-core matches that value againstSecurityConfig.exclude_pathsandendpoint_rate_limits(an exact dict-key match) and passes it tocustom_request_checkhooks, so a key such as/api/vault/loginnever matched a request actually served at/mounted/api/vault/loginand every path-keyed control silently stopped applying under a mount. Both adapters now return Starlette's ownget_route_path(scope), the same route-relative path Starlette's router already matches routes against. - Compatibility - If
exclude_pathsorendpoint_rate_limitskeys currently include yourroot_pathmount prefix (a workaround for the bug above), remove the prefix after upgrading: those keys now match the route-relative path and a prefixed key silently stops matching. The same applies tocustom_request_checkhooks that branch onurl_path. - Compatibility -
starlette>=0.35.0andfastapi>=0.109.0are now declared floors (no ceilings). Route-relative path resolution usesstarlette.routing.get_route_path, which Starlette added in 0.35.0; 0.109.0 is the first FastAPI release that requires that Starlette. Older pairs fail atimport guardwith anImportError. - Changed - Detection input and the reason text of the
Suspicious activity detectedlog line now use the route-relative path, while theGET <url>part of the same line still shows the full URL including the mount prefix (url_fullis unchanged), so the two differ under a mount by design.
What's Changed
Full Changelog: 7.8.1...7.8.2