Skip to main content

Wagtail two-factor auth, updated for Wagtail 6+

Project description

wagtail-2fa-v6

PyPI version Release to PyPi

Supported Python: 3.10, 3.11, 3.12, 3.13
Supported Django: 5.2+
Supported Wagtail: 6.3+

A fork of wagtail-2fa updated for Wagtail 6+ and Django 5.2+. Provides Time-based One-Time Password (TOTP) two-factor authentication in the Wagtail admin.

Use apps like Authy, Google Authenticator, or 1Password to secure your Wagtail login.

📖 Django OTP Documentation


Installation

pip install wagtail-2fa-v6

Then add the following to your INSTALLED_APPS in settings.py:

INSTALLED_APPS = [
    # ...
    'wagtail_2fa',
    'django_otp',
    'django_otp.plugins.otp_totp',
    # ...
]

Next, add the middleware after AuthenticationMiddleware:

MIDDLEWARE = [
    # ... other middleware
    # 'django.contrib.auth.middleware.AuthenticationMiddleware',
    'wagtail_2fa.middleware.VerifyUserMiddleware',
    # 'wagtail.core.middleware.SiteMiddleware',
    # ... other middleware
]

Run migrations:

python manage.py migrate

Settings

Set the following in your Django settings.py file:

  • WAGTAIL_2FA_REQUIRED (default False):Force 2FA login for all staff, superusers, and users with access to the Wagtail admin.

  • WAGTAIL_2FA_OTP_TOTP_NAME (default False):Issuer name for authenticator app. Defaults to WAGTAIL_SITE_NAME if set.(Sets OTP_TOTP_ISSUER under the hood.)


Making 2FA Optional

To make 2FA optional (enabled per group), replace the middleware in your settings:

MIDDLEWARE = [
    # ...
    # 'wagtail_2fa.middleware.VerifyUserMiddleware',
    'wagtail_2fa.middleware.VerifyUserPermissionsMiddleware',
    # ...
]
  • This adds a checkbox to group permissions to enable or disable 2FA.
  • Superusers are always required to use 2FA.

Sandbox

To run a sandbox environment:

  1. Create a virtual environment with Python 3.8

  2. Activate it

  3. Run:

    make sandbox

Access the admin at: http://localhost:8000/admin/

Login credentials:

  • E-mail: superuser@example.com
  • Password: testing

Note: This is still in development. Contribution and testing is highly appreciated.

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

wagtail_2fa_v6-1.0.7.tar.gz (18.4 kB view details)

Uploaded Source

Built Distribution

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

wagtail_2fa_v6-1.0.7-py3-none-any.whl (24.2 kB view details)

Uploaded Python 3

File details

Details for the file wagtail_2fa_v6-1.0.7.tar.gz.

File metadata

  • Download URL: wagtail_2fa_v6-1.0.7.tar.gz
  • Upload date:
  • Size: 18.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for wagtail_2fa_v6-1.0.7.tar.gz
Algorithm Hash digest
SHA256 ddbb5a4ad16a9187983deb65a65bacc0171b914fbc66eeeec72a4cd51a560f81
MD5 06b8447d9d8f86c0aa706247904aeb40
BLAKE2b-256 bbf0a0861ca42a073760080f545fce7c9827a9bff6f9039e9f3c00144d7b09c3

See more details on using hashes here.

File details

Details for the file wagtail_2fa_v6-1.0.7-py3-none-any.whl.

File metadata

  • Download URL: wagtail_2fa_v6-1.0.7-py3-none-any.whl
  • Upload date:
  • Size: 24.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for wagtail_2fa_v6-1.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 77fbeccd44bd5e593eef01c3f2f81e5101a04412625db2f0d0bad376ce0470ba
MD5 2df45ded43c2da143b08ce1b9e1dffdd
BLAKE2b-256 8fdaa5b6b398945ecb092be6004fb4a6c2bf4b93ae5021aea5c1e0b12d94ce56

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