39 lines
1.4 KiB
Python
39 lines
1.4 KiB
Python
"""Point d'entrée : `python -m kazeia_central`.
|
|
|
|
Hôte/port configurables par variables d'environnement (local-first par défaut) :
|
|
KAZEIA_HOST défaut 127.0.0.1 — mettre 0.0.0.0 pour exposer sur le réseau
|
|
KAZEIA_PORT défaut 8000
|
|
KAZEIA_USER / KAZEIA_PASS — si définis, active l'auth HTTP Basic (UI + API)
|
|
|
|
⚠️ Exposer sur 0.0.0.0 sans KAZEIA_USER/KAZEIA_PASS = PII de santé + pilotage flotte
|
|
accessibles à tout le réseau. À éviter (cf. §8 RGPD).
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
|
|
|
|
def main() -> None:
|
|
import uvicorn
|
|
|
|
host = os.environ.get("KAZEIA_HOST", "127.0.0.1")
|
|
port = int(os.environ.get("KAZEIA_PORT", "8000"))
|
|
has_auth = bool(os.environ.get("KAZEIA_USER") and os.environ.get("KAZEIA_PASS"))
|
|
exposed = host not in ("127.0.0.1", "localhost", "::1")
|
|
|
|
if exposed and not has_auth:
|
|
print("\033[33m" +
|
|
f"⚠️ Kazeia-central écoute sur {host}:{port} SANS authentification.\n"
|
|
" Données PII santé + pilotage flotte exposés sur le réseau.\n"
|
|
" → définis KAZEIA_USER et KAZEIA_PASS pour activer l'auth Basic." +
|
|
"\033[0m", flush=True)
|
|
elif exposed:
|
|
print(f"Kazeia-central sur {host}:{port} — auth Basic active.", flush=True)
|
|
|
|
uvicorn.run("kazeia_central.app:app", host=host, port=port)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|