pysaml2
Python implementation of SAML Version 2 Standard
What it is and what it does
PySAML2 is a pure Python library implementing the OASIS SAML Version 2 Standard, enabling you to build SAML2 service providers or identity providers. It handles core SAML2 protocols, assertions, bindings, and metadata as specified by the standard, and was originally designed for WSGI environments with extensions for other frameworks.
The package depends on cryptography, defusedxml, pyopenssl, python-dateutil, requests, and xmlschema to parse and validate SAML2 XML structures. It requires Python 3.9 or later and is maintained by the IdentityPython community. With nearly 2.6 million monthly downloads, it is widely used for enterprise federated authentication and single sign-on integrations.
Use it for:
- Build a web application that accepts SAML2 assertions from a corporate identity provider for enterprise SSO
- Implement a SAML2 identity provider to issue assertions for federated access to partner applications
- Parse and validate SAML2 metadata to discover and configure connections with other SAML2 participants
- Handle SAML2 authentication flows in Python web frameworks beyond WSGI using community extensions
- Manage SAML2 bindings and protocols for secure attribute exchange in federation scenarios
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
PySAML2 is a pure Python implementation of SAML Version 2 Standard for building SAML2 service providers or identity providers.
Yes, with a license verification step. PySAML2 is a mature, widely-used implementation of a critical standard for enterprise identity federation. Install friction is low, security vulnerabilities are absent, and it supports current Python versions. However, resolve the unclear license status before committing to production use. The aging maintenance status is not a blocker given the stable repository state and active community.
Install
pysaml2 on PyPI
pip
pip install pysaml2uv
uv add pysaml2poetry
poetry add pysaml2Installing pysaml2
Before you install
Low install friction with a pure-wheel distribution. Maintenance status is aging—last release was 311 days ago, though the repository remains active with a recent commit on 2026-02-11 and carries 609 GitHub stars.
License in practice
License treatment is unclear—neither SPDX nor raw license metadata is available in the package metadata. Before adopting, verify the actual license terms directly from the repository or project documentation to ensure compliance with your use case.
Quickstart
pip install pysaml2
import pysaml2
from pysaml2 import client
from pysaml2 import config
Requires the xmlsec binary to be installed on the system (e.g., apt-get install xmlsec1 on Linux, brew install libxmlsec1 on macOS). PySAML2 wraps this external tool for cryptographic operations.
Verify before relying
- Specific SAML2 profiles and bindings supported beyond the core standard
- Performance characteristics with large numbers of assertions or metadata
- Compatibility with specific identity providers or SAML2 implementations
- Whether the aging maintenance status reflects stability or reduced active development
Package facts
| License | not declared (unclear) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 6 — cryptography, defusedxml, pyopenssl, python-dateutil, requests, xmlschema |
| Maintenance | aging — 311 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 2,595,971/month — #2,975 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pysaml2-7.5.4-py3-none-any.whl
Keywords: saml, saml2, standard, federation, identity, idpy, IdentityPython
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
djangosaml2idp2Implements the SAML 2.0 Identity Provider side…
permissive · top 15,000 on PyPI
python3-samlTurns a Python application into a SAML 2.0…
permissive · top 5,000 on PyPI
grafana-django-saml2-authA compatibility shim that redirects to…
permissive · top 15,000 on PyPI
djangosaml2Integrates SAML2 single sign-on authentication…
permissive · top 15,000 on PyPI
types-pysaml2Provides type annotations (stubs) for the…
copyleft · top 15,000 on PyPI
xmlsecPython bindings for XML Security Library,…
permissive · top 5,000 on PyPI
signxmlSignXML implements W3C XML Signature (XMLDSig)…
permissive · top 5,000 on PyPI
social-auth-coreProvides a core framework for integrating…
permissive · top 5,000 on PyPI
requests-negotiate-sspiAdds HTTP Negotiate authentication…
permissive · top 15,000 on PyPI
social-auth-app-djangoIntegrates social authentication and…
permissive · top 5,000 on PyPI