skillfed

djangosaml2

pysaml2 integration for Django

djangosaml2 v1.12.0 503.9K downloads/30d#6,300 on PyPI272
Permissive license Apache 2.0 Active released

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 djangosaml2

uv

uv add djangosaml2

poetry

poetry add djangosaml2

Installing 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

Development Status :: 5 - Production/StableEnvironment :: Web EnvironmentFramework :: DjangoFramework :: Django :: 4.2Framework :: Django :: 5.0Framework :: Django :: 5.1Framework :: Django :: 5.2Intended Audience :: DevelopersLicense :: OSI Approved :: Apache Software LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.9Topic :: Internet :: WWW/HTTPTopic :: Internet :: WWW/HTTP :: WSGITopic :: SecurityTopic :: Software Development :: Libraries :: Application Frameworks

Tags

django saml2 ssosaml2 service provider djangofederated authentication djangodjango single sign-onsaml2 integrationdjango identity providersaml2 bindings django
saml2ssofederated-auth

More WWW/HTTP packages