Welcome to DRF Auth Kit documentation!

DRF AUTH KIT

PyPI Code Coverage Test Checked with mypy Checked with pyright Docstring

Modern Django REST Framework authentication toolkit with JWT cookies, social login, and comprehensive user management.

Features

🔐 Multiple Authentication Types
  • JWT tokens with automatic refresh

  • DRF token authentication

  • Custom authentication support

🍪 Cookie-Based Security
  • Secure HTTP-only cookies

  • Automatic token management

  • CSRF protection

📧 Complete User Management
  • User registration with email verification

  • Password reset and change

  • Email verification workflows

🔧 Flexible Configuration
  • Multiple authentication backends

  • Customizable serializers and views

  • Django Allauth integration

🚀 Developer Experience
  • Full type hints support

  • Comprehensive test coverage

  • Auto-generated API documentation

Installation

pip install drf-auth-kit

Quick Start

  1. Add to your Django settings:

INSTALLED_APPS = [
    # ... your apps
    'rest_framework',
    'allauth',
    'allauth.account',
    'auth_kit',
]

REST_FRAMEWORK = {
    'DEFAULT_AUTHENTICATION_CLASSES': [
        'auth_kit.authentication.AuthKitAuthentication',
    ],
}

AUTH_KIT = {
    'AUTH_TYPE': 'jwt',  # or 'token' or 'custom'
    'USE_AUTH_COOKIE': True,
}
  1. Include Auth Kit URLs:

from django.urls import path, include

urlpatterns = [
    path('api/auth/', include('auth_kit.urls')),
    # ... your other URLs
]
  1. Run migrations:

python manage.py migrate

Authentication Types

JWT Authentication (Recommended)
  • Access and refresh tokens

  • Automatic token refresh

  • Secure cookie storage

DRF Token Authentication
  • Simple token-based auth

  • Compatible with DRF TokenAuthentication

  • Cookie support available

Custom Authentication
  • Bring your own authentication backend

  • Full customization support

  • Integrate with third-party services

API Endpoints

The package provides these authentication endpoints:

  • POST /auth/login/ - User authentication

  • POST /auth/logout/ - User logout

  • POST /auth/registration/ - User registration

  • POST /auth/password/reset/ - Password reset request

  • POST /auth/password/reset/confirm/ - Password reset confirmation

  • POST /auth/password/change/ - Password change

  • GET/PUT/PATCH /auth/user/ - User profile management

  • POST /auth/registration/verify-email/ - Email verification

  • POST /auth/token/refresh/ - JWT token refresh (JWT mode only)

Documentation

Please visit DRF Auth Kit docs for complete documentation, including:

  • Detailed configuration options

  • Custom serializer examples

  • Advanced usage patterns

  • Integration guides

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contents

Development