Skip to content

Commit 29d0c83

Browse files
BorisYourichmartenson
authored andcommitted
Basic auth in header
Options for job_conf should be: auth: "none","Basic" ("oauth2" in the future) username: password:
1 parent c9b27d0 commit 29d0c83

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

pulsar/managers/util/tes.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import base64
12
from typing import (
23
Any,
34
cast,
@@ -40,12 +41,19 @@ def ensure_tes_client() -> None:
4041

4142

4243
def tes_client_from_dict(destination_params: Dict[str, Any]) -> TesClient:
43-
# TODO: implement funnel's basic auth in pydantic-tes and expose it here.
4444
tes_url = destination_params.get("tes_url")
45-
token = destination_params.get("private_token")
45+
auth_type = destination_params.get("auth", "none") # Default to "none"
46+
4647
headers = {}
47-
if token:
48-
headers["Authorization"] = f"Bearer {token}"
48+
49+
if auth_type == "basic":
50+
basic_auth = destination_params.get("basic_auth", {})
51+
username = basic_auth.get("username")
52+
password = basic_auth.get("password")
53+
if username and password:
54+
auth_string = f"{username}:{password}"
55+
auth_base64 = base64.b64encode(auth_string.encode()).decode()
56+
headers["Authorization"] = f"Basic {auth_base64}"
4957

5058
return TesClient(url=tes_url, headers=headers)
5159

0 commit comments

Comments
 (0)