"""Environment configuration management for auth service.""" import os from typing import Optional def get_auth_service_url() -> Optional[str]: """ Get backend auth service URL from environment. The auth service validates GitHub tokens and returns cloud account info, permissions, and access to metrics/logs backends. Authentication logic is implemented on that service; this MCP server only forwards the token. Returns: Auth service base URL if set (e.g. https://auth.example.com), None otherwise """ url = os.getenv("AUTH_SERVICE_URL") if not url or not url.strip(): return "https://www.ds.us-west-2.aws.observability.tidbcloud.com" url = url.strip().rstrip("/") if not url.startswith(("http://", "https://")): url = "https://" + url return url def get_github_token() -> Optional[str]: token = os.getenv("GITHUB_TOKEN") if not token or not token.strip(): return None return token.strip() def get_auth_provider() -> str: """ Get cloud provider for backend auth request. Reads AUTH_PROVIDER and normalizes to lowercase; defaults to "aws". """ provider = os.getenv("AUTH_PROVIDER", "aws") return provider.strip().lower() if provider else "aws"