mlflow-oauth-keycloak-auth


Namemlflow-oauth-keycloak-auth JSON
Version 0.0.2.post2 PyPI version JSON
download
home_pageNone
SummaryPackage for dealing with JWT tokens from Keycloak in a MLflow - oauth2-proxy setup.
upload_time2024-07-29 13:46:10
maintainerNone
docs_urlNone
authorNone
requires_pythonNone
licenseNone
keywords keycloak mlflow oauth2
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # mlflow-oauth-keycloak-auth
The purpose of this package is to enable the use of the [MLflow "fluent" tracking API](https://mlflow.org/docs/latest/python_api/mlflow.html) with upstream oauth2-proxy.

## Getting started

```bash
pip install mlflow-oauth-keycloak-auth
```

If not already present, mlflow obviously should be installed.

```bash
pip install mlflow
```

## Usage

```python
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.

```python
# ...
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](https://github.com/SmithyW/mlflow-oauth-keycloak-auth/blob/main/.env.example).

| 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`.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "mlflow-oauth-keycloak-auth",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "keycloak, mlflow, oauth2",
    "author": null,
    "author_email": "SmithyW <github@smiwit.de>",
    "download_url": "https://files.pythonhosted.org/packages/5f/96/5ab4345700ce694ff5b9d1d8eab55920f8bda63b7a96cdee2d8cb9d5ac96/mlflow_oauth_keycloak_auth-0.0.2.post2.tar.gz",
    "platform": null,
    "description": "# mlflow-oauth-keycloak-auth\nThe purpose of this package is to enable the use of the [MLflow \"fluent\" tracking API](https://mlflow.org/docs/latest/python_api/mlflow.html) with upstream oauth2-proxy.\n\n## Getting started\n\n```bash\npip install mlflow-oauth-keycloak-auth\n```\n\nIf not already present, mlflow obviously should be installed.\n\n```bash\npip install mlflow\n```\n\n## Usage\n\n```python\nimport mlflow\nfrom mlflow_oauth_keycloak_auth import authentication as mlflow_auth\n\nmlflow_auth.init()\nmlflow_auth.authenticate()\n\n# Your mlflow code\n# ...\n\n# Optional: Check the validity of the access token and refresh if it is expired\nmlflow_auth.validate_or_refresh()\n# Alternatively: running authenticate() again has the same effect\n```\n\nThis 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.\n\n```python\n# ...\nmlflow_auth.init(env_file=\"/path/to/env_file\")\n# ...\n```\n\n## Configuration\n\nThe configuration is done exclusively via environment variables.\nAll of the following variables are required and can be found in the `.env.example` provided in the [Github repository file](https://github.com/SmithyW/mlflow-oauth-keycloak-auth/blob/main/.env.example).\n\n| Variable              | Value                       | Purpose  |\n| --------------------- |:---------------------------:| -----------------:|\n| KMTA_CLIENT_ID        | Keycloak Client_ID          |   authentication  |\n| KMTA_CLIENT_SECRET    | Keycloak Client_Secret      |   authentication  |\n| KMTA_USERNAME         | Your Keycloak Username      |   authentication  |\n| KMTA_PASSWORD         | Your Keycloak User Password |   authentication  |\n| KMTA_TOKEN_URI        | Your Keycloak User Password |   authentication  |\n| KMTA_USERINFO_URI     | Your Keycloak User Password |   check token     |\n\n\nThe `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`.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Package for dealing with JWT tokens from Keycloak in a MLflow - oauth2-proxy setup.",
    "version": "0.0.2.post2",
    "project_urls": {
        "Homepage": "https://github.com/SmithyW/mlflow-oauth-keycloak-auth",
        "Issues": "https://github.com/SmithyW/mlflow-oauth-keycloak-auth/issues"
    },
    "split_keywords": [
        "keycloak",
        " mlflow",
        " oauth2"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ab2cdb89160242244f6811b0c6934449ba06b3ec960b9ab24a8d5a9e3d4ecfcc",
                "md5": "a0c2c75c00b13aec0a40b908cbf22204",
                "sha256": "099c55d3c48f724200f398aba1fe6291b62624dbd2f3399c662c009961b6039e"
            },
            "downloads": -1,
            "filename": "mlflow_oauth_keycloak_auth-0.0.2.post2-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a0c2c75c00b13aec0a40b908cbf22204",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 5351,
            "upload_time": "2024-07-29T13:46:09",
            "upload_time_iso_8601": "2024-07-29T13:46:09.350985Z",
            "url": "https://files.pythonhosted.org/packages/ab/2c/db89160242244f6811b0c6934449ba06b3ec960b9ab24a8d5a9e3d4ecfcc/mlflow_oauth_keycloak_auth-0.0.2.post2-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5f965ab4345700ce694ff5b9d1d8eab55920f8bda63b7a96cdee2d8cb9d5ac96",
                "md5": "5255e6a601105c73aab589503719e5a6",
                "sha256": "98d044704d9f7f749509fa062d8a77c8c2885a851ac23fe465db06e37cfbc189"
            },
            "downloads": -1,
            "filename": "mlflow_oauth_keycloak_auth-0.0.2.post2.tar.gz",
            "has_sig": false,
            "md5_digest": "5255e6a601105c73aab589503719e5a6",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 5492,
            "upload_time": "2024-07-29T13:46:10",
            "upload_time_iso_8601": "2024-07-29T13:46:10.387143Z",
            "url": "https://files.pythonhosted.org/packages/5f/96/5ab4345700ce694ff5b9d1d8eab55920f8bda63b7a96cdee2d8cb9d5ac96/mlflow_oauth_keycloak_auth-0.0.2.post2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-29 13:46:10",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "SmithyW",
    "github_project": "mlflow-oauth-keycloak-auth",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "mlflow-oauth-keycloak-auth"
}
        
Elapsed time: 7.47712s