From a61fe365ee6cb75787e46e92cad8b868c76ab6eb Mon Sep 17 00:00:00 2001 From: Shudipto Trafder Date: Mon, 1 Dec 2025 22:15:17 +0600 Subject: [PATCH] feat: Validate custom authentication path and method in auth_config --- agentflow_cli/src/app/loader.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/agentflow_cli/src/app/loader.py b/agentflow_cli/src/app/loader.py index 18bd574..b3f52bf 100644 --- a/agentflow_cli/src/app/loader.py +++ b/agentflow_cli/src/app/loader.py @@ -1,6 +1,8 @@ import importlib import inspect import logging +import os +from pathlib import Path from agentflow.checkpointer import BaseCheckpointer from agentflow.graph import CompiledGraph @@ -197,6 +199,24 @@ async def attach_all_modules( if auth_config: method = auth_config.get("method", None) path = auth_config.get("path", None) + if not path or not method: + raise ValueError("Both 'method' and 'path' must be specified in auth_config.") + + # Extract file path before the ':' for existence check + module_or_path = path.split(":", 1)[0] if ":" in path else path + + # Simple handling: if it appears to be a filesystem path, use it; otherwise + # convert dotted module path to a file path like src/auth/custom_auth.py + if os.path.sep in module_or_path or module_or_path.endswith(".py"): + file_path = Path(module_or_path) + elif "." in module_or_path and os.path.sep not in module_or_path: + file_path = Path(module_or_path.replace(".", os.path.sep) + ".py") + else: + file_path = Path(module_or_path) + + if not file_path.exists(): + raise ValueError(f"Custom auth path does not exist: {module_or_path}") + if method == "custom": auth_backend = load_auth( path,