skillfed

python3-saml

Saml Python Toolkit. Add SAML support to your Python software using this library

python3-saml v1.16.0 9.4M downloads/30d#1,534 on PyPI755
Permissive license MIT AGING released

What it is and what it does

python3-saml is a SAML 2.0 toolkit that converts your Python application into a Service Provider capable of federating with identity providers. It handles the full SSO and SLO lifecycle—both SP-initiated and IdP-initiated flows—and manages assertion encryption, signature validation, and metadata publication. The library is session-less, delegating session management to your application layer, and provides both high-level and low-level APIs for flexibility.

The toolkit requires Python 3.7 or later and depends on xmlsec and lxml for XML cryptography and parsing. It implements the SAML 2.0 Web Browser SSO Profile and has been in production use since 2015. The library emphasizes security best practices, including strict mode validation by default and defenses against XML external entity attacks, signature wrapping, and replay attacks.

Use it for:

  • Integrate enterprise SSO into a SaaS application to allow users to authenticate via corporate identity providers
  • Build a federated B2B platform where partner organizations can authenticate their users without sharing credentials
  • Implement single logout across multiple applications by handling IdP-initiated SLO requests
  • Publish SP metadata for discovery and automated configuration by identity provider administrators
  • Validate digitally signed SAML assertions and encrypted nameIds from trusted identity providers

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Turns a Python application into a SAML 2.0 Service Provider, enabling single sign-on and single logout with identity providers through standardized XML-based federation.

Yes, with conditions. The library is mature, permissively licensed, and has no known vulnerabilities. Install friction is low and it covers the full SAML 2.0 SP workflow. However, maintenance is aging (last release 2023-10-09); verify that it supports your IdP's current SAML profile and that you can manage the xmlsec and lxml system dependencies in your deployment environment. Suitable for production use if you can commit to security best practices, especially enabling strict mode.

Install

python3-saml on PyPI

pip

pip install python3-saml

uv

uv add python3-saml

poetry

poetry add python3-saml

Installing python3-saml

Before you install

Low install friction with no runtime dependencies. Maintenance is aging—last release was 2023-10-09 and last commit 2026-01-14—but the repository remains active and unarchived with a stable user base.

License in practice

MIT license permits commercial and private use with minimal restrictions, making it suitable for most deployment contexts.

Quickstart

pip install python3-saml

Import the toolkit and instantiate with request and settings to handle SSO and SLO flows.

Requires xmlsec and lxml system libraries; lxml should be installed from source (not binary) to avoid libxml2 version conflicts with xmlsec.

Verify before relying

  • Whether xmlsec and lxml system dependencies are pre-installed or require separate setup in typical deployment environments
  • Current status of the library's compatibility with modern IdP implementations and SAML 2.0 profile updates
  • Specific API usage patterns and method signatures for SSO/SLO workflows

Package facts

License MIT (permissive)
Python support not specified
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance aging — 1,040 days since the last release
Last repo commit
First released
Downloads 9,429,292/month — #1,534 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: python3_saml-1.16.0-py2-none-any.whl; python3_saml-1.16.0-py3-none-any.whl

Keywords: saml, saml2, sso, xmlsec, federation, identity

Development Status :: 5 - Production/StableIntended Audience :: DevelopersIntended Audience :: System AdministratorsOperating System :: OS IndependentProgramming Language :: Python :: 2.7Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.5Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9

Tags

saml service providersingle sign-on ssosaml authenticationidentity provider federationsaml2 pythonxml security authenticationenterprise sso
saml-federationsso-authenticationxml-security

More Security packages