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
uv add bunifu-django-auth
---------------------
pip install bunifu-django-auth
Quick Start
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.BunifuUser"
Include URLs
from django.urls import path, include
urlpatterns = [
path("auth/", include("bunifu_django_auth.urls")),
# add allauth urls for the allauth paths
path("accounts/", include("allauth.urls")),
]
Include the JWTAuthorization
REST_FRAMEWORK = {
"DEFAULT_AUTHENTICATION_CLASSES": (
"rest_framework_simplejwt.authentication.JWTAuthentication",
)
}
Ensure the allauth middleware is added as below
MIDDLEWARE = [
...
# add this
"allauth.account.middleware.AccountMiddleware"
]
Migrate the tables
python manage.py migrate
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 custom user model abstract
If by any chance you want to update your user model You can simply inherit from the BunifuAbstractUser as shown below
from django.db import models
from bunifu_django_auth.models import BunifuAbstractUser
class CustomUser(BunifuAbstractUser):
user_stats = models.JSONField(default=list)
Then in the settings
AUTH_USER_MODEL = "your_app.CustomUser"
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
Metadata
Release files for bunifu-django-auth 0.3.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bunifu_django_auth-0.3.4.tar.gz | 12.4 kB | Without provenance | Details for bunifu_django_auth-0.3.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bunifu_django_auth-0.3.4-py3-none-any.whl | Python 3 | none | any | Details for bunifu_django_auth-0.3.4-py3-none-any.whl |
Total release size: 30.7 kB
Release files / bunifu_django_auth-0.3.4.tar.gz
| Download URL | bunifu_django_auth-0.3.4.tar.gz |
|---|---|
| Size | 12.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
74b07a77071f56695384dfb18282f1e76c7abe73f834ae333aef9841b93e077a
|
|
BLAKE2b-256 checksum How to use checksums |
4aca53667b5999d3b8c0277af475fdd03fbb7a6534349b47e34da38cd5041f43
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.12
|
Release files / bunifu_django_auth-0.3.4-py3-none-any.whl
| Download URL | bunifu_django_auth-0.3.4-py3-none-any.whl |
|---|---|
| Size | 18.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
debe1679c8b0e1efb53dd2de2c493f646a0978f4d099be564a8f2a1bc45bb8b4
|
|
BLAKE2b-256 checksum How to use checksums |
65ce47826edccf961a129ec637f6e03a96df44baad4cdf3d4f3c79cd1caeee9c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.12
|
Security for bunifu-django-auth 0.3.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.