{"id":21138,"library":"django-auth-adfs","title":"django-auth-adfs","description":"A Django authentication backend for Microsoft ADFS and Azure AD. Implements OAuth2/OpenID Connect flows for single sign-on. Current version 1.16.0 supports Django 3.2-6.0 and Python 3.9+. Release cadence is irregular, approximately 2-3 minor versions per year.","status":"active","version":"1.16.0","language":"python","source_language":"en","source_url":"https://github.com/snok/django-auth-adfs","tags":["django","authentication","adfs","azure-ad","sso","oauth2","openid-connect"],"install":[{"cmd":"pip install django-auth-adfs","lang":"bash","label":"default"}],"dependencies":[{"reason":"Core framework; requires >=3.2","package":"Django","optional":false},{"reason":"Token validation and JWKS handling","package":"cryptography","optional":false},{"reason":"HTTP requests to ADFS/Azure AD endpoints","package":"requests","optional":false}],"imports":[{"note":"Backend is in the backend module, not package root","wrong":"from django_auth_adfs import AuthenticationBackend","symbol":"AuthenticationBackend","correct":"from django_auth_adfs.backend import AuthenticationBackend"},{"note":"Correct import for OAuth2 views","symbol":"views","correct":"from django_auth_adfs.views import OAuth2CallbackView, OAuth2LoginView"}],"quickstart":{"code":"# settings.py\nINSTALLED_APPS = [\n    ...\n    'django_auth_adfs',\n    'django_auth_adfs.drf',  # optional: for DRF integration\n]\n\nAUTHENTICATION_BACKENDS = [\n    'django_auth_adfs.backend.AuthenticationBackend',\n    'django.contrib.auth.backends.ModelBackend',\n]\n\nAUTH_ADFS = {\n    \"SERVER\": \"adfs.yourorg.com\",\n    \"CLIENT_ID\": \"your-client-id\",\n    \"RELYING_PARTY_ID\": \"your-rp-id\",\n    \"AUDIENCE\": \"microsoft:identityserver:your-rp-id\",\n    \"CA_BUNDLE\": \"/etc/ssl/certs/ca-certificates.crt\",\n    \"CLAIM_MAPPING\": {\"first_name\": \"given_name\", \"last_name\": \"family_name\", \"email\": \"email\"},\n}\n\n# urls.py\nfrom django.urls import path, include\nurlpatterns = [\n    path('oauth2/', include('django_auth_adfs.urls')),\n]\n\n# Quick login: go to /oauth2/login","lang":"python","description":"Configure ADFS backend, claim mapping, and include OAuth2 URLs."},"warnings":[{"fix":"Upgrade to django-auth-adfs>=1.16.0","message":"Django 6 support added in 1.16.0; older versions (<1.16) may break on Django 6.","severity":"breaking","affected_versions":"<1.16.0"},{"fix":"Use django-auth-adfs<1.14.0 if stuck on older Django","message":"Django 3.2 and 4.0/4.1 dropped in 1.14.0; will cause import errors or compatibility issues.","severity":"breaking","affected_versions":">=1.14.0"},{"fix":"Verify the token's 'aud' claim matches AUTH_ADFS['AUDIENCE'] exactly; check claim mapping keys match token fields.","message":"AssertionError or AttributeError due to missing or malformed JWT token. Often caused by misconfigured AUDIENCE or CLAIM_MAPPING.","severity":"gotcha","affected_versions":"all"},{"fix":"Set SERVER to 'https://adfs.yourorg.com' (with https://)","message":"Redirect loop on login if SERVER setting does not include protocol (https://). The library does not automatically add https.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use `from django_auth_adfs.backend import AuthenticationBackend`","cause":"Incorrect import path. The backend is in the submodule `backend`.","error":"ImportError: cannot import name 'AuthenticationBackend' from 'django_auth_adfs'"},{"fix":"Add AUTH_ADFS dictionary with required keys (SERVER, CLIENT_ID, etc.)","cause":"Missing or incorrectly defined AUTH_ADFS dictionary in Django settings.","error":"django.core.exceptions.ImproperlyConfigured: The AUTH_ADFS setting must be a dict."},{"fix":"Ensure AUTH_ADFS['SERVER'] includes 'https://' and is reachable from your server.","cause":"Network connectivity issue or incorrect SERVER setting (missing https:// or typo).","error":"requests.exceptions.ConnectionError: HTTPSConnectionPool(host='adfs.yourorg.com', port=443): Max retries exceeded"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}