agent_tracker/config.py
2025-09-05 13:41:33 -05:00

40 lines
No EOL
1.2 KiB
Python

import os
from dotenv import load_dotenv
load_dotenv()
# Environment Configuration
DISABLE_MSAL = os.getenv("DISABLE_MSAL", "false").lower() == "true"
HIDE_LOCAL_LOGIN = os.getenv("HIDE_LOCAL_LOGIN", "false").lower() == "true"
BASE_PATH = os.getenv("BASE_PATH", "").rstrip("/") # Remove trailing slash
def get_base_path() -> str:
"""Get the base path for URLs"""
return BASE_PATH
def get_full_url(path: str) -> str:
"""Get full URL with base path prefix"""
path = path.lstrip("/") # Remove leading slash
if BASE_PATH:
return f"{BASE_PATH}/{path}"
return f"/{path}" if path else "/"
def is_msal_enabled() -> bool:
"""Check if MSAL authentication is enabled"""
return not DISABLE_MSAL
def show_local_login() -> bool:
"""Check if local login should be shown (hidden in production)"""
return not HIDE_LOCAL_LOGIN
def get_msal_config():
"""Get MSAL configuration if enabled"""
if not is_msal_enabled():
return None
return {
"client_id": os.getenv("AZURE_CLIENT_ID"),
"client_secret": os.getenv("AZURE_CLIENT_SECRET"),
"authority": os.getenv("AZURE_AUTHORITY"),
"redirect_uri": os.getenv("AZURE_REDIRECT_URI"),
}