djangosaml2idp2
SAML 2.0 Identity Provider for Django
What it is and what it does
djangosaml2idp2 is a Django application that implements the Identity Provider (IdP) side of the SAML 2.0 protocol, enabling your Django application to act as a federated authentication server. It builds on PySAML2 and handles the cryptographic signing and encryption of SAML assertions, metadata generation, and single sign-on flows. You configure it by adding it to Django's installed apps, including its URL routes, and then defining your IdP configuration (certificates, endpoints, signing algorithms) and registering Service Providers through the Django admin interface.
The package is production-ready and supports modern Django versions and Python 3.9 and later. It requires the xmlsec binary to be installed separately on your system for SAML assertion signing. Configuration is done via Django settings and the admin interface, with hooks for custom access control logic via processor classes and customizable attribute mapping between Django user fields and SAML assertions.
Use it for:
- Build a corporate SSO server where multiple web applications authenticate users against a central Django-based IdP.
- Integrate Django with federated identity systems by acting as an IdP for SAML 2.0 service providers.
- Implement custom access control logic per service provider using processor subclasses to enforce fine-grained authentication rules.
- Map Django user attributes to SAML fields for seamless user provisioning across federated applications.
- Support multiple authentication algorithms and encryption standards by configuring signing and digest algorithms per service provider.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Implements the SAML 2.0 Identity Provider side for Django applications, enabling federated authentication and single sign-on (SSO) by building on PySAML2.
Yes. This is a production-ready, actively maintained SAML 2.0 IdP implementation for Django with low install friction, permissive licensing, no known vulnerabilities, and support for current Django and Python versions. Install it if you need to operate a federated authentication server. The main prerequisite is having xmlsec available on your system.
Install
djangosaml2idp2 on PyPI
pip
pip install djangosaml2idp2uv
uv add djangosaml2idp2poetry
poetry add djangosaml2idp2Installing djangosaml2idp2
Before you install
Low install friction with a pure-Python wheel distribution. Active maintenance with recent commits and support for current Django versions (4.2, 5.1, 5.2) and Python 3.9–3.13. Requires xmlsec binary (XML Security Library) to be installed separately on the system for SAML assertion signing.
License in practice
Licensed under Apache Software License 2.0 (permissive), allowing commercial and private use with minimal restrictions—suitable for production deployments.
Quickstart
pip install djangosaml2idp2
# In Django settings.py:
INSTALLED_APPS = [
'djangosaml2idp',
...
]
# In urls.py:
urlpatterns = [
path('idp/', include('djangosaml2idp.urls')),
]
# Configure SAML_IDP_CONFIG with xmlsec_binary path, certificates, and service endpoints.
Requires xmlsec binary (XML Security Library) to be installed on the system; the package will not function for signing SAML assertions without it.
Verify before relying
- Whether the fork actively maintains compatibility with the original OTA-Insight/djangosaml2idp or diverges significantly.
- Performance characteristics under high-volume SSO traffic or with many service providers configured.
- Completeness of documentation and examples beyond the excerpt provided.
Package facts
| License | Apache Software License 2.0 (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 4 — django, pysaml2, pytz, arrow |
| Maintenance | actively maintained — 158 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 83,976/month — #14,037 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: djangosaml2idp2-0.9.1-py2.py3-none-any.whl
Keywords: django, pysaml2, sso, saml2, federated authentication, authentication, idp
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
djangosaml2Integrates SAML2 single sign-on authentication…
permissive · top 15,000 on PyPI
grafana-django-saml2-authA compatibility shim that redirects to…
permissive · top 15,000 on PyPI
pysaml2PySAML2 is a pure Python implementation of SAML…
unclear · top 5,000 on PyPI
python3-samlTurns a Python application into a SAML 2.0…
permissive · top 5,000 on PyPI
social-auth-app-djangoIntegrates social authentication and…
permissive · top 5,000 on PyPI
django-allauthProvides integrated local and social…
permissive · top 5,000 on PyPI
descopeDescope SDK provides Python backend access to…
permissive · top 5,000 on PyPI
django-oidc-providerProvides OpenID Connect and OAuth 2.0 server…
permissive · top 15,000 on PyPI
django-auth-adfsIntegrates Django applications with Microsoft…
permissive · top 15,000 on PyPI
types-pysaml2Provides type annotations (stubs) for the…
copyleft · top 15,000 on PyPI