Modern Django REST Framework authentication toolkit with JWT cookies, social login, and 2FA support
Project description
Modern Django REST Framework authentication toolkit with JWT cookies, social login, MFA, and comprehensive user management.
Built as a next-generation alternative to existing DRF authentication packages, DRF Auth Kit provides a complete authentication solution with modern developer experience, inspired by dj-rest-auth but enhanced with full type safety, automatic OpenAPI schema generation, and comprehensive MFA support inspired by django-trench.
Features
Multiple Authentication Types: JWT (default), DRF Token, or Custom
Cookie-Based Security: HTTP-only cookies
Complete User Management: Registration, password reset, email verification
Multi-Factor Authentication: Support multiple MFAs with backup codes
Social Authentication: Django Allauth integration with 50+ providers, support for both OAuth2 and OpenID connect.
Internationalization: Built-in support for 57 languages including English, Spanish, French, German, Chinese, Japanese, Korean, Vietnamese, and more
Full Type Safety: Complete type hints with mypy and pyright
OpenAPI Integration: Auto-generated API documentation with DRF Spectacular
Flexible Configuration: Customizable serializers, views, and authentication backends
Installation
pip install drf-auth-kit
Optional Features:
# For MFA support
pip install drf-auth-kit[mfa]
# For social authentication
pip install drf-auth-kit[social]
# For both MFA and social
pip install drf-auth-kit[all]
Core Dependencies: Django 5.0+, DRF 3.0+, Django Allauth, DRF SimpleJWT
Quick Start
Add to your Django settings:
INSTALLED_APPS = [
# ... your apps
'rest_framework',
'allauth', # Required for social auth
'allauth.account', # Required for social auth
# 'allauth.socialaccount', # For social login
# 'allauth.socialaccount.providers.google', # For Google login
'auth_kit',
# 'auth_kit.social', # For social authentication
# 'auth_kit.mfa', # For MFA support
]
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': [
'auth_kit.authentication.JWTCookieAuthentication',
],
}
# Override only if needed:
# AUTH_KIT = {
# 'USE_MFA': True, # Enable MFA
# }
# Google OAuth2 settings (for social login)
# SOCIALACCOUNT_PROVIDERS = {
# 'google': {
# 'SCOPE': ['profile', 'email'],
# 'AUTH_PARAMS': {'access_type': 'online'},
# 'OAUTH_PKCE_ENABLED': True,
# 'APP': {
# 'client_id': 'your-google-client-id',
# 'secret': 'your-google-client-secret',
# }
# }
# }
Include Auth Kit URLs:
from django.urls import path, include
urlpatterns = [
path('api/auth/', include('auth_kit.urls')),
# path('api/auth/social/', include('auth_kit.social.urls')), # For social auth
# ... your other URLs
]
Run migrations (only needed if using MFA):
python manage.py migrate
Authentication Types
- JWT Authentication (Recommended)
Access and refresh tokens
Token refresh support
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
Documentation
Please visit DRF Auth Kit docs for complete documentation, including:
Detailed configuration options
Custom serializer examples
Advanced usage patterns
Integration guides
Upcoming Features
Enhanced Multi-Factor Authentication
☐ Hardware Security Keys: YubiKey and FIDO2/WebAuthn support
☐ SMS & Voice: Twilio integration for SMS and voice-based MFA
☐ Authenticator Apps: Enhanced TOTP support (Google Authenticator, Authy, etc.)
☐ Trusted Devices: Remember MFA verification for trusted browsers/sessions
Passwordless Authentication
☐ WebAuthn: Biometric and hardware key authentication
☐ Magic Links: Email-based passwordless login
☐ SMS Login: One-time password via SMS
Advanced Security Features
☐ Rate Limiting: Configurable rate limits for authentication endpoints
☐ Account Lockout: Progressive delays and temporary account locks
☐ Audit Logging: Comprehensive security event logging
☐ Geographic Restrictions: IP-based access controls and geo-blocking
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file drf_auth_kit-1.0.1.tar.gz.
File metadata
- Download URL: drf_auth_kit-1.0.1.tar.gz
- Upload date:
- Size: 257.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7efbdc0c3528ea774072fb1ec6552b167d44e3ebbb57fc673258c8444aeaaa0c
|
|
| MD5 |
e14ef3b508605cb7d21c2d6e7efec63c
|
|
| BLAKE2b-256 |
7c44332b9525eb55d789b8aa3fb37cf1362d2814aa5f3d45e1c18e74bda6ee30
|
Provenance
The following attestation bundles were made for drf_auth_kit-1.0.1.tar.gz:
Publisher:
publish.yml on forthecraft/drf-auth-kit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
drf_auth_kit-1.0.1.tar.gz -
Subject digest:
7efbdc0c3528ea774072fb1ec6552b167d44e3ebbb57fc673258c8444aeaaa0c - Sigstore transparency entry: 767257938
- Sigstore integration time:
-
Permalink:
forthecraft/drf-auth-kit@478fd607a7bfdbed21311f3ffb3b26b4cd65edfc -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/forthecraft
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@478fd607a7bfdbed21311f3ffb3b26b4cd65edfc -
Trigger Event:
push
-
Statement type:
File details
Details for the file drf_auth_kit-1.0.1-py3-none-any.whl.
File metadata
- Download URL: drf_auth_kit-1.0.1-py3-none-any.whl
- Upload date:
- Size: 472.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce8ad89eef6f2516c4bda975bb2d5ea495800bcbabb9e8b5c98901559e0795cb
|
|
| MD5 |
03246551a22677c6eee3d8380a5a395e
|
|
| BLAKE2b-256 |
3864a3c0681134d7dbcf1e02cb866d97b30cd557453a77002daa1c85c22e7ceb
|
Provenance
The following attestation bundles were made for drf_auth_kit-1.0.1-py3-none-any.whl:
Publisher:
publish.yml on forthecraft/drf-auth-kit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
drf_auth_kit-1.0.1-py3-none-any.whl -
Subject digest:
ce8ad89eef6f2516c4bda975bb2d5ea495800bcbabb9e8b5c98901559e0795cb - Sigstore transparency entry: 767257943
- Sigstore integration time:
-
Permalink:
forthecraft/drf-auth-kit@478fd607a7bfdbed21311f3ffb3b26b4cd65edfc -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/forthecraft
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@478fd607a7bfdbed21311f3ffb3b26b4cd65edfc -
Trigger Event:
push
-
Statement type: