A5: sign up, sign in, sign out, profile and the base layout (WEB-02, WEB-06, WEB-11, WEB-50..54)
Registration (case-insensitive unique names, 8-256 char passwords, no email), sign-in with a generic error and a fresh session, internal-only ?next=, POST-only sign-out, password change that closes the other sessions. The failed-login backoff, the registration quota and the password-change guard live in the database so every web process shares them; the client IP is the last X-Forwarded-For hop. One responsive stylesheet with light/dark theme, labelled fields, alerts and no inline scripts or styles; Italian error pages and a readable CSRF failure. Mutation checks: open redirects, uncounted failures and a missing CSRF middleware are all caught. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1d4b53d778
commit
efb3e2e702
28 files changed
+1232
-22
No files matched your search
@@ -1,6 +1,7 @@
|
||||
from django.contrib.auth.models import AbstractUser
|
||||
from django.db import models
|
||||
from django.db.models.functions import Lower
|
||||
from django.utils import timezone
|
||||
|
||||
|
||||
class User(AbstractUser):
|
||||
@@ -14,3 +15,18 @@ class User(AbstractUser):
|
||||
# ADR-38: one case-insensitive namespace. The name is stored as typed.
|
||||
models.UniqueConstraint(Lower("username"), name="accounts_user_username_ci_unique"),
|
||||
]
|
||||
|
||||
|
||||
class ThrottleEvent(models.Model):
|
||||
"""One counted event of a throttle (failed login, registration, wrong current password).
|
||||
|
||||
In the database, not in memory: the web runs as several processes (ADR-55, ARC-72), and a throttle
|
||||
kept in one process's memory is bypassed by whichever other process answers the next request.
|
||||
"""
|
||||
|
||||
scope = models.CharField(max_length=16)
|
||||
key = models.CharField(max_length=150)
|
||||
created_at = models.DateTimeField(default=timezone.now)
|
||||
|
||||
class Meta:
|
||||
indexes = [models.Index(fields=["scope", "key", "created_at"])]
|
||||
Reference in new issue
Block a user