G
YouTube TikTok Games
Skip to content
devabusayedPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

AuthFlow – Complete Django Authentication System

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).

Screenshots

Landing page Landing

Login Sign Up
Login Sign Up

Dashboard Dashboard

Tech Stack

  • 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

Quick Start

Local Development

  1. Clone and create virtual environment:
python -m venv .venv
source .venv/bin/activate  # Windows: .venv\Scripts\activate
pip install -r requirements/dev.txt
  1. Copy environment file and configure:
cp .env.example .env
# Edit .env - SECRET_KEY and DATABASE_URL (leave empty for SQLite)
  1. Run migrations:
python manage.py migrate
  1. Build CSS (Tailwind + DaisyUI):
npm install
npm run build:css
  1. Create superuser and run server:
python manage.py createsuperuser
python manage.py runserver

Docker

cp .env.example .env
docker-compose up --build

Features

  • 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)

API Endpoints

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

Example: Register

curl -X POST http://localhost:8000/api/register/ \
  -H "Content-Type: application/json" \
  -d '{"email":"user@example.com","name":"User","password":"securepass123"}'

Example: Login

curl -X POST http://localhost:8000/api/login/ \
  -H "Content-Type: application/json" \
  -d '{"email":"user@example.com","password":"securepass123"}'

Integration with Existing Django Projects

  1. Copy apps/accounts, apps/core, apps/dashboard, apps/api into your project.

  2. 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",
]
  1. Set AUTH_USER_MODEL = "accounts.User" (only for new projects).

  2. 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")),
]
  1. Copy required settings from config/settings/base.py (allauth, JWT, etc.).

  2. Run migrations, configure .env, copy templates and static files.

Social Provider Setup

Google

  1. Create OAuth 2.0 credentials in Google Cloud Console.
  2. Add authorized redirect URI: http://localhost:8000/accounts/google/login/callback/
  3. Set .env or settings:
SOCIALACCOUNT_PROVIDERS = {
    "google": {
        "APP": {
            "client_id": "your-client-id",
            "secret": "your-secret",
        }
    }
}

GitHub

  1. Create OAuth App in GitHub Developer Settings.
  2. Callback URL: http://localhost:8000/accounts/github/login/callback/
  3. Configure client ID and secret in settings/Admin.

Testing

pytest
pytest -v --cov  # with coverage

Code Quality

black .
ruff check .

Project Structure

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/

License

MIT

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages