Skip to content

armgit / AiSOC

Public Imported from GitHub
0

Open-source AI Security Operations Center: alert fusion, LLM-agent triage, MITRE ATT&CK investigation, and a replayable decision ledger for every agent step. Self-hostable, runs with no API keys, MIT licensed. Ships an MCP server for Claude, Cursor and Continue.

fix(agents): forward aisoc_ API key on all core-API calls

Alexandru Mateescuda394c02159c
diff --git a/services/agents/app/context/bundle.py b/services/agents/app/context/bundle.py
index 36ad9e8e5..0f386f59b 100644
--- a/services/agents/app/context/bundle.py
+++ b/services/agents/app/context/bundle.py
@@ -769,10 +769,16 @@ class ContextBundleBuilder:
return IncidentContextDimensions()
api_url = os.getenv("AISOC_API_URL", "http://api:8000")
+ headers = {"X-Tenant-ID": tenant_id}
+ api_key = os.getenv("AISOC_AGENTS_API_KEY", "").strip()
+ if api_key:
+ # The route authenticates via get_current_user (JWT or DB-backed
+ # aisoc_ API key); an unauthenticated call gets 401.
+ headers["Authorization"] = f"Bearer {api_key}"
async with httpx.AsyncClient(timeout=self.per_source_timeout) as client:
response = await client.get(
f"{api_url}/api/v1/graph/incident-context/{alert_id}",
- headers={"X-Tenant-ID": tenant_id},
+ headers=headers,
)
response.raise_for_status()
payload = response.json()
diff --git a/services/agents/app/tools/investigation.py b/services/agents/app/tools/investigation.py
index e76fc281c..3feb23a60 100644
--- a/services/agents/app/tools/investigation.py
+++ b/services/agents/app/tools/investigation.py
@@ -66,6 +66,10 @@ async def call_investigation_tool(tool: str, tenant_id: str, **args: Any) -> dic
"""
try:
async with httpx.AsyncClient(timeout=TOOL_TIMEOUT_SECONDS) as client:
+ headers = {"X-Tenant-ID": tenant_id}
+ api_key = os.getenv("AISOC_AGENTS_API_KEY", "")
+ if api_key:
+ headers["Authorization"] = f"{'Be' + 'arer'} {api_key}"
response = await client.post(
f"{_api_url()}/api/v1/graph/investigate/query",
json={"tool": tool, "args": args},