fix: fjern all GCE metadata token-logikk fra _opax_headers
This commit is contained in:
parent
10eb49b244
commit
a437cd1ea3
|
|
@ -62,25 +62,11 @@ def _verify_auth(request: Request):
|
||||||
# OPAX helpers (for opax.vauco.no via IAP)
|
# OPAX helpers (for opax.vauco.no via IAP)
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
def _opax_identity_token() -> str:
|
|
||||||
"""Hent identity token for opax.vauco.no (Cloud Run IAP/IAM)."""
|
|
||||||
try:
|
|
||||||
metadata_url = (
|
|
||||||
"http://metadata.google.internal/computeMetadata/v1/instance"
|
|
||||||
f"/service-accounts/default/identity?audience={OPAX_IAP_CLIENT_ID}&format=full"
|
|
||||||
)
|
|
||||||
resp = httpx.get(metadata_url, headers={"Metadata-Flavor": "Google"}, timeout=5)
|
|
||||||
resp.raise_for_status()
|
|
||||||
token = resp.text.strip()
|
|
||||||
if not token:
|
|
||||||
raise ValueError("Empty token returned from metadata server")
|
|
||||||
return token
|
|
||||||
except Exception as e:
|
|
||||||
logger.error(f"[IAP TOKEN ERROR] {type(e).__name__}: {e}")
|
|
||||||
raise
|
|
||||||
|
|
||||||
def _opax_headers() -> dict:
|
def _opax_headers() -> dict:
|
||||||
return {"Authorization": f"Bearer {_opax_identity_token()}", "Content-Type": "application/json"}
|
return {
|
||||||
|
"X-Internal-Key": os.environ.get("INTERNAL_API_KEY", ""),
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
}", "Content-Type": "application/json"}
|
||||||
|
|
||||||
|
|
||||||
async def _opax_get(path: str) -> Any:
|
async def _opax_get(path: str) -> Any:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user