Understand the dj-rest-auth Demo Architecture
masterThe demo demonstrates a modern Single Page Application (SPA) authentication flow. It is composed of two primary parts:
- Backend (
demo/backend): A Django project integratingdj-rest-auth,django-allauth, anddjangorestframework-simplejwt. It provides REST APIs for registration, login, and Multi-Factor Authentication (MFA). - Frontend (
demo/spa-client): A Next.js application that interacts with the backend APIs to implement user flows like registration, login, MFA setup (via QR code), and MFA verification.
Login Flow Sequence
- User provides credentials via the frontend pages.
- Frontend sends a login request to
dj-rest-auth. - If MFA is enabled,
dj-rest-authresponds indicating MFA is required along with an ephemeral token. - The user provides the MFA verification code and the ephemeral token.
dj-rest-authissues the final Authentication Token or Session.