msal-streamlit-authentication-dentro


Namemsal-streamlit-authentication-dentro JSON
Version 1.0.9 PyPI version JSON
download
home_pagehttps://github.com/dentro-innovation/msal_streamlit_authentication
SummaryStreamlit Authentication library based on MSAL.JS
upload_time2023-12-13 19:06:56
maintainer
docs_urlNone
authorMichael Staal-Olsen
requires_python>=3.7
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # OpenID Connect (OIDC) authentication component for Streamlit

## About

This Streamlit component enables client-side authentication using [Azure AD](https://docs.microsoft.com/azure/active-directory/develop/v2-overview) work and school accounts (AAD), Microsoft personal accounts (MSA) and social identity providers like Facebook, Google, LinkedIn, Microsoft accounts, etc. through [Azure AD B2C](https://docs.microsoft.com/azure/active-directory-b2c/active-directory-b2c-overview#identity-providers) service.
The component is achieving this by applying the [Microsoft MSAL JS Library](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/lib/msal-browser) inside of a React project. Since the component is based on MSAL, it can be configured to support any provider that supports the OpenID Connect Authorization Code Flow (PKCE).
For more information on MSAL, consult the [Github project](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/lib/msal-browser) and its [offical documentation](https://learn.microsoft.com/en-us/azure/active-directory/develop/msal-overview).

## Usage

Below is a sample Python snippet displaying how to apply the component. Visually, the component gives rise to a single button
in the Streamlit Dashboard with a text that depends on whether an active login session exists. The `auth` and `cache`
parameters are entirely equivalent to the properties mentioned in the [Github documentation](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/docs/initialization.md).
The `login_request` and `logout_request` parameters are covered [here](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/docs/login-user.md).
```python
import streamlit as st
from msal_streamlit_authentication import msal_authentication


login_token = msal_authentication(
    auth={
        "clientId": "aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeee",
        "authority": "https://login.microsoftonline.com/aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeee",
        "redirectUri": "/",
        "postLogoutRedirectUri": "/"
    }, # Corresponds to the 'auth' configuration for an MSAL Instance
    cache={
        "cacheLocation": "sessionStorage",
        "storeAuthStateInCookie": False
    }, # Corresponds to the 'cache' configuration for an MSAL Instance
    login_request={
        "scopes": ["aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeee/.default"]
    }, # Optional
    logout_request={}, # Optional
    login_button_text="Login", # Optional, defaults to "Login"
    logout_button_text="Logout", # Optional, defaults to "Logout"
    class_name="css_button_class_selector", # Optional, defaults to None. Corresponds to HTML class.
    html_id="html_id_for_button", # Optional, defaults to None. Corresponds to HTML id.
    key=1 # Optional if only a single instance is needed
)
st.write("Recevied login token:", login_token)
```
A minimal sample project using the library can be found [here](https://github.com/mstaal/streamlit_msal_sample). Note that it is Dockerized.

The component currently expects for the user to go through a popup based login flow.
Further flows may be supported at a later time. As discussed [here](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/docs/initialization.md#optional-configure-authority),
the `protocolMode` parameter in `auth` can be used to configure OIDC providers that differ from Azure AD.

## Inspiration
Inspired by [official Streamlit template](https://github.com/streamlit/component-template), [this tutorial](https://youtu.be/htXgwEXwmNs) ([Github](https://github.com/andfanilo/streamlit-plotly-component-tutorial)) and the official [Streamlit NPM component-lib](https://github.com/streamlit/streamlit/tree/develop/component-lib).



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/dentro-innovation/msal_streamlit_authentication",
    "name": "msal-streamlit-authentication-dentro",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "",
    "author": "Michael Staal-Olsen",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/2a/f2/01898bb3abaad3f1e4174355c4562c4b55c8530e2f78de342f04e14ab830/msal_streamlit_authentication_dentro-1.0.9.tar.gz",
    "platform": null,
    "description": "# OpenID Connect (OIDC) authentication component for Streamlit\n\n## About\n\nThis Streamlit component enables client-side authentication using [Azure AD](https://docs.microsoft.com/azure/active-directory/develop/v2-overview) work and school accounts (AAD), Microsoft personal accounts (MSA) and social identity providers like Facebook, Google, LinkedIn, Microsoft accounts, etc. through [Azure AD B2C](https://docs.microsoft.com/azure/active-directory-b2c/active-directory-b2c-overview#identity-providers) service.\nThe component is achieving this by applying the [Microsoft MSAL JS Library](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/lib/msal-browser) inside of a React project. Since the component is based on MSAL, it can be configured to support any provider that supports the OpenID Connect Authorization Code Flow (PKCE).\nFor more information on MSAL, consult the [Github project](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/lib/msal-browser) and its [offical documentation](https://learn.microsoft.com/en-us/azure/active-directory/develop/msal-overview).\n\n## Usage\n\nBelow is a sample Python snippet displaying how to apply the component. Visually, the component gives rise to a single button\nin the Streamlit Dashboard with a text that depends on whether an active login session exists. The `auth` and `cache`\nparameters are entirely equivalent to the properties mentioned in the [Github documentation](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/docs/initialization.md).\nThe `login_request` and `logout_request` parameters are covered [here](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/docs/login-user.md).\n```python\nimport streamlit as st\nfrom msal_streamlit_authentication import msal_authentication\n\n\nlogin_token = msal_authentication(\n    auth={\n        \"clientId\": \"aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeee\",\n        \"authority\": \"https://login.microsoftonline.com/aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeee\",\n        \"redirectUri\": \"/\",\n        \"postLogoutRedirectUri\": \"/\"\n    }, # Corresponds to the 'auth' configuration for an MSAL Instance\n    cache={\n        \"cacheLocation\": \"sessionStorage\",\n        \"storeAuthStateInCookie\": False\n    }, # Corresponds to the 'cache' configuration for an MSAL Instance\n    login_request={\n        \"scopes\": [\"aaaaaaa-bbbb-cccc-dddd-eeeeeeeeeee/.default\"]\n    }, # Optional\n    logout_request={}, # Optional\n    login_button_text=\"Login\", # Optional, defaults to \"Login\"\n    logout_button_text=\"Logout\", # Optional, defaults to \"Logout\"\n    class_name=\"css_button_class_selector\", # Optional, defaults to None. Corresponds to HTML class.\n    html_id=\"html_id_for_button\", # Optional, defaults to None. Corresponds to HTML id.\n    key=1 # Optional if only a single instance is needed\n)\nst.write(\"Recevied login token:\", login_token)\n```\nA minimal sample project using the library can be found [here](https://github.com/mstaal/streamlit_msal_sample). Note that it is Dockerized.\n\nThe component currently expects for the user to go through a popup based login flow.\nFurther flows may be supported at a later time. As discussed [here](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/docs/initialization.md#optional-configure-authority),\nthe `protocolMode` parameter in `auth` can be used to configure OIDC providers that differ from Azure AD.\n\n## Inspiration\nInspired by [official Streamlit template](https://github.com/streamlit/component-template), [this tutorial](https://youtu.be/htXgwEXwmNs) ([Github](https://github.com/andfanilo/streamlit-plotly-component-tutorial)) and the official [Streamlit NPM component-lib](https://github.com/streamlit/streamlit/tree/develop/component-lib).\n\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Streamlit Authentication library based on MSAL.JS",
    "version": "1.0.9",
    "project_urls": {
        "Homepage": "https://github.com/dentro-innovation/msal_streamlit_authentication",
        "Repository": "https://github.com/dentro-innovation/msal_streamlit_authentication"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "18b3010109d9580528d9b8c98eea6a460af3ea9ac140d5b3e973d1c689e4c646",
                "md5": "e41f1a49ba889cd17c1e0514d5277f44",
                "sha256": "47ff6b90f32170943631544491a142b762eeb9fd2ab24a1a4f02c1bcf670e78c"
            },
            "downloads": -1,
            "filename": "msal_streamlit_authentication_dentro-1.0.9-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e41f1a49ba889cd17c1e0514d5277f44",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 179832,
            "upload_time": "2023-12-13T19:06:53",
            "upload_time_iso_8601": "2023-12-13T19:06:53.744757Z",
            "url": "https://files.pythonhosted.org/packages/18/b3/010109d9580528d9b8c98eea6a460af3ea9ac140d5b3e973d1c689e4c646/msal_streamlit_authentication_dentro-1.0.9-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2af201898bb3abaad3f1e4174355c4562c4b55c8530e2f78de342f04e14ab830",
                "md5": "b6f2cde2d3cdeb5c850772a50889ca53",
                "sha256": "e7df025d02ee89541b0e7da3e3eecd8cfdfe2c00f8497a71d8c292ce10db973f"
            },
            "downloads": -1,
            "filename": "msal_streamlit_authentication_dentro-1.0.9.tar.gz",
            "has_sig": false,
            "md5_digest": "b6f2cde2d3cdeb5c850772a50889ca53",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 179499,
            "upload_time": "2023-12-13T19:06:56",
            "upload_time_iso_8601": "2023-12-13T19:06:56.091882Z",
            "url": "https://files.pythonhosted.org/packages/2a/f2/01898bb3abaad3f1e4174355c4562c4b55c8530e2f78de342f04e14ab830/msal_streamlit_authentication_dentro-1.0.9.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-13 19:06:56",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "dentro-innovation",
    "github_project": "msal_streamlit_authentication",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "msal-streamlit-authentication-dentro"
}
        
Elapsed time: 0.18114s