AuthFlow is a plug-and-play authentication module for Django with web auth (allauth), JWT API, email verification, password reset, profile management, role-based permissions, and social login (Google, GitHub).
| Login | Sign Up |
|---|---|
![]() |
![]() |
- Backend: Python 3.12, Django 5, Django REST Framework
- Frontend: Django Templates, TailwindCSS, DaisyUI, Alpine.js
- Auth: django-allauth, djangorestframework-simplejwt
- Database: PostgreSQL (or SQLite for dev)
- Dev Tools: Docker, Black, Ruff, pytest
- Clone and create virtual environment:
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements/dev.txt- Copy environment file and configure:
cp .env.example .env
# Edit .env - SECRET_KEY and DATABASE_URL (leave empty for SQLite)- Run migrations:
python manage.py migrate- Build CSS (Tailwind + DaisyUI):
npm install
npm run build:css- Create superuser and run server:
python manage.py createsuperuser
python manage.py runservercp .env.example .env
docker-compose up --build- Django: http://localhost:8000
- PostgreSQL runs in the background
- User Registration: Name, email, password (signup, login, logout)
- Email Verification: Mandatory verification before dashboard access
- Password Reset: Request link, set new password
- Profile: Update name, email, avatar at
/profile/ - Settings: Change password at
/profile/settings/ - Social Login: Google, GitHub (configure OAuth apps)
- Role-Based Permissions: admin, staff, user; admin manages users at
/profile/manage/users/ - JWT API:
/api/login/,/api/register/,/api/user/,/api/token/refresh/ - Dashboard:
/dashboard/(requires verified email)
| Method | Endpoint | Auth | Description |
|---|---|---|---|
| POST | /api/register/ |
No | Register, returns access + refresh tokens |
| POST | /api/login/ |
No | Login, returns access + refresh tokens |
| POST | /api/token/refresh/ |
No | Refresh access token |
| GET/PUT/PATCH | /api/user/ |
JWT | Get/update current user |
curl -X POST http://localhost:8000/api/register/ \
-H "Content-Type: application/json" \
-d '{"email":"user@example.com","name":"User","password":"securepass123"}'curl -X POST http://localhost:8000/api/login/ \
-H "Content-Type: application/json" \
-d '{"email":"user@example.com","password":"securepass123"}'-
Copy
apps/accounts,apps/core,apps/dashboard,apps/apiinto your project. -
Add to
INSTALLED_APPS:
INSTALLED_APPS = [
# ...
"rest_framework",
"rest_framework_simplejwt",
"allauth",
"allauth.account",
"allauth.socialaccount",
"allauth.socialaccount.providers.google",
"allauth.socialaccount.providers.github",
"corsheaders",
"apps.core",
"apps.accounts",
"apps.dashboard",
"apps.api",
]-
Set
AUTH_USER_MODEL = "accounts.User"(only for new projects). -
Include URLs:
urlpatterns = [
path("accounts/", include("allauth.urls")),
path("api/", include("apps.api.urls")),
path("dashboard/", include("apps.dashboard.urls")),
path("profile/", include("apps.accounts.urls")),
]-
Copy required settings from
config/settings/base.py(allauth, JWT, etc.). -
Run migrations, configure
.env, copy templates and static files.
- Create OAuth 2.0 credentials in Google Cloud Console.
- Add authorized redirect URI:
http://localhost:8000/accounts/google/login/callback/ - Set
.envor settings:
SOCIALACCOUNT_PROVIDERS = {
"google": {
"APP": {
"client_id": "your-client-id",
"secret": "your-secret",
}
}
}- Create OAuth App in GitHub Developer Settings.
- Callback URL:
http://localhost:8000/accounts/github/login/callback/ - Configure client ID and secret in settings/Admin.
pytest
pytest -v --cov # with coverageblack .
ruff check .authflow/
├── config/ # Django project config
├── apps/
│ ├── accounts/ # User model, allauth, profile
│ ├── core/ # Landing page
│ ├── dashboard/ # Dashboard views
│ └── api/ # JWT endpoints
├── templates/
│ ├── components/ # Navbar, forms, cards, alerts, modals
│ ├── account/ # allauth overrides
│ └── pages/ # landing, dashboard, profile, settings
├── static/
├── tests/
├── Dockerfile
├── docker-compose.yml
└── requirements/
MIT



