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
Rules
Nothing runs unless you register it. SEC_AUDIT_ENFORCEMENT['rules'] is the
single registration surface: list the shipped built-ins
(sec_audit.rules.builtins.* — brute_force_login, login_throttle,
repeated_client_error, and resource_enumeration, the last alert-only and
active only when a history store such as Redis is configured) and/or your own
sec_audit.rules.Rule subclasses. The registered set is exactly what you declare:
SEC_AUDIT_ENFORCEMENT = {
'enabled': True,
'rules': [
'sec_audit.rules.builtins.BruteForceLoginRule', # a shipped built-in
'myapp.security.rules.GeoVelocityRule', # your own
],
# observe-only until you map the rule's name to an action:
'rule_actions': {'geo_velocity': {'action': 'temp_block', 'scopes': ['ip']}},
}
A built-in carries a scope-safe default action (it blocks once registered). 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.0a4
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.0a4.tar.gz | 71.7 kB | Without provenance | Details for django_sec_audit_enforcement-0.1.0a4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_sec_audit_enforcement-0.1.0a4-py3-none-any.whl | Python 3 | none | any | Details for django_sec_audit_enforcement-0.1.0a4-py3-none-any.whl |
Total release size: 120.4 kB
Release files / django_sec_audit_enforcement-0.1.0a4.tar.gz
| Download URL | django_sec_audit_enforcement-0.1.0a4.tar.gz |
|---|---|
| Size | 71.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f0ac7ee3a8df386fcdda2694a0248ad523210e989b0035f0bbcb623644a22184
|
|
BLAKE2b-256 checksum How to use checksums |
f0010e9eea50793e79ca8096551168f845b0e43f2932b246965c09b5d0205f89
|
| 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.0a4-py3-none-any.whl
| Download URL | django_sec_audit_enforcement-0.1.0a4-py3-none-any.whl |
|---|---|
| Size | 48.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9b48a542fdd0d781d81806ced07f85412fb56e28306ba42d324f1430c20d8ce5
|
|
BLAKE2b-256 checksum How to use checksums |
8dc5bd2a5aff4944f18b2367978f31c3a48ac6f7a792ef3ab5a680a413edffd9
|
| 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.0a4
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.