$ show snok/django-auth-adfs
django-auth-adfs is a Django authentication backend that enables integration with Microsoft ADFS and Azure AD for single sign-on (SSO). It implements OAuth2 and OpenID Connect flows to authenticate users against enterprise identity providers, automatically creating and updating Django users based on identity claims. The package provides Django authentication backends, middleware for enforcing authentication, URL handlers for the OAuth2 flow, and Django REST Framework integration for token-based API authentication. The architecture follows Django best practices with clear separation of concerns between configuration, backend logic, views, and middleware.
The LLM identified 2 files worth highlighting for reuse:
The validate_access_token method demonstrates excellent JWT validation practices including proper key rotation handling, explicit validation options (avoiding reliance on library defaults), granular error handling for different token failure modes, and appropriate logging. This pattern could be extracted as a standalone JWT validator utility with minimal changes to remove Django-specific dependencies.
The ProviderConfig class implements a robust pattern for loading and caching identity provider configuration from both OpenID Connect discovery documents and legacy SAML federation metadata. It handles key rotation, endpoint discovery, and provides a clean interface for building authorization URLs. This abstraction demonstrates good separation of concerns and could be adapted for other identity provider integrations.