Grafana Django SAML2 Auth

raw JSON →
3.21.0 verified Fri May 01 auth: no python deprecated

Deprecated compatibility shim for SAML2 authentication in Django, originally developed for Grafana. The current version is 3.21.0. The project has been migrated to django-saml2-auth-community; this package is now a no-op wrapper. Install django-saml2-auth-community instead for ongoing maintenance.

pip install django-saml2-auth-community
error ModuleNotFoundError: No module named 'django_saml2_auth'
cause Attempting to import from the deprecated package after installing grafana-django-saml2-auth. The package does not actually contain the module; it's a shim that issues a deprecation warning.
fix
pip install django-saml2-auth-community
error ImportError: cannot import name 'SAML2Backend' from 'django_saml2_auth.backends'
cause Typo in the backend path. The correct class is SAML2Backend (capital letters).
fix
Use: AUTHENTICATION_BACKENDS = ['django_saml2_auth.backends.SAML2Backend', ...]
error WARNING: grafana-django-saml2-auth 3.21.0 is deprecated. You should install django-saml2-auth-community.
cause Installing the deprecated shim triggers a pip deprecation warning.
fix
pip uninstall grafana-django-saml2-auth; pip install django-saml2-auth-community
breaking This package (grafana-django-saml2-auth) is deprecated. Do not install it. Install django-saml2-auth-community instead.
fix pip uninstall grafana-django-saml2-auth && pip install django-saml2-auth-community
gotcha The import path is 'django_saml2_auth' (underscores), not 'django_saml2_auth' (same). Ensure your code uses correct underscores to avoid ImportError.
fix Use: from django_saml2_auth import views
gotcha Requires Python >= 3.10. Older Python versions will fail to install.
fix Upgrade Python to 3.10 or later.

Basic integration of django-saml2-auth-community.

# settings.py
INSTALLED_APPS = [
    ...
    'django_saml2_auth',
]

AUTHENTICATION_BACKENDS = [
    'django_saml2_auth.backends.SAML2Backend',
    'django.contrib.auth.backends.ModelBackend',
]

SAML2_AUTH = {
    'METADATA_FILE': '/path/to/metadata.xml',
    'ENTITY_ID': 'https://your-app.example.com/saml2/metadata/',
    'ACS_URL': 'https://your-app.example.com/saml2/acs/',
}

# urls.py
from django.urls import path, include
urlpatterns = [
    path('saml2/', include('django_saml2_auth.urls')),
]