djangosaml2idp
raw JSON → 0.9.1 verified Sat May 09 auth: no python
SAML 2.0 Identity Provider for Django. Current version 0.9.1, released Jan 2025. Maintained on GitHub, monthly patch releases.
pip install djangosaml2idp2 Common errors
error ModuleNotFoundError: No module named 'djangosaml2idp' ↓
cause Package installed as 'djangosaml2idp2' but import expects 'djangosaml2idp'.
fix
The module name is 'djangosaml2idp'. Install with 'pip install djangosaml2idp2' and import correctly.
error AttributeError: module 'djangosaml2idp.conf' has no attribute 'settings' ↓
cause Old import path was 'from djangosaml2idp.settings import saml2idp_settings'.
fix
Use 'from djangosaml2idp.conf import settings'.
error django.db.utils.IntegrityError: (1062, "Duplicate entry '...' for key 'djangosaml2idp_idp_entity_id...'") ↓
cause IdP model 'entity_id' field is unique; duplicate entity IDs cause crash.
fix
Ensure each service provider uses a unique entity_id in SAML_IDP_CONFIG.
Warnings
breaking In v0.9.0 the model class 'IdentityProvider' was renamed to 'IdP'. Any code referencing IdentityProvider must be updated. ↓
fix Replace 'IdentityProvider' with 'IdP' in imports and queries.
deprecated The setting 'SAML_IDP_ATTRIBUTE_MAP' is deprecated; use 'SAML_IDP_CONFIG['attribute_map']' instead. ↓
fix Move attribute map inside SAML_IDP_CONFIG dict.
gotcha The package is installed as 'djangosaml2idp2' on PyPI, but the Python module is 'djangosaml2idp'. Ensure you import correctly. ↓
fix Install with 'pip install djangosaml2idp2', then import as 'djangosaml2idp'.
gotcha SAML_IDP_CONFIG must include 'entity_id' and 'acs_endpoint' as full URLs. Missing these causes AttributeError on metadata endpoint. ↓
fix Ensure both are present and valid HTTPS URLs.
Imports
- IdP wrong
from djangosaml2idp.models import IdentityProvidercorrectfrom djangosaml2idp.models import IdP - settings wrong
from djangosaml2idp.settings import saml2idp_settingscorrectfrom djangosaml2idp.conf import settings - processors
from djangosaml2idp.processors import BaseProcessor
Quickstart
# INSTALLED_APPS += ['djangosaml2idp']
# urls.py
from django.urls import path, include
urlpatterns = [
path('saml2/', include('djangosaml2idp.urls')),
]
# settings.py
SAML_IDP_CONFIG = {
'entity_id': 'https://your-idp.example.com/saml2/metadata/',
'acs_endpoint': 'https://your-idp.example.com/saml2/acs/',
'attribute_map': {
'email': 'email',
'username': 'username',
},
}