style: format docs, fix user_permissions variable scoping in auth middleware

Apply ruff line-wrapping formatting to docs and test files.
Clarify auth middleware: extract user_permissions once before
subsystem check, removing conditional variable scoping.
This commit is contained in:
2026-07-27 18:37:11 +00:00
parent d4213fb93b
commit ca110c321d
9 changed files with 640 additions and 26 deletions
+3 -2
View File
@@ -68,7 +68,9 @@ def rotate_user_secret(username: str) -> None:
new_secret = secrets.token_urlsafe(32)
db = get_db()
db.run(Q_UPDATE_JWT_SECRET, (new_secret, username))
logger.warning("JWT secret rotated for %r — their existing tokens are now invalid", username)
logger.warning(
"JWT secret rotated for %r — their existing tokens are now invalid", username
)
def get_access_ttl() -> int:
@@ -343,7 +345,6 @@ def blacklist_expired() -> None:
db.run(Q_DELETE_EXPIRED_BLACKLIST, (now,))
class RateLimiter:
"""Simple sliding-window rate limiter for login attempts.
+3 -1
View File
@@ -56,7 +56,9 @@ class SQLiteBackend(Database):
# Schema init is handled by direct execution, not prepared statements
# init_tables is called as _execute_direct(INIT_SQL)
# Users
Q_INSERT_USER: ("INSERT INTO users (username, password_hash, jwt_secret) VALUES (?, ?, ?)"),
Q_INSERT_USER: (
"INSERT INTO users (username, password_hash, jwt_secret) VALUES (?, ?, ?)"
),
Q_SELECT_USER_BY_NAME: (
"SELECT id, username, password_hash, jwt_secret, created_at FROM users WHERE username = ?"
),