From 619bcfd63560265170754956a6e65e6172f0fc84 Mon Sep 17 00:00:00 2001 From: Chris Christiansen Date: Thu, 2 Jul 2026 22:05:59 +0000 Subject: [PATCH] fix: legg til X-Internal-Key bypass i require_iap middleware for m2m --- main.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/main.py b/main.py index 8f185fe..535c4a6 100644 --- a/main.py +++ b/main.py @@ -111,6 +111,10 @@ async def require_iap(request: Request, call_next): return await call_next(request) if request.headers.get("x-goog-authenticated-user-email"): return await call_next(request) + # M2M: X-Internal-Key bypass + _ikey = request.headers.get("X-Internal-Key", "") + if _ikey and _ikey == os.environ.get("INTERNAL_API_KEY", ""): + return await call_next(request) # Fallback: aksepter Cloud Run identity token (Bearer) auth_header = request.headers.get("Authorization", "") if auth_header.startswith("Bearer "):