Repository navigation
fix(middleware): pass global behavior rules and require GUARD_SECURITY_CONFIG like fastapi-guard - #39
Merged
Merged
Conversation
…Y_CONFIG like fastapi-guard Pass global behavior return rules to the engine response pass. Raise ImproperlyConfigured when GUARD_SECURITY_CONFIG is unset instead of silently running with SecurityConfig() defaults. Add real-routing parity tests for passthrough, bypass, blocked and global rules.
… the advanced example The README examples used a plain dict and a nonexistent djangoapi_guard.models import, which cannot work now that a missing or non-SecurityConfig setting is rejected. Convert them to SecurityConfig, state that the setting is required, and fix the advanced example so it starts (status: return pattern, guard request and response API in its hooks).
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 Django adapter with fastapi-guard's engine routing.
global_behavior_rulesare passed to the engine response pass, so global return rules fire.settings.GUARD_SECURITY_CONFIGraisesImproperlyConfiguredinstead of silently falling back toSecurityConfig()defaults. The repo docs that described the fallback are updated.The existing test that asserted the fallback now asserts the error.
Tests
New
tests/test_engine_parity.pydrives the middleware over Django's real URL resolution and views, with the real engine bypass handler and response factory, and pins excluded path scoping, the no-client-address fail_secure 403, route bypass, blocked requests emitting no request metrics, and global return rules. Full suite with--cov-fail-under=100andpre-commit run --all-filespass.Closes #38