Skip to main content

Internal authentication package using Django Allauth, DRF and SimpleJWT

Project description

Bunifu Django Auth

A standardized authentication framework for Django projects built on:

  • Django
  • Django Allauth
  • Django REST Framework
  • SimpleJWT

Designed for internal organizational consistency and centralized user model management.


Features

  • Email-based authentication
  • JWT access & refresh tokens
  • Token rotation & blacklisting
  • DRF-ready endpoints
  • Automatic safe default configuration
  • Pluggable and override-friendly
  • Production-ready test suite (pytest + factoryboy)

Installation

TestPypi Repository

uv pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple  bunifu-django-auth       

Quick Start

1️⃣ Add to Installed Apps

INSTALLED_APPS = [
    "allauth",
    "allauth.account",
    "rest_framework",
    "rest_framework_simplejwt",
    "rest_framework_simplejwt.token_blacklist",
    "bunifu_django_auth",
]

Register auth user model

AUTH_USER_MODEL="bunifu_django_auth.User"

2️⃣ Include URLs

from django.urls import path, include

urlpatterns = [
    path("auth/", include("bunifu_django_auth.urls")),
]

Migrate the tables

python manage.py makemigrations bunifu_django_auth
python manage.py makemigrations account
python manage.py migrate

Include the JWTAuthorization

REST_FRAMEWORK = {
    "DEFAULT_AUTHENTICATION_CLASSES": (
        "rest_framework_simplejwt.authentication.JWTAuthentication",
    )
}

That’s it.

No additional configuration required.


Available Endpoints

Endpoint Method Description
/auth/register/ POST Register new user
/auth/login/ POST Obtain JWT access & refresh tokens
/auth/refresh/ POST Refresh access token
/auth/logout/ POST Blacklist refresh token

Default Configuration

The package automatically applies safe defaults:

  • Email authentication
  • JWT token rotation
  • 15-minute access tokens
  • 7-day refresh tokens
  • Refresh token blacklisting
  • DRF JWT authentication backend

All settings can be overridden in the host project.

Example:

SIMPLE_JWT = {
    "ACCESS_TOKEN_LIFETIME": timedelta(minutes=5),
}

Overriding Serializers

You may override serializers if needed:

BUNIFU_REGISTER_SERIALIZER = "yourapp.serializers.CustomRegisterSerializer"

Running Tests

pytest

With coverage:

pytest --cov=bunifu_django_auth

License

MIT License © 2026 Bunifu

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bunifu_django_auth-0.0.1.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bunifu_django_auth-0.0.1-py3-none-any.whl (14.9 kB view details)

Uploaded Python 3

File details

Details for the file bunifu_django_auth-0.0.1.tar.gz.

File metadata

  • Download URL: bunifu_django_auth-0.0.1.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for bunifu_django_auth-0.0.1.tar.gz
Algorithm Hash digest
SHA256 1b64fb081cf72fdcaea99f0ccc21553c06ccaa6aa075c63c98be1c382cb26019
MD5 df78ce2a59f87da23e9dc836a763382a
BLAKE2b-256 271c31282852ece916797851012953beaffa01ccd9a69c0dc046983fd17c9410

See more details on using hashes here.

File details

Details for the file bunifu_django_auth-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for bunifu_django_auth-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 49719092e0ad250a41ec4e3edb2a44b1fdb54374d8e25455f335764502cb273b
MD5 9c3d6f52bbc4a4da912007228aac71c0
BLAKE2b-256 56fefe8347c6fffd25ff4dac4077d28953f4e3456572c5cc63d82de3fc72b9bb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page