fix: legg til X-Internal-Key bypass i require_auth for m2m
This commit is contained in:
parent
e04a95b952
commit
1f4df47083
7
main.py
7
main.py
|
|
@ -190,7 +190,12 @@ def require_auth(func):
|
||||||
if user:
|
if user:
|
||||||
return await func(request, *args, **kwargs)
|
return await func(request, *args, **kwargs)
|
||||||
|
|
||||||
# 2. Bearer token (Cloud Run identity token)
|
# 2. Internal API key (maskin-til-maskin, opax-mcp → osvauco-agent)
|
||||||
|
internal_key = request.headers.get('X-Internal-Key', '')
|
||||||
|
if internal_key and internal_key == os.environ.get('INTERNAL_API_KEY', ''):
|
||||||
|
return await func(request, *args, **kwargs)
|
||||||
|
|
||||||
|
# 3. Bearer token (Cloud Run identity token)
|
||||||
auth_header = request.headers.get('Authorization', '')
|
auth_header = request.headers.get('Authorization', '')
|
||||||
if auth_header.startswith('Bearer '):
|
if auth_header.startswith('Bearer '):
|
||||||
token = auth_header[7:]
|
token = auth_header[7:]
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,7 @@ def _osvauco_agent_identity_token() -> str:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def _osvauco_agent_headers() -> dict:
|
def _osvauco_agent_headers() -> dict:
|
||||||
return {"Authorization": f"Bearer {_osvauco_agent_identity_token()}", "X-MCP-Secret": os.environ.get("MCP_SECRET", ""), "Content-Type": "application/json"}
|
return {"Authorization": f"Bearer {_osvauco_agent_identity_token()}", "X-Internal-Key": os.environ.get("INTERNAL_API_KEY", ""), "Content-Type": "application/json"}
|
||||||
|
|
||||||
async def _osvauco_agent_post(path: str, body: dict) -> Any:
|
async def _osvauco_agent_post(path: str, body: dict) -> Any:
|
||||||
"""Kaller osvauco-agent direkte med service-to-service auth."""
|
"""Kaller osvauco-agent direkte med service-to-service auth."""
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user