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

Uploaded Python 3

File details

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

File metadata

  • Download URL: msal_streamlit_auth-1.1.4.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.4.tar.gz
Algorithm Hash digest
SHA256 5bbdd77e0a1339c2213449d18b9320a92ae30e5b77b21b71a50f099cff175be2
MD5 20b7b2142bc4be5bf29f058396a1b3d8
BLAKE2b-256 f1ba2e58ab07adafdbf1988ea5710f34fd3cd91b01590a7cfea6a1db06585ec5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for msal_streamlit_auth-1.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 849681281be1a2dab440b611181f35d58ffc1c67b0d02730ec782aaa7a30c0b4
MD5 8ef341ae7f88157849dae4ef9dc57acc
BLAKE2b-256 999c83e2e42880869a90f529c3b443d26893a5c6a99d93e4c3e92a89c6117a52

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