- Improved formatting and readability in config.py and other files by adding line breaks. - Introduced INIT_DATA_MAX_AGE_SECONDS to enforce replay protection for Telegram initData. - Updated validate_init_data function to include max_age_seconds parameter for validation. - Enhanced API to reject old initData based on the new max_age_seconds setting. - Added tests for auth_date expiry and validation of initData in test_telegram_auth.py. - Updated README with details on the new INIT_DATA_MAX_AGE_SECONDS configuration.
13 lines
545 B
Python
13 lines
545 B
Python
"""Database layer: SQLAlchemy models, Pydantic schemas, repository, init."""
|
|
|
|
from db.models import Base, User, Duty
|
|
from db.schemas import UserCreate, UserInDb, DutyCreate, DutyInDb, DutyWithUser
|
|
from db.session import get_engine, get_session_factory, get_session
|
|
from db.repository import get_or_create_user, get_duties, insert_duty
|
|
|
|
|
|
def init_db(database_url: str) -> None:
|
|
"""Create tables from metadata (Alembic migrations handle schema in production)."""
|
|
engine = get_engine(database_url)
|
|
Base.metadata.create_all(bind=engine)
|