django-auth-adfs
A Django authentication backend for Microsoft ADFS and AzureAD
What it is and what it does
django-auth-adfs is a Django authentication backend that delegates user login to Microsoft ADFS (Active Directory Federation Services) or Azure AD. Instead of storing passwords in Django, it redirects users through an OAuth2 flow to your organization's identity provider, then creates or updates Django user accounts based on claims returned from ADFS. It handles the full redirect cycle—login initiation, ADFS callback, token validation via cryptography and PyJWT, and automatic group assignment—so developers can focus on application logic rather than directory integration.
The package is designed for intranet and cloud environments where centralized identity management is already in place. It depends on django, requests, urllib3, cryptography, and PyJWT to manage HTTP communication, certificate validation, and token verification. Configuration is done through Django settings, and it provides optional middleware to enforce login across your application and template tags for login/logout links.
Use it for:
- Enterprise Django applications where users authenticate via corporate Active Directory or Azure AD without storing passwords in the app.
- Intranet portals that need single sign-on (SSO) so employees log in once to ADFS and automatically gain access to Django apps.
- Multi-tenant SaaS platforms using Azure AD for customer organization authentication and automatic user provisioning.
- Django REST Framework APIs that accept ADFS access tokens for stateless, federated authentication.
- Organizations migrating from on-premises ADFS to Azure AD while keeping existing Django applications.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Integrates Django applications with Microsoft ADFS and Azure AD for single sign-on authentication, automatically provisioning users and group memberships from directory claims.
Yes, if you are building a Django application in an organization using ADFS or Azure AD for identity management. The package is production-stable, actively maintained, has no known vulnerabilities, and handles the complex OAuth2 and token validation logic so you don't have to. Install it only if your deployment environment has an ADFS or Azure AD endpoint already configured; it is not useful for standalone Django apps or those using other identity providers.
Install
django-auth-adfs on PyPI
pip
pip install django-auth-adfsuv
uv add django-auth-adfspoetry
poetry add django-auth-adfsInstalling django-auth-adfs
Before you install
Low install friction with a pure-Python wheel distribution. Actively maintained as of 2026-01-08 with recent commits, and supports current Django versions (4.2 through 6.0) and Python 3.9–3.14.
License in practice
BSD-1-Clause is a permissive open-source license with minimal restrictions on use, modification, and distribution in both commercial and private projects.
Quickstart
pip install django-auth-adfs
# In settings.py:
AUTHENTICATION_BACKENDS = ('django_auth_adfs.backend.AdfsAuthCodeBackend',)
INSTALLED_APPS = (..., 'django_auth_adfs')
AUTH_ADFS = {
'SERVER': 'adfs.yourcompany.com',
'CLIENT_ID': 'your-client-id',
'RELYING_PARTY_ID': 'your-rpt-name',
}
# In urls.py:
path('oauth2/', include('django_auth_adfs.urls'))
Requires ADFS or Azure AD server endpoint configured with a client ID and relying party trust; certificate bundle path may be needed for on-premises ADFS.
Verify before relying
- Whether the package works with Django versions beyond 6.0 or Python 3.14 in production (classifiers list them but latest release is 2026-01-08).
- Performance characteristics when handling large numbers of concurrent ADFS authentication requests.
- Compatibility with non-standard ADFS claim mappings or custom identity providers.
Package facts
| License | BSD-1-Clause (permissive) |
| Python support | supports the current Python release (<4.0,>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 5 — django, requests, urllib3, cryptography, PyJWT |
| Maintenance | actively maintained — 218 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 147,754/month — #11,052 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: django_auth_adfs-1.16.0-py3-none-any.whl
Keywords: django, authentication, adfs, azure, ad, oauth2
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
django-google-ssoAdds Google OAuth 2.0 authentication to Django…
permissive · top 15,000 on PyPI
django-authlibProvides passwordless authentication for Django…
permissive · top 15,000 on PyPI
django-loginasAdds a "Log in as user" button to the Django…
permissive · top 5,000 on PyPI
django-magiclinkAdds passwordless email-based authentication to…
permissive · top 15,000 on PyPI
grafana-django-saml2-authA compatibility shim that redirects to…
permissive · top 15,000 on PyPI
adalADAL for Python authenticates applications with…
permissive · top 1,000 on PyPI
dj-rest-authProvides drop-in REST API endpoints for user…
permissive · top 5,000 on PyPI
identityProvides a high-level authentication and…
permissive · top 15,000 on PyPI
fastapi-azure-authAdds Azure Entra ID (formerly Azure AD)…
permissive · top 15,000 on PyPI
fastapi-auth0Integrates Auth0 authentication into FastAPI…
permissive · top 15,000 on PyPI