fix: fjern GCE metadata token-kall, bruk kun X-Internal-Key for m2m
This commit is contained in:
parent
1f4df47083
commit
10eb49b244
|
|
@ -100,23 +100,12 @@ async def _opax_post(path: str, body: dict) -> Any:
|
||||||
# OSVauco Agent helpers (for direct service-to-service calls)
|
# OSVauco Agent helpers (for direct service-to-service calls)
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
def _osvauco_agent_identity_token() -> str:
|
|
||||||
"""Hent identity token for direkte kall til osvauco-agent."""
|
|
||||||
try:
|
|
||||||
audience = os.environ.get("OSVAUCO_AGENT_URL")
|
|
||||||
if not audience:
|
|
||||||
raise ValueError("OSVAUCO_AGENT_URL environment variable is not set.")
|
|
||||||
auth_req = google.auth.transport.requests.Request()
|
|
||||||
token = google.oauth2.id_token.fetch_id_token(auth_req, audience)
|
|
||||||
if not token:
|
|
||||||
raise ValueError("Empty token returned from fetch_id_token")
|
|
||||||
return token
|
|
||||||
except Exception as e:
|
|
||||||
logger.error(f"[SERVICE-TO-SERVICE TOKEN ERROR] {type(e).__name__}: {e}")
|
|
||||||
raise
|
|
||||||
|
|
||||||
def _osvauco_agent_headers() -> dict:
|
def _osvauco_agent_headers() -> dict:
|
||||||
return {"Authorization": f"Bearer {_osvauco_agent_identity_token()}", "X-Internal-Key": os.environ.get("INTERNAL_API_KEY", ""), "Content-Type": "application/json"}
|
"""Headers for maskin-til-maskin kall til osvauco-agent via X-Internal-Key."""
|
||||||
|
return {
|
||||||
|
"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