Skip to content

fix(middleware): pass global behavior rules and require GUARD_SECURITY_CONFIG like fastapi-guard - #39

Merged
rennf93 merged 2 commits into
masterfrom
fix/engine-parity
Oct 15, 2026
Merged

rennf93 merged 2 commits into
masterfrom
fix/engine-parity

Conversation

@rennf93

@rennf93 rennf93 commented Oct 15, 2026

Copy link
Copy Markdown
Member

Summary

Aligns the Django adapter with fastapi-guard's engine routing.

  • global_behavior_rules are passed to the engine response pass, so global return rules fire.
  • A missing settings.GUARD_SECURITY_CONFIG raises ImproperlyConfigured instead of silently falling back to SecurityConfig() 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.py drives 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=100 and pre-commit run --all-files pass.

Closes #38

…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.
@rennf93 rennf93 self-assigned this Oct 15, 2026
@github-actions github-actions Bot added area: middleware Touches djangoapi_guard/middleware.py (Django middleware adapter) tests Test suite changes labels Oct 15, 2026
… 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).
@github-actions github-actions Bot added documentation Docs, README, CHANGELOG, governance files examples examples/ projects labels Oct 15, 2026
@rennf93
rennf93 merged commit d55c31c into master Oct 15, 2026
12 checks passed
@rennf93
rennf93 deleted the fix/engine-parity branch October 15, 2026 10:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: middleware Touches djangoapi_guard/middleware.py (Django middleware adapter) documentation Docs, README, CHANGELOG, governance files examples examples/ projects tests Test suite changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Django adapter drops global behavior rules and silently defaults a missing config

1 participant