djangosaml2
pysaml2 integration for Django
What it is and what it does
Djangosaml2 is a Django application that wraps the pysaml2 library to implement a SAML2 Service Provider, enabling your Django project to authenticate users via SAML2-compliant identity providers. It handles the core SAML2 protocol flows—HTTP-REDIRECT and HTTP-POST bindings for both SSO and SLO (single logout)—and provides discovery service support and an embedded WAYF (Where Are You From) page. The package depends on defusedxml for secure XML parsing and pysaml2 for the underlying SAML2 protocol implementation.
Typical use involves configuring SAML2 metadata and IdP details in Django settings, then routing authentication requests through djangosaml2's views. It's designed for organizations integrating with existing federated identity systems (such as Shibboleth or commercial IdPs) rather than building a new identity provider from scratch.
Use it for:
- Integrate a Django application with a corporate Shibboleth or ADFS identity provider for enterprise SSO.
- Enable federated login across multiple organizations using SAML2 standards without managing passwords.
- Add single logout (SLO) support to a Django app so users log out across all federated services at once.
- Implement IdP discovery or hinting to route users to the correct identity provider in a multi-tenant setup.
- Protect a Django application with SAML2 authentication while maintaining compatibility with modern Django versions.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Integrates SAML2 single sign-on authentication into Django applications using the pysaml2 library, enabling federated identity and SSO workflows.
Yes. Djangosaml2 is actively maintained, supports current Django and Python versions, has no known vulnerabilities, and carries a permissive license. Install it if you need SAML2 SSO integration; skip it if your authentication requirements are simpler (e.g., OAuth2, OIDC, or local users).
Install
djangosaml2 on PyPI
pip
pip install djangosaml2uv
uv add djangosaml2poetry
poetry add djangosaml2Installing djangosaml2
Before you install
Low install friction with a pure-Python wheel distribution. Actively maintained with a recent release (178 days ago) and ongoing commits; supports current Django versions (4.2 through 5.2) and Python 3.9–3.13.
License in practice
Licensed under Apache 2.0 (permissive), allowing use in commercial and proprietary projects with minimal restrictions beyond attribution and liability disclaimers.
Quickstart
pip install djangosaml2
from djangosaml2.views import acs
from django.urls import path
urlpatterns = [
path('saml2/acs/', acs, name='saml2_acs'),
]
Requires Django 4.2+ and Python 3.9+; SAML2 metadata and IdP configuration must be set up separately in Django settings.
Verify before relying
- Whether HTTP-REDIRECT and HTTP-POST SSO bindings are fully tested against modern IdP implementations.
- Performance characteristics when handling high-volume SSO requests or large SAML2 assertions.
- Specific version constraints or compatibility notes for pysaml2 beyond what the package declares.
Package facts
| License | Apache 2.0 (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — defusedxml, Django, pysaml2 |
| Maintenance | actively maintained — 178 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 503,856/month — #6,300 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: djangosaml2-1.12.0-py2.py3-none-any.whl
Keywords: django, pysaml2, sso, saml2, federated authentication, authentication
Tags
More WWW/HTTP packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
h11h11 is a pure-Python HTTP/1.1 protocol…
permissive · top 100 on PyPI
httpxHTTPX is a fully featured HTTP client library…
permissive · top 100 on PyPI
httpcoreA minimal low-level HTTP client library that…
permissive · top 100 on PyPI
aiohttpaiohttp is an async HTTP client and server…
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
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
types-pysaml2Provides type annotations (stubs) for the…
copyleft · top 15,000 on PyPI
djangorestframework-simplejwtProvides JSON Web Token (JWT) authentication…
permissive · top 5,000 on PyPI
requests-negotiate-sspiAdds HTTP Negotiate authentication…
permissive · top 15,000 on PyPI
django-auth-adfsIntegrates Django applications with Microsoft…
permissive · top 15,000 on PyPI
python-openidImplements OpenID authentication for Python…
permissive · top 15,000 on PyPI