101 lines
3.1 KiB
Python
101 lines
3.1 KiB
Python
"""
|
|
Delphi Consulting Group Database System - Configuration
|
|
"""
|
|
from typing import Optional
|
|
|
|
from pydantic import Field
|
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
"""Application configuration (env and .env driven).
|
|
|
|
Environment precedence: real environment variables take priority over .env,
|
|
which take priority over defaults.
|
|
"""
|
|
|
|
# Application
|
|
app_name: str = "Delphi Consulting Group Database System"
|
|
app_version: str = "1.0.0"
|
|
debug: bool = False
|
|
|
|
# Database
|
|
database_url: str = "sqlite:///./data/delphi_database.db"
|
|
|
|
# Authentication / JWT
|
|
# Require SECRET_KEY to be provided via environment/.env (no insecure default)
|
|
secret_key: str = Field(..., min_length=32)
|
|
# Optional previous secret key to allow seamless rotation
|
|
previous_secret_key: Optional[str] = None
|
|
algorithm: str = "HS256"
|
|
access_token_expire_minutes: int = 240 # 4 hours
|
|
# Long-lived refresh token expiration (default 30 days)
|
|
refresh_token_expire_minutes: int = 43200
|
|
|
|
# Admin account settings
|
|
admin_username: str = "admin"
|
|
# SECURITY: Admin password MUST be set via environment variable
|
|
admin_password: str = Field(..., description="Admin password - MUST be set securely via ADMIN_PASSWORD environment variable")
|
|
|
|
# File paths
|
|
upload_dir: str = "./uploads"
|
|
backup_dir: str = "./backups"
|
|
|
|
# Pagination
|
|
default_page_size: int = 50
|
|
max_page_size: int = 200
|
|
|
|
# Docker/deployment settings
|
|
external_port: Optional[str] = None
|
|
allowed_hosts: Optional[str] = None
|
|
cors_origins: Optional[str] = None
|
|
secure_cookies: bool = False
|
|
compose_project_name: Optional[str] = None
|
|
|
|
# Logging
|
|
log_level: str = "INFO"
|
|
log_to_file: bool = True
|
|
log_rotation: str = "10 MB"
|
|
log_retention: str = "30 days"
|
|
|
|
# Cache / Redis
|
|
cache_enabled: bool = False
|
|
redis_url: Optional[str] = None
|
|
|
|
# Rate limiting (authenticated user-based limits)
|
|
auth_rl_enabled: bool = True
|
|
auth_rl_api_requests: int = 1000
|
|
auth_rl_api_window_seconds: int = 3600
|
|
auth_rl_search_requests: int = 500
|
|
auth_rl_search_window_seconds: int = 3600
|
|
auth_rl_upload_requests: int = 50
|
|
auth_rl_upload_window_seconds: int = 3600
|
|
auth_rl_admin_requests: int = 200
|
|
auth_rl_admin_window_seconds: int = 3600
|
|
|
|
# Notifications
|
|
notifications_enabled: bool = False
|
|
# Email settings (optional)
|
|
smtp_host: Optional[str] = None
|
|
smtp_port: int = 587
|
|
smtp_username: Optional[str] = None
|
|
smtp_password: Optional[str] = None
|
|
smtp_starttls: bool = True
|
|
notification_email_from: str = "no-reply@localhost"
|
|
# QDRO notification recipients (comma-separated emails)
|
|
qdro_notify_email_to: Optional[str] = None
|
|
# Webhook settings (optional)
|
|
qdro_notify_webhook_url: Optional[str] = None
|
|
qdro_notify_webhook_secret: Optional[str] = None
|
|
|
|
# pydantic-settings v2 configuration
|
|
model_config = SettingsConfigDict(
|
|
env_file=".env",
|
|
env_prefix="",
|
|
case_sensitive=False,
|
|
env_ignore_empty=True,
|
|
extra="ignore",
|
|
)
|
|
|
|
|
|
settings = Settings() |