Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mlflow_oauth_keycloak_auth-0.0.2.post2.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mlflow_oauth_keycloak_auth-0.0.2.post2-py2.py3-none-any.whl (5.4 kB view details)

Uploaded Python 2Python 3

File details

Details for the file mlflow_oauth_keycloak_auth-0.0.2.post2.tar.gz.

File metadata

File hashes

Hashes for mlflow_oauth_keycloak_auth-0.0.2.post2.tar.gz
Algorithm Hash digest
SHA256 98d044704d9f7f749509fa062d8a77c8c2885a851ac23fe465db06e37cfbc189
MD5 5255e6a601105c73aab589503719e5a6
BLAKE2b-256 5f965ab4345700ce694ff5b9d1d8eab55920f8bda63b7a96cdee2d8cb9d5ac96

See more details on using hashes here.

File details

Details for the file mlflow_oauth_keycloak_auth-0.0.2.post2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for mlflow_oauth_keycloak_auth-0.0.2.post2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 099c55d3c48f724200f398aba1fe6291b62624dbd2f3399c662c009961b6039e
MD5 a0c2c75c00b13aec0a40b908cbf22204
BLAKE2b-256 ab2cdb89160242244f6811b0c6934449ba06b3ec960b9ab24a8d5a9e3d4ecfcc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page