From 993985f3e964f089a0e9121999ffb39aa0c2b1ad Mon Sep 17 00:00:00 2001 From: Zawadi Done Date: Fri, 5 Apr 2024 16:04:32 +0200 Subject: [PATCH] Add authorization token to use GCP IAP Setting the header `Proxy-Authorization` does not work because it is deleted: https://github.com/psf/requests/blob/2a438c27b5a5828c8ea0dc958112eecffca70b12/src/requests/sessions.py#L318-L319. --- api_client/python/timesketch_api_client/client.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/api_client/python/timesketch_api_client/client.py b/api_client/python/timesketch_api_client/client.py index e9f13eee8e..b4fca3d1ba 100644 --- a/api_client/python/timesketch_api_client/client.py +++ b/api_client/python/timesketch_api_client/client.py @@ -340,6 +340,10 @@ def _create_session( session = requests.Session() + # GCP IAP + if token := os.getenv("AUTHORIZATION_TOKEN"): + session.headers = {"Authorization": f"Bearer {token}"} + # If using HTTP Basic auth, add the user/pass to the session if auth_mode == "http-basic": session.auth = (username, password)