mirror of https://github.com/interlegis/sapl.git
Browse Source
- Move get_client_ip() and ratelimit_ip() from utils.py to sapl/middleware/ratelimit.py (canonical location). utils.py re-exports both via a single import line so all existing callers (comissoes, crud, norma, sessao, painel, parlamentares, protocoloadm) keep working with zero changes. - get_client_ip() is now used inside RateLimitMiddleware instead of the weaker _get_ip(): gains ip_mask() for IPv6 /64 collapsing and HTTP_X_REAL_IP fallback. - Replace getattr(settings, 'X', default) with settings.X throughout __init__: settings.py always defines these vars, defaults were duplicated and would silently drift. django.conf.settings proxy also honours @override_settings in tests, unlike direct module imports. - Replace getattr(..., []) or [] with set(settings.RATE_LIMIT_WHITELIST_IPS): the cast in settings.py always returns a list, the double guard was redundant. - Remove unused _get_ip() and 'from sapl.settings import RATE_LIMITER_RATE'. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>rate-limiter-2026
2 changed files with 33 additions and 32 deletions
Loading…
Reference in new issue