Add debug mode feature flag with environment variable parsing, UI badge indicator, secret redaction utility, and enhanced terminal session management with status checks and session limit error handling
Tests / Backend Tests (Python) (3.10) (push) Has been cancelled
Tests / Backend Tests (Python) (3.11) (push) Has been cancelled
Tests / Backend Tests (Python) (3.12) (push) Has been cancelled
Tests / Frontend Tests (JS) (push) Has been cancelled
Tests / Integration Tests (push) Has been cancelled
Tests / All Tests Passed (push) Has been cancelled

This commit is contained in:
2025-12-21 17:22:36 -05:00
parent 421446bd13
commit 70c15c9b6f
16 changed files with 606 additions and 181 deletions
+28
View File
@@ -7,10 +7,29 @@ Toutes les variables d'environnement et paramètres sont centralisés ici.
import os
from pathlib import Path
from typing import Optional
from pydantic import Field
from pydantic import field_validator
from pydantic_settings import BaseSettings
def parse_env_bool(value: object, default: bool = False) -> bool:
if value is None:
return default
if isinstance(value, bool):
return value
if isinstance(value, (int, float)):
return bool(value)
if isinstance(value, str):
normalized = value.strip().lower()
if normalized in {"1", "true", "yes"}:
return True
if normalized in {"0", "false", "no"}:
return False
return default
return default
class Settings(BaseSettings):
"""Configuration de l'application Homelab Automation."""
@@ -113,6 +132,14 @@ class Settings(BaseSettings):
)
log_level: str = "info"
# === Feature Flags ===
debug_mode: bool = Field(default=False, validation_alias="DEBUG_MODE")
@field_validator("debug_mode", mode="before")
@classmethod
def _validate_debug_mode(cls, v: object) -> bool:
return parse_env_bool(v, default=False)
class Config:
env_file = ".env"
env_file_encoding = "utf-8"
@@ -121,3 +148,4 @@ class Settings(BaseSettings):
# Instance singleton de la configuration
settings = Settings()
DEBUG_MODE_ENABLED: bool = settings.debug_mode
+9
View File
@@ -130,6 +130,15 @@ async def get_current_user(
return user
async def require_debug_mode() -> bool:
if not settings.debug_mode:
raise HTTPException(
status_code=status.HTTP_403_FORBIDDEN,
detail="Debug mode disabled",
)
return True
# === Dépendance: Vérification rôle admin ===
async def require_admin(