import os from typing import Optional # Database connection settings DATABASE_URL = os.getenv("DATABASE_URL", "postgresql://haproxy_user:haproxy_password@postgres:5432/haproxy_openmanager") # Redis connection REDIS_URL = os.getenv("REDIS_URL", "redis://localhost:6379") # CORS settings # Configurable via CORS_ORIGINS env var (comma-separated), e.g. "http://localhost:3000,http://server:8080" # Default allows common development and Docker Compose origins _cors_env = os.getenv("CORS_ORIGINS", "") CORS_ORIGINS = [o.strip() for o in _cors_env.split(",") if o.strip()] if _cors_env else [ "http://localhost:3000", "http://localhost:8080", "http://localhost:8000", ] # Security settings SECRET_KEY = os.getenv("SECRET_KEY", "your-secret-key-here") JWT_SECRET_KEY = SECRET_KEY # Alias for JWT middleware ALGORITHM = "HS256" JWT_ALGORITHM = ALGORITHM # Alias for JWT middleware ACCESS_TOKEN_EXPIRE_MINUTES = 30 # Logging level LOG_LEVEL = os.getenv("LOG_LEVEL", "INFO") # Public URL configuration (for agent installation scripts) PUBLIC_URL = os.getenv("PUBLIC_URL", "http://localhost:8000") MANAGEMENT_BASE_URL = os.getenv("MANAGEMENT_BASE_URL", PUBLIC_URL) # Backward compatibility # Agent settings AGENT_HEARTBEAT_TIMEOUT_SECONDS = 15 AGENT_CONFIG_SYNC_INTERVAL_SECONDS = 30 # Entity snapshot enabled by default (rollback functionality) # Set to "false" only if you need to disable snapshot temporarily ENTITY_SNAPSHOT_ENABLED = os.getenv("ENTITY_SNAPSHOT_ENABLED", "true").lower() == "true"