Skip to content

Commit 9f2a5cd

Browse files
committed
Initial implementation of proxy auth header
1 parent 6feec69 commit 9f2a5cd

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

.flake8

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[flake8]
2+
exclude = .git,__pycache__,data,old,build,dist
3+
max-complexity = 10
4+
max-line-length = 88
5+
extend-ignore = E203
6+
per-file-ignores =
7+
*/__init__.py: F401
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import base64
2+
import os
3+
4+
from mlflow.tracking.request_auth.abstract_request_auth_provider import (
5+
RequestAuthProvider,
6+
)
7+
8+
9+
class ProxyAuthProvider(RequestAuthProvider):
10+
def __init__(self):
11+
self.username = os.getenv("MLFLOW_TRACKING_USERNAME")
12+
self.password = os.getenv("MLFLOW_TRACKING_PASSWORD")
13+
14+
def get_name(self):
15+
return "proxy_auth_provider"
16+
17+
def get_auth(self):
18+
# Add your Authelia Proxy-Authorization logic here
19+
credentials = f"{self.username}:{self.password}"
20+
encoded_credentials = base64.b64encode(credentials.encode("utf-8")).decode(
21+
"utf-8"
22+
)
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}

setup.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from setuptools import find_packages, setup
2+
3+
setup(
4+
name="mlflow-plugin-proxy-auth",
5+
version="0.0.1",
6+
packages=find_packages(),
7+
install_requires=["mlflow"],
8+
entry_points={
9+
"mlflow.request_auth_provider": "dummy-backend=mlflow_plugin_proxy_auth.proxy_auth_header_provider:ProxyAuthProvider",
10+
},
11+
)

0 commit comments

Comments
 (0)