This release is a pre-release and may not be stable for production use.
django-sec-audit-enforcement
The enforcement layer for django-sec-audit. It turns the
detection brain in sec-audit-rules into action: it holds
block state (temp blocks in Redis, permanent blocks in Postgres with a Redis
read-through cache), applies a matched rule's RuleAction as a block, checks
incoming requests against active blocks before the view runs, and emits every
enforcement decision as OTel JSONL on the existing sec_audit.audit logger.
Status: alpha. Master switch is off by default — installing the package is
inert until SEC_AUDIT_ENFORCEMENT['enabled'] is set.
Design
- Temp blocks → Redis only (self-expiring TTL keys). Permanent blocks → Postgres (durable, auditable) + a Redis read-through cache carrying a long refresh TTL (never a no-TTL key, which managed Redis can silently evict).
- One scope vocabulary (
ip/user/session/route) shared with detection, via thesec-audit-rulesScopeRegistry. Theipscope is resolved throughdjango-sec-audit's trusted-proxy config — never a rawX-Forwarded-For. - Fail-open by default, per-path fail-closed opt-in.
- No feedback loop: emitted
audit.enforcement.*events are skipped by the rule engine.
Documentation
Full docs live in docs/:
- Getting started — install,
INSTALLED_APPS/MIDDLEWARE, migrate, enable, verify - Configuration — every
SEC_AUDIT_ENFORCEMENTkey +rule_actions/block_rules - Architecture — the ingress/egress paths, the tiered store, fail modes
- Custom rules — write and register your own
Rule - Enforcement events — the four
audit.enforcement.*events - Operations — deploy tiers, system checks, the
PermanentBlockmodel, revocation
Custom rules
The built-in rules (brute_force_login, login_throttle,
repeated_client_error, and resource_enumeration — alert-only, and active only
when a history store such as Redis is configured) can be extended with your own.
Subclass sec_audit.rules.Rule, then register it via
SEC_AUDIT_ENFORCEMENT['rules'] (appended to the built-ins):
SEC_AUDIT_ENFORCEMENT = {
'enabled': True,
'rules': ['myapp.security.rules.GeoVelocityRule'],
# observe-only until you map the rule's name to an action:
'rule_actions': {'geo_velocity': {'action': 'temp_block', 'scopes': ['ip']}},
}
A custom rule observes (detect + log, no block) until it has a rule_actions
entry, and runs on the egress path unless it sets safe_for_enforcement = True.
See the full Custom rules guide.
Metadata
Release files for django-sec-audit-enforcement 0.1.0a3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django_sec_audit_enforcement-0.1.0a3.tar.gz | 59.2 kB | Without provenance | Details for django_sec_audit_enforcement-0.1.0a3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_sec_audit_enforcement-0.1.0a3-py3-none-any.whl | Python 3 | none | any | Details for django_sec_audit_enforcement-0.1.0a3-py3-none-any.whl |
Total release size: 101.0 kB
Release files / django_sec_audit_enforcement-0.1.0a3.tar.gz
| Download URL | django_sec_audit_enforcement-0.1.0a3.tar.gz |
|---|---|
| Size | 59.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
99567e22f883bedcb1afe594863966e6897c523c5ec89d0e184238b189249b6e
|
|
BLAKE2b-256 checksum How to use checksums |
7bf9b34d084c1dd3b561cc335e663adbdccbcbd20d456ff3c04a14008bb86970
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.2
|
Release files / django_sec_audit_enforcement-0.1.0a3-py3-none-any.whl
| Download URL | django_sec_audit_enforcement-0.1.0a3-py3-none-any.whl |
|---|---|
| Size | 41.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2ce395ea3d5411cc66cba62f3f3b5489dcf283181239d0b2e0b2ec4e6083c543
|
|
BLAKE2b-256 checksum How to use checksums |
fd66eac89d34c927186b402815c87b593fce593b3379da3c7abb8f2a1dde4c1b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.2
|
Security for django-sec-audit-enforcement 0.1.0a3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.