feat: add password login and bearer sessions
- Argon2id password hashes, KDF in a thread with its own limit - POST /auth/sessions with Basic, DELETE /auth/sessions/current - Bearer sessions in PostgreSQL, X-User-Id ignored - migration drops lab 1 data without passwords - student-tests on tokens, sessions spec and synced specs Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -79,6 +79,20 @@ class Database(BaseModel):
|
||||
)
|
||||
|
||||
|
||||
class Auth(BaseModel):
|
||||
"""Сессии и пароли; значения — из `config.toml`.
|
||||
|
||||
Контрактное `SESSION_TTL_SECONDS` сопоставлено с `session_ttl_seconds`
|
||||
в `REPORT.md`; разовая подмена — окружением `AUTH__SESSION_TTL_SECONDS`.
|
||||
"""
|
||||
|
||||
# секунды жизни сессии с момента входа
|
||||
session_ttl_seconds: int = Field(default=3600, gt=0)
|
||||
# сколько хэшей пароля считается одновременно: Argon2id берёт 64 MiB
|
||||
# памяти на каждый
|
||||
kdf_concurrency: int = Field(default=4, gt=0)
|
||||
|
||||
|
||||
class Settings(BaseSettings):
|
||||
model_config = SettingsConfigDict(
|
||||
extra="ignore",
|
||||
@@ -90,6 +104,7 @@ class Settings(BaseSettings):
|
||||
|
||||
app: App = App()
|
||||
database: Database = Database()
|
||||
auth: Auth = Auth()
|
||||
|
||||
@classmethod
|
||||
def settings_customise_sources(
|
||||
|
||||
Reference in New Issue
Block a user