From 394273d4b39e69ab34a01bf6ecb0f869eddd0b7e Mon Sep 17 00:00:00 2001 From: Agzamus Date: Mon, 12 Oct 2026 15:42:00 +0300 Subject: [PATCH] =?UTF-8?q?feat:=202.1=20=D0=A1=D0=BE=D0=B7=D0=B4=D0=B0?= =?UTF-8?q?=D1=82=D1=8C=20=D0=BC=D0=BE=D0=B4=D1=83=D0=BB=D1=8C=20`app/conf?= =?UTF-8?q?ig.py`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/config.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 app/config.py diff --git a/app/config.py b/app/config.py new file mode 100644 index 0000000..56baefb --- /dev/null +++ b/app/config.py @@ -0,0 +1,33 @@ +from pydantic import model_validator +from pydantic_settings import BaseSettings, SettingsConfigDict + + +class Settings(BaseSettings): + database_url: str = "sqlite:///./vault.db" # строка подключения к БД; + jwt_secret: str = "" # секрет для подписи JWT; + jwt_algorithm: str = "HS256" # по умолчанию `HS256`; + access_token_ttl_min: int = 60 # время жизни access-токена в минутах; + password_pepper: str = "" # глобальный «перец» для паролей; + password_min_length: int = 12 # минимальная длина пароля; + environment: str = "development" # служебные поля. + app_name: str = "Vault" # служебные поля. + + model_config = SettingsConfigDict( + env_file=".env", + env_file_encoding="utf-8", + extra="ignore", + ) + + @model_validator(mode="after") + def _require_secrets(self) -> "Settings": + missing = [ + name + for name in ("jwt_secret", "password_pepper") + if not getattr(self, name) + ] + if missing: + raise ValueError("Missing required settings: " + ", ".join(missing)) + return self + + +settings = Settings()