skillfed

pysaml2

Python implementation of SAML Version 2 Standard

pysaml2 v7.5.4 2.6M downloads/30d#2,975 on PyPI609
License unclear AGING released

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 pysaml2

uv

uv add pysaml2

poetry

poetry add pysaml2

Installing 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

Topic :: Software Development :: Libraries :: Python Modules

Tags

saml2 authenticationidentity provider pythonsaml service providerfederated identitysaml protocol implementationsso single sign-onsaml assertions
saml-federationidentity-managemententerprise-auth

More Python Modules packages