fix(opax-mcp): bruk OPAX_IAP_CLIENT_ID som IAP audience i identitytoken

Update identity token retrieval to use OPAX_IAP_CLIENT_ID if available.
This commit is contained in:
chrischristiansen-glitch 2026-06-18 14:11:54 +02:00 committed by GitHub
parent 0ab044417e
commit 9542106ecd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -14,6 +14,7 @@ from typing import Optional, Any
app = FastAPI(title="opax-mcp", version="2.0.0")
OPAX_BASE_URL = os.environ.get("OPAX_BASE_URL", "https://opax.vauco.no")
OPAX_IAP_CLIENT_ID = os.environ.get("OPAX_IAP_CLIENT_ID", "")
MCP_SECRET = os.environ.get("MCP_SECRET", "")
# Gitea
@ -33,7 +34,7 @@ def _opax_identity_token() -> str:
"""Hent identity token for opax.vauco.no (Cloud Run IAP/IAM)."""
metadata_url = (
"http://metadata.google.internal/computeMetadata/v1/instance"
f"/service-accounts/default/identity?audience={OPAX_BASE_URL}&format=full"
f"/service-accounts/default/identity?audience={OPAX_IAP_CLIENT_ID or OPAX_BASE_URL}&format=full"
)
try:
resp = httpx.get(metadata_url, headers={"Metadata-Flavor": "Google"}, timeout=5)