diligence/backend/app/config.py
Claude 6e082ce58f Stream D: Security hardening — 10 fixes from QA review
- SEC-05: Fail fast if SECRET_KEY is default 'change-me-in-production'
- SEC-06: CORS allow_credentials=False (Bearer tokens don't need it)
- SEC-08: Input validation on auth schemas (min/max length, username pattern)
- SEC-10: .dockerignore files (root, backend, mcp-connector)
- SEC-11: Hardcode ALGORITHM='HS256' as constant, remove from settings
- CQ-01: Gate crawl scheduler on CRAWL_ENABLED env var (default false)
- OS-02: CONTRIBUTING.md
- OS-03: CHANGELOG.md with v1.0.0 entry
- setup.ps1: Add API_TOKEN generation (Windows parity with setup.sh)
2026-06-21 23:13:53 +00:00

45 lines
1.2 KiB
Python

from __future__ import annotations
from pydantic_settings import BaseSettings
from functools import lru_cache
class Settings(BaseSettings):
# Database - hostname 'fitness-db' avoids collision with other 'db' containers on Coolify network
database_url: str = "postgresql+asyncpg://fitness@fitness-db:5432/fitness_rewards"
# Auth
secret_key: str = "change-me-in-production"
crawl_enabled: bool = False # Set CRAWL_ENABLED=true to start program crawl scheduler
access_token_expire_minutes: int = 1440 # 24 hours
api_token: str = "" # MCP connector auth — generated by setup.sh
# Strava
strava_client_id: str = ""
strava_client_secret: str = ""
# Polar
polar_client_id: str = ""
polar_client_secret: str = ""
# Groq (program extraction)
groq_api_key: str = ""
# Telegram (support notifications — outbound only)
telegram_bot_token: str = ""
telegram_chat_id: str = ""
# App
base_url: str = "http://localhost"
timezone: str = "Asia/Bangkok"
model_config = {"env_file": ".env", "extra": "ignore"}
@lru_cache
def get_settings() -> Settings:
return Settings()
# Module-level shortcut used by services
settings = get_settings()