from django.conf import settings from django.core.checks import Tags, Warning, register @register(Tags.security, deploy=True) def trusted_proxies_configured(app_configs, **kwargs): if settings.DEBUG or settings.EVECTION_TRUSTED_PROXIES: return [] return [ Warning( "EVECTION_TRUSTED_PROXIES is not set.", hint=( "The login throttle then trusts the first X-Forwarded-For entry from " "anyone, which only holds while gunicorn is reachable by nothing but a " "proxy that overwrites that header. Set EVECTION_TRUSTED_PROXIES to your " "reverse proxy's IP/CIDR in .env (see docs/install.md)." ), id="evection.W001", ) ]