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:
parent
0ab044417e
commit
9542106ecd
|
|
@ -14,6 +14,7 @@ from typing import Optional, Any
|
||||||
app = FastAPI(title="opax-mcp", version="2.0.0")
|
app = FastAPI(title="opax-mcp", version="2.0.0")
|
||||||
|
|
||||||
OPAX_BASE_URL = os.environ.get("OPAX_BASE_URL", "https://opax.vauco.no")
|
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", "")
|
MCP_SECRET = os.environ.get("MCP_SECRET", "")
|
||||||
|
|
||||||
# Gitea
|
# Gitea
|
||||||
|
|
@ -33,7 +34,7 @@ def _opax_identity_token() -> str:
|
||||||
"""Hent identity token for opax.vauco.no (Cloud Run IAP/IAM)."""
|
"""Hent identity token for opax.vauco.no (Cloud Run IAP/IAM)."""
|
||||||
metadata_url = (
|
metadata_url = (
|
||||||
"http://metadata.google.internal/computeMetadata/v1/instance"
|
"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:
|
try:
|
||||||
resp = httpx.get(metadata_url, headers={"Metadata-Flavor": "Google"}, timeout=5)
|
resp = httpx.get(metadata_url, headers={"Metadata-Flavor": "Google"}, timeout=5)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user