Two-Factor Authentication for Django Admin with TOTP, backup codes, and trusted devices.
Project description
Django Admin 2FA
Django Admin 2FA Plus is a secure, easy-to-use Two-Factor Authentication package for Django Admin. It provides TOTP-based verification (Google Authenticator, Authy, etc.), recovery codes, and optional trusted devices.
🚀 Key Features
🔐 Fortified Admin Security
- Two-Factor Authentication (2FA) for Django Admin
- Adds an extra layer of protection for staff logins
📲 Flexible TOTP Support
- Time-based One-Time Passwords using apps like:
- Google Authenticator
- Authy
- and more!
🛡️ Recovery & Backup
- One-time backup codes for account recovery
🧩 Device & Access Control
- Built-in admin panel to view & manage TOTP devices
- "Trusted Device" support — keeps your users happy with fewer prompts
🎨 Rate Limit
- Extra security with rate limit
⚙️ Compatibility
- Supports Django 3.2-5.* and above
- Easy to integrate with existing Django projects
📦 Installation
pip install django-admin-2fa
Add it to your INSTALLED_APPS:
INSTALLED_APPS = [
...
"djangoadmin2fa",
]
Include the URLs:
# urls.py
path("admin2fa/", include("djangoadmin2fa.urls")),
Add SITE_NAME variable in your django setting (Recomended) Otherwise default DJANGO ADMIN 2FA will be shown in your authenticator app and in backup code print page instead of your website name.
#settings.py
SITE_NAME = "www.yoursite.com"
Add the middleware near the top of your middleware stack:
MIDDLEWARE = [
...
"djangoadmin2fa.middleware.Admin2FAMiddleware",
"djangoadmin2fa.middleware.Admin2faRateLimitMiddleware",
]
Run migrations:
python manage.py migrate
🚀 Quick Start
- Log in to Django Admin.
- It will automatically return to 2FA Setup page.
- Scan the QR code using your authenticator app.
- Enter the generated code to confirm.
- Copy/Print the backup codes displayed — each can be used once.
- Done! (Logout and login again to see effect)
🤝 Contributing
Contributions are welcome! To contribute:
- Fork the repository
- Create your feature branch:
git checkout -b feature/my-feature - Commit your changes:
git commit -am 'Add new feature' - Update code, if needed, as per pre-commit logs
- Push to the branch:
git push origin feature/my-feature - Open a Pull Request
You must follow PEP8, isort and must have proper test cases.
📬 Support
For questions, bug reports, or feature requests, please open an issue on GitHub. Feel free to reach out via email: python.package@himosoft.com.bd
📄 License
This project is licensed under the MIT License. See the LICENSE file for details. 🚫 Branding usage is restricted — see the LICENSE and TRADEMARK files for details.
Secure your Django Admin with TOTP based 2FA system ✨
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 django_admin_2fa-1.0.0.tar.gz.
File metadata
- Download URL: django_admin_2fa-1.0.0.tar.gz
- Upload date:
- Size: 17.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6cced99d357b5dc945d99b9aa9604e629745a09e98807d5b3e82d2ade4602b19
|
|
| MD5 |
127558d2f30cd961f2026d91851f7766
|
|
| BLAKE2b-256 |
bb16b2227804d1ed208564466fbc59487a6ca8cf431afe3ca55c04dc5cc217ee
|
File details
Details for the file django_admin_2fa-1.0.0-py3-none-any.whl.
File metadata
- Download URL: django_admin_2fa-1.0.0-py3-none-any.whl
- Upload date:
- Size: 27.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a1887491dcf70eed3c58e1f78d9a708de7dd52800ee5d9f23394d937c740c7f
|
|
| MD5 |
2e87e8a8509cc3fbe99d844582bf5dc7
|
|
| BLAKE2b-256 |
32f05a8313e572c2a93ba5d1312108a501188179eb46ec334a58db7709f777fd
|