Skip to content

2.35.4: throttle failed /admin logins (django-axes) - #1466

Merged
jonfroehlich merged 4 commits into
masterfrom
1460-admin-login-throttle
Nov 25, 2026
Merged

jonfroehlich merged 4 commits into
masterfrom
1460-admin-login-throttle

Conversation

@jonfroehlich

Copy link
Copy Markdown
Member

Part of #1460.

What changed

Adds django-axes 9.0.0 so repeated wrong passwords at /admin/login/ lock the account for a while. Standard practice for any Django admin on the public internet.

Policy: 10 wrong passwords in a row lock that username for 30 minutes. A locked username gets HTTP 429 even with the right password. A correct login resets the count.

  • Per username, not per IP. The site sits behind a reverse proxy, so the client address Django sees may not be the visitor's. An IP key could lock out everyone or no one.
  • Lockouts don't extend. More guesses during the 30 minutes do not restart the clock.
  • Unlocking: it clears by itself, or a superuser deletes the row under Admin → Administration → Access attempts. Documented in docs/ADMIN_USERS_AND_GROUPS.md.
  • Admin: the three axes models are grouped under Administration. Only superusers have permissions on them.
  • Tests: AXES_ENABLED = False in settings_test.py, because client.login() passes no request to the axes backend. website/tests/test_login_throttle.py turns it back on for 7 tests covering lock, no-lock, reset, per-username isolation and the pinned policy.

Verification

  • In a container: makemigrations axes --check reports no changes (axes ships its own migrations; the startup migrate applies them), and manage.py check is clean apart from the deliberately silenced axes.W006.
  • The new tests and the full suite: CI on this PR (not run locally, no local database was up).

After merge

On -test: sign in to /admin normally, then confirm "Access attempts" and "Access logs" appear under Administration. Local dev needs an image rebuild (requirements.txt changed).

🤖 Generated with Claude Code — Fable 5.2, claude-fable-5-2

Nothing limited password guessing against /admin/login/. django-axes 9.0.0
now locks a username for 30 minutes after 10 consecutive wrong passwords
(HTTP 429), with counts in the database so all Gunicorn workers share them.

- Keyed on username only: behind the CSE proxy the client IP is unreliable.
  Further guesses during a lockout do not extend it.
- Axes models grouped under Administration in the admin (superuser-only).
- settings_test disables axes (client.login passes no request);
  test_login_throttle.py re-enables it and pins the policy (7 tests).
- axes.W006 (no ip_address key) silenced deliberately, with the reason.

Part of #1460.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@jonfroehlich jonfroehlich added Admin Dependencies Pull requests that update a dependency file Security Security: XSS, auth, dependency CVEs, hardening labels Nov 22, 2026
jonfroehlich and others added 2 commits November 23, 2026 08:38
…holder usernames

- Wire django-axes in only when the package is importable, so a Gunicorn
  worker restarted mid-deploy (old image, new checkout) still boots.
- ML_DISABLE_LOGIN_THROTTLE=true (from the repository variable
  DISABLE_LOGIN_THROTTLE) turns throttling off without a commit; superusers
  see a dashboard warning whenever it is off.
- Record names that match no account as one placeholder, so a password typed
  into the username box is never stored.
- Enable the failed-login history, add an accessible lockout page, and
  correct the docs (rows, not row; no shell on the servers).
- Tests for the placeholder, failure log, lockout page, unlock path,
  superuser-only admin, and the on/off switch.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@jonfroehlich

Copy link
Copy Markdown
Member Author

Review fixes (independent Opus 5.5 review, then fixes in the latest commit)

No must-fix findings. Addressed:

  • Deploy safety: axes is wired in only when the package is importable, so a Gunicorn worker restarted while the old image runs the new checkout still boots.
  • Emergency switch: repository variable DISABLE_LOGIN_THROTTLE=true plus a redeploy turns throttling off without a commit. Superusers see a dashboard warning whenever throttling is off.
  • Privacy: names that match no account are recorded as one placeholder, so a password typed into the username box is never stored.
  • Failed-login history is now enabled (it was listed in the admin but always empty).
  • Lockout page: a proper HTML page (title, lang, what to do next) instead of bare text.
  • Docs: corrected (rows, not row; no shell on the servers) and a recovery runbook added.
  • Tests: 7 → 17, covering the placeholder, failure log, lockout page and Retry-After, the admin unlock path, superuser-only access, and the on/off switch.

Follow-up, not in this PR: keying the lock on client IP as well, once the proxy's forwarding header is confirmed.

🤖 Generated with Claude Code — Fable 5.2, claude-fable-5-2

… tests

Second review pass. Unknown usernames are now recorded as a keyed hash per
name instead of one shared placeholder, so they are throttled exactly like
real accounts. The off switch also accepts 1/yes/on, the lockout page says
"within" N minutes, and tests now cover the switch end to end and the
superuser-only dashboard warning.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@jonfroehlich
jonfroehlich merged commit 9e87d21 into master Nov 25, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Admin Dependencies Pull requests that update a dependency file Security Security: XSS, auth, dependency CVEs, hardening

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant