osint-dashboard/app/config.py

43 lines
2 KiB
Python
Raw Permalink Normal View History

"""OSINT Dashboard — centralized configuration (12-factor, env-driven).
All infrastructure endpoints are read from the environment with
container-friendly defaults. No secrets, hostnames, or cluster-specific
addresses are hardcoded anywhere in the codebase.
Override per environment via environment variables (docker-compose,
k8s ConfigMap/Secret, or systemd):
DB_USER, DB_PASSWORD, DB_HOST, DB_PORT, DB_NAME
NATS_URL
MINIO_ENDPOINT, MINIO_ACCESS_KEY, MINIO_SECRET_KEY, MINIO_SECURE
"""
from __future__ import annotations
import os
from urllib.parse import quote_plus
# ── PostgreSQL ────────────────────────────────────────────────────────────
# Defaults assume docker-compose/k8s service names. Override for your stack.
DB_USER = os.getenv("DB_USER", "osint")
DB_PASSWORD = os.getenv("DB_PASSWORD", "")
DB_HOST = os.getenv("DB_HOST", "postgres")
DB_PORT = os.getenv("DB_PORT", "5432")
DB_NAME = os.getenv("DB_NAME", "osint_data")
# Async SQLAlchemy URL. Password is URL-encoded so special chars are safe.
DATABASE_URL = (
f"postgresql+asyncpg://"
f"{DB_USER}:{quote_plus(DB_PASSWORD)}@{DB_HOST}:{DB_PORT}/{DB_NAME}"
)
# ── NATS JetStream ─────────────────────────────────────────────────────────
NATS_URL = os.getenv("NATS_URL", "nats://nats:4222")
# ── MinIO (document storage) ────────────────────────────────────────────────
MINIO_ENDPOINT = os.getenv("MINIO_ENDPOINT", "minio:9000")
MINIO_ACCESS_KEY = os.getenv("MINIO_ACCESS_KEY", "")
MINIO_SECRET_KEY = os.getenv("MINIO_SECRET_KEY", "")
# "false" / "0" / "no" (case-insensitive) → plain HTTP (e.g. local compose).
MINIO_SECURE = os.getenv("MINIO_SECURE", "false").lower() not in ("false", "0", "no")