Skip to main content

Two-Factor Authentication for Django Admin with TOTP, backup codes, and trusted devices.

Project description

Django Admin 2FA

PyPI version License: MIT TRADEMARK Django Versions Build Status

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

  1. Log in to Django Admin.
  2. It will automatically return to 2FA Setup page.
  3. Scan the QR code using your authenticator app.
  4. Enter the generated code to confirm.
  5. Copy/Print the backup codes displayed — each can be used once.
  6. Done! (Logout and login again to see effect)

🤝 Contributing

Contributions are welcome! To contribute:

  1. Fork the repository
  2. Create your feature branch: git checkout -b feature/my-feature
  3. Commit your changes: git commit -am 'Add new feature'
  4. Update code, if needed, as per pre-commit logs
  5. Push to the branch: git push origin feature/my-feature
  6. 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


Download files

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

Source Distribution

django_admin_2fa-1.0.0.tar.gz (17.5 kB view details)

Uploaded Source

Built Distribution

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

django_admin_2fa-1.0.0-py3-none-any.whl (27.2 kB view details)

Uploaded Python 3

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

Hashes for django_admin_2fa-1.0.0.tar.gz
Algorithm Hash digest
SHA256 6cced99d357b5dc945d99b9aa9604e629745a09e98807d5b3e82d2ade4602b19
MD5 127558d2f30cd961f2026d91851f7766
BLAKE2b-256 bb16b2227804d1ed208564466fbc59487a6ca8cf431afe3ca55c04dc5cc217ee

See more details on using hashes here.

File details

Details for the file django_admin_2fa-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_admin_2fa-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4a1887491dcf70eed3c58e1f78d9a708de7dd52800ee5d9f23394d937c740c7f
MD5 2e87e8a8509cc3fbe99d844582bf5dc7
BLAKE2b-256 32f05a8313e572c2a93ba5d1312108a501188179eb46ec334a58db7709f777fd

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