OpenID Connect (OIDC) authentication component for Streamlit
About
This Streamlit component enables client-side authentication using Azure AD work and school accounts (AAD), Microsoft personal accounts (MSA) and social identity providers like Facebook, Google, LinkedIn, Microsoft accounts, etc. through Azure AD B2C service. The component is achieving this by applying the Microsoft MSAL JS Library 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 and its offical documentation.
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.
The login_request and logout_request parameters are covered here.
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. 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,
the protocolMode parameter in auth can be used to configure OIDC providers that differ from Azure AD.
Inspiration
Inspired by official Streamlit template, this tutorial (Github) and the official Streamlit NPM component-lib.
Metadata
Release files for msal-streamlit-authentication 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| msal_streamlit_authentication-1.1.0.tar.gz | 158.4 kB | Without provenance | Details for msal_streamlit_authentication-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| msal_streamlit_authentication-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for msal_streamlit_authentication-1.1.0-py3-none-any.whl |
Total release size: 316.9 kB
Release files / msal_streamlit_authentication-1.1.0.tar.gz
| Download URL | msal_streamlit_authentication-1.1.0.tar.gz |
|---|---|
| Size | 158.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
018594c8eb7bad3df7f6dbc7b5cc1518c99f2da4796a5ae2097fd78301680cdd
|
|
BLAKE2b-256 checksum How to use checksums |
9929d6faf62389a039ad6111b8cfd7100864fe27a5275bfae7114819c85db3c3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Release files / msal_streamlit_authentication-1.1.0-py3-none-any.whl
| Download URL | msal_streamlit_authentication-1.1.0-py3-none-any.whl |
|---|---|
| Size | 158.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
111d0df8a47e83ca94b5345166104760edadc4b1884541203bd854c5bcd5487c
|
|
BLAKE2b-256 checksum How to use checksums |
73373952a91cbc434aa3cb71ae097e373d46f6a738b1c8aa0e1320a756c15679
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Security for msal-streamlit-authentication 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.