Repository navigation
fix(handler): route passthrough, bypass and the response pass through the engine like fastapi-guard - #39
Merged
Conversation
… the engine like fastapi-guard Use the engine BypassHandler for passthrough and the route all-checks bypass, with the real handler method as the downstream. Run the engine response pass from SecurityHandler.finish before the response is flushed, so the modifier, security headers, CORS and body-based and global return rules take effect. Emit request metrics only for responses that reach the view. Return a 503 when Redis is unavailable at initialization. Align the guard-core floor with the other adapters.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Aligns the Tornado adapter with fastapi-guard's engine routing.
BypassHandler: a request with no client address gets thefail_secure403, excluded paths stay scoped (checks still run), and a bypassed route calls the real handler method with the modifier applied.SecurityHandler.finish()runs the engine response pass before the response is flushed, instead ofon_finishafter it was sent.custom_response_modifier, the security headers, CORS and return-rule effects now reach the client, body-based return rules see the buffered body, and global behavior return rules are passed.Retry-After.SecurityMiddleware.apply_pre_flight_headersis removed (it was the reimplemented path), and the docs describe the new flow.>=4.0.0to>=4.1.0, the first release with the engine APIs used and the floor the other adapters declare.Streamed responses that call
flush()beforefinish()have their headers on the wire already, so the pass observes them (metrics, return rules over the buffered body) but cannot change them.Tests
New
tests/test_engine_parity.pyruns a real Tornado server and client against the real engine handlers. The tests that asserted the old_check_bypassbehavior and the removed pre-flight headers are replaced. Full suite with--cov-fail-under=100andpre-commit run --all-filespass.Closes #38