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

Uploaded Python 3

File details

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

File metadata

  • Download URL: msal_streamlit_auth-1.1.3.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.3.tar.gz
Algorithm Hash digest
SHA256 59e7f1381939f3c6706fe3cfa4128bfe69297115ab50bc2ed5485e423733e5ab
MD5 574afbbec7871303fd5f5888894d1897
BLAKE2b-256 2f45ad7790f189efa1c449b7fa83fdeff599a71e283db08ef5a4e6b4e1a2729e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for msal_streamlit_auth-1.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 64159ea2b0c927c91462e5271c03ebfb698774abc1e9f6f0a0d4fa93f1e154a9
MD5 81739ecc3abe495a8bf8a15ffe566e8b
BLAKE2b-256 9e4b253e6c535d90f7846c54ed071f6ea50438871aac58d4aaf5a2febc3137a6

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