Skip to content

Commit 77c318b

Browse files
committed
Return Auth object instead of dict
1 parent b8632e8 commit 77c318b

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

mlflow_plugin_proxy_auth/proxy_auth_header_provider.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from mlflow.tracking.request_auth.abstract_request_auth_provider import (
55
RequestAuthProvider,
66
)
7+
from requests.auth import AuthBase
78

89

910
class ProxyAuthProvider(RequestAuthProvider):
@@ -15,12 +16,18 @@ def get_name(self):
1516
return "proxy_auth_provider"
1617

1718
def get_auth(self):
18-
# Add your Authelia Proxy-Authorization logic here
19+
return ProxyAuth(self.username, self.password)
20+
21+
22+
class ProxyAuth(AuthBase):
23+
def __init__(self, username, password):
24+
self.username = username
25+
self.password = password
26+
27+
def __call__(self, r):
1928
credentials = f"{self.username}:{self.password}"
2029
encoded_credentials = base64.b64encode(credentials.encode("utf-8")).decode(
2130
"utf-8"
2231
)
23-
proxy_authorization_header = f"Basic {encoded_credentials}"
24-
25-
# Return a dictionary containing the header for authentication
26-
return {"Proxy-Authorization": proxy_authorization_header}
32+
r.headers["Proxy-Authorization"] = f"Basic {encoded_credentials}"
33+
return r

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name="mlflow-plugin-proxy-auth",
5-
version="0.0.2",
5+
version="0.0.3",
66
packages=find_packages(),
77
install_requires=["mlflow"],
88
entry_points={

0 commit comments

Comments
 (0)