Private
Public Access
Django's default LoginView had no throttle — an internet-facing instance was exposed to unlimited password-guessing/credential- stuffing attempts. apps.accounts.views.LoginView adds two independent, Redis-cache-backed throttles (shared across all gunicorn workers, unlike the per-process default LocMemCache): by client address (catches one attacker spraying many usernames) and by the submitted username (catches a distributed attack on one specific account). Either blocks further attempts for a 5-minute window; both are generous enough not to lock out a user who's just mistyped their own password a few times. Client address prefers X-Forwarded-For's first hop, falling back to REMOTE_ADDR — the same reverse-proxy trust boundary config.settings.prod already relies on for X-Forwarded-Proto (gunicorn is never meant to be reachable except through that proxy). CACHES now points at Redis (already a hard install requirement for Celery) instead of Django's implicit per-process default, since the whole point is a shared counter across every gunicorn worker; test settings override it back to LocMemCache so the suite doesn't need a real Redis instance. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
15 lines
448 B
Python
15 lines
448 B
Python
from django.contrib.auth import views as auth_views
|
|
from django.urls import path
|
|
|
|
from . import views
|
|
|
|
app_name = "accounts"
|
|
|
|
urlpatterns = [
|
|
path("setup/", views.setup, name="setup"),
|
|
path("login/", views.LoginView.as_view(), name="login"),
|
|
path("logout/", auth_views.LogoutView.as_view(), name="logout"),
|
|
path("users/", views.manage_users, name="manage_users"),
|
|
path("users/create/", views.create_user, name="create_user"),
|
|
]
|