Django Admin 2FA Plus
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.
🌟 Features
- 🔐 Secure Django Admin with 2FA
- 📱 TOTP Authentication (Google Authenticator, Authy, 1Password, etc.)
- 🔑 One-time use Backup Recovery Codes
- 📩 Optional Email OTP fallback (configurable)
- 🧩 Admin interface to manage TOTP Devices
- 🎛️ Trusted Device support (via cookies)
- 🎨 Customizable templates
- ⚙️ Middleware-based enforcement
- ⚡ Works with Django 3.2+
📦 Installation
pip install django-admin-2fa-plus
Add it to your INSTALLED_APPS:
INSTALLED_APPS = [
...
"django_admin_2fa_plus",
]
Add the middleware near the top of your middleware stack:
MIDDLEWARE = [
"django_admin_2fa_plus.middleware.Admin2FAMiddleware",
...
]
Include the URLs:
# urls.py
path("admin-2fa/", include("django_admin_2fa_plus.urls")),
Run migrations:
python manage.py migrate
🚀 Quick Start
- Log in to Django Admin.
- Go to
/admin-2fa/setup/to begin TOTP setup. - Scan the QR code using your authenticator app.
- Enter the generated code to confirm.
- Save the backup codes displayed — each can be used once.
- Done! 2FA is now required to access the admin area.
⚙️ Optional Settings
You can override the default behavior using these settings in your Django settings.py:
| Setting | Default | Description |
|---|---|---|
ADMIN_2FA_REDIRECT_URL |
/admin/ |
URL to redirect to after successful verification |
ADMIN_2FA_TOTP_DIGITS |
6 |
Number of digits for the TOTP code |
ADMIN_2FA_TOTP_STEP |
30 |
Step size in seconds for TOTP code rotation |
ADMIN_2FA_TOTP_ALGORITHM |
'sha1' |
Algorithm used for TOTP ('sha1', 'sha256', 'sha512') |
ADMIN_2FA_BACKUP_CODES_COUNT |
10 |
Number of backup codes generated |
ADMIN_2FA_TRUSTED_DEVICE_DAYS |
30 |
Days to trust a device when user selects "Remember this device" |
ADMIN_2FA_ENABLE_EMAIL_OTP |
False |
Enable fallback email OTP support |
ADMIN_2FA_EMAIL_SENDER |
None |
Sender address for email OTP |
ADMIN_2FA_EMAIL_SUBJECT |
'Your login code' |
Subject line for email OTP |
ADMIN_2FA_EMAIL_TEMPLATE |
None |
Path to custom HTML template for email OTP |
🧪 Testing
Unit test are pending
🤝 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
Please follow PEP8, isort and write tests for any new functionality.
📬 Support
For questions, bug reports, or feature requests, please open an issue on GitHub.
📄 License
This project is licensed under the MIT License. See the LICENSE file for details.
Secure your Django Admin with ease ✨
Metadata
Release files for django-admin-2fa-plus 0.1.0
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 | |
|---|---|---|---|---|
| django_admin_2fa_plus-0.1.0.tar.gz | 13.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_admin_2fa_plus-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 29.1 kB
Release files / django_admin_2fa_plus-0.1.0.tar.gz
| Download URL | django_admin_2fa_plus-0.1.0.tar.gz |
|---|---|
| Size | 13.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8a437b7d87f27a15a51fa6b83aae035a533a61c41d5f28dec8579cf9fbc8e8c5
|
|
BLAKE2b-256 checksum How to use checksums |
2e671814060f413c464f8e38a951d1bc9f8f7630e01380cca2772d99d8abb634
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.3
|
Release files / django_admin_2fa_plus-0.1.0-py3-none-any.whl
| Download URL | django_admin_2fa_plus-0.1.0-py3-none-any.whl |
|---|---|
| Size | 15.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
174c59c98833fe0f6fefe6320ad5428c897b4842928f4891d567f000d80e53c2
|
|
BLAKE2b-256 checksum How to use checksums |
67c859cc19af01732229bf1e2480a81efc4f87385f9e8464b847c8c34cf1b4ba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.3
|
Security for django-admin-2fa-plus 0.1.0
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.