Private
Public Access
S4: the throttle keyed on the first X-Forwarded-For entry, which a client or a proxy that appends can choose, and disabled itself entirely when Redis was down. EVECTION_TRUSTED_PROXIES (IPs/CIDRs of your reverse proxy) makes it strict: X-Forwarded-For is only believed when the TCP peer is a trusted proxy, and the rightmost entry that isn't itself a trusted proxy — the address the proxy actually saw — is used instead of the spoofable first one. Unset keeps the previous behavior so existing installs don't suddenly share one bucket behind a proxy, and `manage.py check --deploy` warns (evection.W001) until it's set. During a Redis outage the throttle now falls back to a bounded in-process limiter instead of switching off. C5: /health/ready/ reuses its queue/feed aggregates for 15s (EVECTION_HEALTH_CACHE_SECONDS) so a fast-polling monitor can't create steady load; the database, Redis and poller probes stay live. Docs cover both settings, restricting the endpoint at the proxy, and the tombstone/purge behavior from the previous changes. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
aacb41d1d3
commit
ac5e951749
12 files changed
+386
-53
No files matched your search
@@ -4,6 +4,7 @@ Base Django settings for Evection, shared by all environments.
|
||||
Environment-specific overrides live in dev.py / prod.py / test.py.
|
||||
"""
|
||||
|
||||
import ipaddress
|
||||
from pathlib import Path
|
||||
|
||||
import environ
|
||||
@@ -122,6 +123,18 @@ EVECTION_SIGNUP_ENABLED = env.bool("EVECTION_SIGNUP_ENABLED", default=False)
|
||||
EVECTION_MIN_FETCH_INTERVAL_MINUTES = env.int("EVECTION_MIN_FETCH_INTERVAL_MINUTES", default=15)
|
||||
EVECTION_PWA_CACHE_VERSION = env.str("EVECTION_PWA_CACHE_VERSION", default="v1")
|
||||
|
||||
# How long /health/ready/ reuses its queue/feed aggregates (0 = never).
|
||||
EVECTION_HEALTH_CACHE_SECONDS = env.int("EVECTION_HEALTH_CACHE_SECONDS", default=15)
|
||||
|
||||
# IPs/CIDRs of the reverse proxy in front of gunicorn. When set, the login
|
||||
# throttle only believes X-Forwarded-For from these peers (see
|
||||
# apps.accounts.throttle.client_address). Empty keeps the legacy behavior.
|
||||
EVECTION_TRUSTED_PROXIES = [
|
||||
ipaddress.ip_network(entry.strip(), strict=False)
|
||||
for entry in env.list("EVECTION_TRUSTED_PROXIES", default=[])
|
||||
if entry.strip()
|
||||
]
|
||||
|
||||
# Redis-backed rather than Django's default per-process LocMemCache: login
|
||||
# rate limiting (apps.accounts.views) must share counters across every
|
||||
# gunicorn worker, not just whichever one happened to handle a given
|
||||
|
||||
@@ -12,3 +12,6 @@ PASSWORD_HASHERS = ["django.contrib.auth.hashers.MD5PasswordHasher"]
|
||||
# location is per-process but shared across tests in that process; see
|
||||
# apps.accounts.test_rate_limit's cache.clear() fixture).
|
||||
CACHES = {"default": {"BACKEND": "django.core.cache.backends.locmem.LocMemCache"}}
|
||||
|
||||
# Tests change state between calls to /health/ready/; caching it would hide that.
|
||||
EVECTION_HEALTH_CACHE_SECONDS = 0
|
||||
Reference in new issue
Block a user