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.1.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.1-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: msal_streamlit_auth-1.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 ede7dd0acf4d96e787fad3f3df8e1773cedc02e79754e198ef115422f5706d1d
MD5 4dc0608edb3a9556218780ab1bf4385b
BLAKE2b-256 5ff01badf638a92cd8ab488e41d527a6c4e3ae432f7df1e517b83b204c94b70e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for msal_streamlit_auth-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 567cb8d4a9316be06588f94d072e5b55cd8a7dce74e4f2c46ae825fefaa84fd6
MD5 52bc5e3def8b191905811b03051c8f28
BLAKE2b-256 4da45b29e048ff542e00af4484f8cb25957f3d9d3e518e19d272cbd0bdc63602

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