Package for dealing with JWT tokens from Keycloak in a MLflow - oauth2-proxy setup.
Project description
mlflow-oauth-keycloak-auth
The purpose of this package is to enable the use of the MLflow "fluent" tracking API with upstream oauth2-proxy.
Getting started
pip install mlflow-oauth-keycloak-auth
If not already present, mlflow obviously should be installed.
pip install mlflow
Usage
import mlflow
from mlflow_oauth_keycloak_auth import authentication as mlflow_auth
mlflow_auth.init()
mlflow_auth.authenticate()
# Your mlflow code
# ...
# Optional: Check the validity of the access token and refresh if it is expired
mlflow_auth.validate_or_refresh()
# Alternatively: running authenticate() again has the same effect
This package expects a file named .env in the directory your script is executed, but can be customized by creating a custom config and passing it to the init() method.
# ...
mlflow_auth.init(env_file="/path/to/env_file")
# ...
Configuration
The configuration is done exclusively via environment variables.
All of the following variables are required and can be found in the .env.example provided in the Github repository file.
| Variable | Value | Purpose |
|---|---|---|
| KMTA_CLIENT_ID | Keycloak Client_ID | authentication |
| KMTA_CLIENT_SECRET | Keycloak Client_Secret | authentication |
| KMTA_USERNAME | Your Keycloak Username | authentication |
| KMTA_PASSWORD | Your Keycloak User Password | authentication |
| KMTA_TOKEN_URI | Your Keycloak User Password | authentication |
| KMTA_USERINFO_URI | Your Keycloak User Password | check token |
The KMTA_TOKEN_URI and KMTA_USERINFO_URI can be obtained by opening the <keycloak_address>/realms/<realm>/.well-known/openid-configuration and copying the properties token_endpoint and userinfo_endpoint.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mlflow_oauth_keycloak_auth-0.0.2.post2.tar.gz.
File metadata
- Download URL: mlflow_oauth_keycloak_auth-0.0.2.post2.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
98d044704d9f7f749509fa062d8a77c8c2885a851ac23fe465db06e37cfbc189
|
|
| MD5 |
5255e6a601105c73aab589503719e5a6
|
|
| BLAKE2b-256 |
5f965ab4345700ce694ff5b9d1d8eab55920f8bda63b7a96cdee2d8cb9d5ac96
|
File details
Details for the file mlflow_oauth_keycloak_auth-0.0.2.post2-py2.py3-none-any.whl.
File metadata
- Download URL: mlflow_oauth_keycloak_auth-0.0.2.post2-py2.py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
099c55d3c48f724200f398aba1fe6291b62624dbd2f3399c662c009961b6039e
|
|
| MD5 |
a0c2c75c00b13aec0a40b908cbf22204
|
|
| BLAKE2b-256 |
ab2cdb89160242244f6811b0c6934449ba06b3ec960b9ab24a8d5a9e3d4ecfcc
|