Files
Messenger/app/config/settings.py
benya ab65a8b768
All checks were successful
CI / test (push) Successful in 21s
Implement real SMTP delivery and transactional email auth flow
Email delivery:

- Replaced logging-only email sender with aiosmtplib SMTP implementation.

- Added provider mode switch via EMAIL_PROVIDER (log/smtp).

- Added TLS/SSL and timeout controls for SMTP transport.

Auth registration flow:

- Made register/resend/reset email flows transactional with rollback on delivery failure.

- Return 503 when verification/reset email cannot be delivered.

Configuration:

- Extended settings and env templates for EMAIL_PROVIDER, SMTP_USE_SSL, SMTP_TIMEOUT_SECONDS.

- Updated docker-compose environment mapping for new SMTP variables.
2026-03-07 22:24:22 +03:00

53 lines
1.8 KiB
Python

from pydantic import Field
from pydantic_settings import BaseSettings, SettingsConfigDict
class Settings(BaseSettings):
app_name: str = "BenyaMessenger"
environment: str = "development"
debug: bool = True
api_v1_prefix: str = "/api/v1"
auto_create_tables: bool = True
secret_key: str = Field(default="change-me-please-12345", min_length=16)
access_token_expire_minutes: int = 30
refresh_token_expire_days: int = 30
jwt_algorithm: str = "HS256"
email_verification_token_expire_hours: int = 24
password_reset_token_expire_hours: int = 1
postgres_dsn: str = "postgresql+asyncpg://postgres:postgres@localhost:5432/messenger"
redis_url: str = "redis://localhost:6379/0"
s3_endpoint_url: str = "http://localhost:9000"
s3_access_key: str = "minioadmin"
s3_secret_key: str = "minioadmin"
s3_region: str = "us-east-1"
s3_bucket_name: str = "messenger-media"
s3_presign_expire_seconds: int = 900
max_upload_size_bytes: int = 104857600
frontend_base_url: str = "http://localhost:5173"
smtp_host: str = "localhost"
smtp_port: int = 1025
smtp_username: str = ""
smtp_password: str = ""
email_provider: str = "log"
smtp_use_tls: bool = False
smtp_use_ssl: bool = False
smtp_timeout_seconds: float = 10.0
smtp_from_email: str = "no-reply@benyamessenger.local"
login_rate_limit_per_minute: int = 10
register_rate_limit_per_minute: int = 5
reset_rate_limit_per_minute: int = 5
refresh_rate_limit_per_minute: int = 30
message_rate_limit_per_minute: int = 30
duplicate_message_cooldown_seconds: int = 10
celery_task_always_eager: bool = False
model_config = SettingsConfigDict(env_file=".env", env_file_encoding="utf-8", extra="ignore")
settings = Settings()