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.post1.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.post1-py2.py3-none-any.whl (5.3 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

File hashes

Hashes for mlflow_oauth_keycloak_auth-0.0.2.post1.tar.gz
Algorithm Hash digest
SHA256 1af726b23cba2d1d44c9e3d766140283ee63de3f609ca8b31ab0680754941693
MD5 80233a3f365f19c6a7a34e908e7c9af3
BLAKE2b-256 01bb416bd2c693365108e3cb63a496ff36bf08d4b8a4f93e3a6b3066e58c60c9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mlflow_oauth_keycloak_auth-0.0.2.post1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 7ecb18ea8b577dc7440caed796abb47582d3e0477b7f545ef0cc444e2cb1e4f5
MD5 ffe18e3bd183798e09664f5f5f58a0b4
BLAKE2b-256 08d51b0c3e732b241985a4a8dcae79ebdec38ba3a742965cfc8a9c9695c8aba1

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