python3-saml
Saml Python Toolkit. Add SAML support to your Python software using this library
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-samluv
uv add python3-samlpoetry
poetry add python3-samlInstalling 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
Tags
More Security packages
Provides Python bindings to the FreeDesktop.org…
permissive · top 1,000 on PyPI
msalMSAL for Python handles OAuth2 and OpenID…
permissive · top 1,000 on PyPI
joserfcjoserfc implements JOSE standards (JWS, JWE,…
permissive · top 1,000 on PyPI
AuthlibAuthlib provides a complete implementation of…
permissive · top 1,000 on PyPI
argon2-cffi-bindingsProvides low-level CFFI bindings to the…
permissive · top 1,000 on PyPI
adalADAL for Python authenticates applications with…
permissive · top 1,000 on PyPI
pysaml2PySAML2 is a pure Python implementation of SAML…
unclear · top 5,000 on PyPI
python-casImplements a CAS (Central Authentication…
permissive · top 15,000 on PyPI
djangosaml2Integrates SAML2 single sign-on authentication…
permissive · top 15,000 on PyPI
djangosaml2idp2Implements the SAML 2.0 Identity Provider side…
permissive · top 15,000 on PyPI
descopeDescope SDK provides Python backend access to…
permissive · top 5,000 on PyPI
grafana-django-saml2-authA compatibility shim that redirects to…
permissive · top 15,000 on PyPI
signxmlSignXML implements W3C XML Signature (XMLDSig)…
permissive · top 5,000 on PyPI
oneloginOfficial Python SDK for OneLogin's API,…
unclear · top 15,000 on PyPI
python-openidImplements OpenID authentication for Python…
permissive · top 15,000 on PyPI
xmlsecPython bindings for XML Security Library,…
permissive · top 5,000 on PyPI