Bound credentials, brake password changes, cap bug reports, page the user list, structure every error (B-94, SEC-54, SEC-55, API-09, API-15, API-16, API-19, API-21, API-28, API-33, REG-12, AUD-42)
- login and password-change fields: at most 256 characters
- wrong current password: per-user brake (5 free, 2s doubling to 300s), 429 even for the
right password while locked; password_changed audited in the same transaction
- POST /bug-reports: 10 per IP per hour, consumed only by a stored report
- GET /admin/users: limit/after_id paging, the panel walks the pages
- 401/403/404/405/422/503 all answer {code, message, params}; the 422 omits the input
- static files revalidated on every use (Cache-Control: no-cache)
- error.* keys for the new codes in all seven languages
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c1b192f6d1
commit
24e5fc3d8b
23 files changed
+374
-111
No files matched your search
@@ -186,6 +186,8 @@ class RollingQuota:
|
||||
|
||||
_REGISTRATIONS_PER_IP = 5
|
||||
_REGISTRATION_WINDOW_SECONDS = 3600.0
|
||||
_BUG_REPORTS_PER_IP = 10
|
||||
_BUG_REPORT_WINDOW_SECONDS = 3600.0
|
||||
|
||||
|
||||
class AuthRateLimiters:
|
||||
@@ -208,3 +210,8 @@ class AuthRateLimiters:
|
||||
self.register_ip = RollingQuota(
|
||||
limit=_REGISTRATIONS_PER_IP, window_seconds=_REGISTRATION_WINDOW_SECONDS
|
||||
)
|
||||
# B-94 (SEC-54): wrong `current_password` on a password change, per user — a stolen
|
||||
# token must not be able to guess the password and lock the owner out.
|
||||
self.change_password = RateLimiter(threshold=5, base_delay=2.0, max_delay=300.0)
|
||||
# B-94 (SEC-55): bug reports are anonymous; a quota per IP keeps them from filling the DB.
|
||||
self.bug_reports = RollingQuota(limit=_BUG_REPORTS_PER_IP, window_seconds=_BUG_REPORT_WINDOW_SECONDS)
|
||||
+4
-2
@@ -148,8 +148,10 @@ async def register(
|
||||
|
||||
|
||||
class LoginRequest(BaseModel):
|
||||
username: str
|
||||
password: str
|
||||
# B-94 (API-19): bounded before anything is hashed or counted; a megabyte password would
|
||||
# otherwise be an Argon2 input and a rate-limit key.
|
||||
username: str = Field(max_length=256)
|
||||
password: str = Field(max_length=256)
|
||||
|
||||
|
||||
@router.post("/login", response_model=TokenResponse)
|
||||
|
||||
Reference in new issue
Block a user