How snok/django-auth-adfs works
django-auth-adfs is a Django authentication integration for on-premises ADFS and Azure AD. In the browser flow, a user starts login, is redirected to the identity provider, and returns to a callback that authenticates the authorization code, provisions or updates the Django user, and establishes a session. It also supports middleware-enforced login and DRF bearer-token authentication; backend token validation can retrieve group membership through Microsoft Graph. The graph reflects the sampled calls and README-described routes; other configuration and integration details were not inspected.
Main entry points: backend.py Auth backends · views.py OAuth views · config.py Provider config · rest_framework.py DRF bearer auth
Components 14
Browser OAuth
- OAuth routes
django_auth_adfs/urls.py - OAuth views
django_auth_adfs/views.py
Authentication
- Auth backends
django_auth_adfs/backend.py - Django users / groups
- Post-auth signal
django_auth_adfs/signals.py - MFA exception
django_auth_adfs/exceptions.py - Login middleware
django_auth_adfs/middleware.py
Provider Configuration
- Provider config
django_auth_adfs/config.py - OIDC metadata
API Integrations
- DRF bearer auth
django_auth_adfs/rest_framework.py - DRF login routes
django_auth_adfs/drf_urls.py - Microsoft Graph
Other components
- Browser user
- ADFS / Azure AD
Connections 19
- Browser user → OAuth routes: opens login
README.rst - OAuth routes → OAuth views: routes requests
django_auth_adfs/urls.py - OAuth views → Provider config: builds redirects
django_auth_adfs/views.py - OAuth views → Auth backends: authenticates code
django_auth_adfs/views.py - OAuth views → Browser user: redirects callback
django_auth_adfs/views.py - Provider config → OIDC metadata: loads metadata
django_auth_adfs/config.py - Provider config → ADFS / Azure AD: builds provider URLs
django_auth_adfs/config.py - OAuth views → ADFS / Azure AD: redirects for login
django_auth_adfs/views.py - Auth backends → ADFS / Azure AD: exchanges code
django_auth_adfs/backend.py - Auth backends → Provider config: uses provider settings
django_auth_adfs/backend.py - Auth backends → Django users / groups: creates and updates
django_auth_adfs/backend.py - Auth backends → Post-auth signal: sends signal
django_auth_adfs/backend.py - Auth backends → MFA exception: raises MFA error
django_auth_adfs/backend.py - Auth backends → Microsoft Graph: queries memberships
django_auth_adfs/backend.py - Login middleware → MFA exception: handles MFA error
django_auth_adfs/middleware.py - Browser user → DRF bearer auth: sends bearer token
README.rst - DRF bearer auth → Auth backends: authenticates token
django_auth_adfs/rest_framework.py - DRF bearer auth → MFA exception: handles MFA error
django_auth_adfs/rest_framework.py - DRF login routes → OAuth views: routes login
django_auth_adfs/drf_urls.py