Skip to main content

Streamlit auth library based on MSAL.JS

Project description

Streamlit - Microsoft MSAL Authentication

This project is a fork of Ploomber's msal-streamlit-authentication

A Streamlit component for Microsoft Authentication Library (MSAL) integration

PyPI version

pip install msal-streamlit-auth

Example: Local Project With Docker

Overview

This Streamlit component enables seamless client-side authentication using:

  • Azure Active Directory (AAD) work and school accounts
  • Microsoft personal accounts (MSA)
  • Social identity providers (Facebook, Google, LinkedIn, etc.) through Azure AD B2C

Built on the Microsoft MSAL JS Library, it supports any provider using OpenID Connect Authorization Code Flow (PKCE).

Sign In Example

Quick Start

  1. Register Your Application

  2. Install the Package

    pip install msal-streamlit-authentication
    
  3. Implementation Example

    value = msal_authentication(
        auth={
            "clientId": "YOUR_CLIENT_ID",
            "authority": "https://login.microsoftonline.com/YOUR_TENANT_ID",
            "postLogoutRedirectUri": "/"
        },
        cache={
            "cacheLocation": "sessionStorage",
            "storeAuthStateInCookie": False
        },
        login_request={
            "scopes": ["YOUR_SCOPE/.default"]
        }
    )
    

Configuration Guide

Required Configuration

  • Client ID: Found in Azure Portal under "Application (client) ID"

    📷 Where to find Client ID Client ID Location
  • Tenant ID: Found in Azure Portal under "Directory (tenant) ID"

    📷 Where to find Tenant ID Tenant ID Location

Optional Parameters

msal_authentication(
    # ... required config ...
    login_button_text="Login",          # Default: "Login"
    logout_button_text="Logout",        # Default: "Logout"
    class_name="css_button_class",      # CSS class selector
    html_id="button_id",                # HTML ID
    key="1"                             # Streamlit component key
)

Scopes Configuration

For more information on configuring scopes and permissions, see the official documentation.

Basic scope example:

login_request={
    "scopes": ["https://graph.microsoft.com/.default"]
}

Redirect URI

By default, MSAL uses the current page as the redirect URI. To customize:

auth={
    # ... other config ...
    "redirectUri": "/custom-path",
}

⚠️ All redirect URIs must be registered in your Azure portal application settings.

Additional Resources

Acknowledgments

Built with inspiration from:

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

msal_streamlit_auth-1.1.2.tar.gz (157.4 kB view details)

Uploaded Source

Built Distribution

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

msal_streamlit_auth-1.1.2-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file msal_streamlit_auth-1.1.2.tar.gz.

File metadata

  • Download URL: msal_streamlit_auth-1.1.2.tar.gz
  • Upload date:
  • Size: 157.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for msal_streamlit_auth-1.1.2.tar.gz
Algorithm Hash digest
SHA256 27d900bd96d04419666cc5d1e1fec25ef781ff9f8e76a1f02a4e35c33edb2d16
MD5 3f24f529cc1692e4151ed2461ed36c40
BLAKE2b-256 fab4277ebc88eb90d1be0458751a73ba614809c6d321bba319fb9ccab38eec64

See more details on using hashes here.

File details

Details for the file msal_streamlit_auth-1.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for msal_streamlit_auth-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f8087e832b98509120fc46fad4428b92daa2c835ab1779b178e1c769f0763fce
MD5 71dad93b48fa02d33bed6b08a065ab6c
BLAKE2b-256 1c2b2393f5c7024b06ba19003239af44189a8b9e1dcc9b19938a11a46bfe97fd

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