Skip to main content

wagtail-2fa

https://img.shields.io/pypi/v/wagtail-2fa.svg https://github.com/labd/wagtail-2fa/actions/workflows/python-test.yml/badge.svg https://readthedocs.org/projects/wagtail-2fa/badge/?version=stable

This Django app adds two factor authentication to Wagtail. Behind the scenes it use django-otp which supports Time-based One-Time Passwords (TOTP). This allows you to use various apps like Authy, Google Authenticator, or 1Password.

Installation

pip install wagtail-2fa

Then add the following lines to the INSTALLED_APPS list in your Django settings:

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

Next add the required middleware to the MIDDLEWARE. It should come after the AuthenticationMiddleware:

MIDDLEWARE = [
    # .. other middleware
    # 'django.contrib.auth.middleware.AuthenticationMiddleware',

    'wagtail_2fa.middleware.VerifyUserMiddleware',

    # 'wagtail.core.middleware.SiteMiddleware',
    # .. other middleware
]

Migrate your database:

python manage.py migrate

Settings

The following settings are available (Set via your Django settings):

  • WAGTAIL_2FA_REQUIRED (default False): When set to True all staff, superuser and other users with access to the Wagtail Admin site are forced to login using two factor authentication.

  • WAGTAIL_2FA_OTP_TOTP_NAME (default: False): The issuer name to identify which site is which in your authenticator app. If not set and WAGTAIL_SITE_NAME is defined it uses this. sets OTP_TOTP_ISSUER under the hood.

Making 2FA optional

With the default VerifyUserMiddleware middleware, 2FA is enabled for every user. To make 2FA optional, use the VerifyUserPermissionsMiddleware middleware instead.

To do so, use the VerifyUserPermissionsMiddleware middleware instead of the VerifyUserMiddleware in your Django settings:

MIDDLEWARE = [
    # ...
    # 'wagtail_2fa.middleware.VerifyUserMiddleware',
    'wagtail_2fa.middleware.VerifyUserPermissionsMiddleware',
    # ...
]

When this middleware is used, a checkbox is added to the group permissions and 2FA can be enabled or disabled per group.

2FA is always enabled for superusers, regardless of the middleware used.

Sandbox

First create a new virtualenv with Python 3.11 or newer and activate it. Then run the following commands:

make sandbox

You can then visit http://localhost:8000/admin/ and login with the following credentials:

  • E-mail: superuser@example.com

  • Password: testing

Releasing

Releases are managed with changie:

  1. Add a changelog entry to your pull request with changie new.

  2. After merging to master, a release pull request is opened (or updated) automatically, with the new version and the updated CHANGELOG.md.

  3. Merging the release pull request creates the GitHub release, which publishes the package to PyPI.

Metadata

Release files for wagtail-2fa 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for wagtail-2fa 2.0.0
File Size Uploaded Provenance Actions
wagtail_2fa-2.0.0.tar.gz 21.9 kB With provenance Details for wagtail_2fa-2.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for wagtail-2fa 2.0.0
File Interpreter ABI Platform Actions
wagtail_2fa-2.0.0-py3-none-any.whl Python 3 none any Details for wagtail_2fa-2.0.0-py3-none-any.whl

Total release size: 63.7 kB

Release files / wagtail_2fa-2.0.0.tar.gz

Download URL wagtail_2fa-2.0.0.tar.gz
Size 21.9 kB
Tags Source
SHA-256 checksum
How to use checksums
2e4c31c2ee027a38796e5076f1cc0146be7a58a479961b870c66b0bf663041bb
BLAKE2b-256 checksum
How to use checksums
2051fab913977a3bc6bd30778e0ac2e8f7506ea4d19303b3727b7fdf98311ba3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 17, 2026.

Transparency log

Release files / wagtail_2fa-2.0.0-py3-none-any.whl

Download URL wagtail_2fa-2.0.0-py3-none-any.whl
Size 41.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c533776a0d94faf93d3f6371bfaf167ba85843ea07cc4d70cab920746eebb137
BLAKE2b-256 checksum
How to use checksums
28c6d7c337bebfff93718acd90754d2f4d65de37ff0a9797177ded040ef663df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 17, 2026.

Transparency log

Security for wagtail-2fa 2.0.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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for wagtail_2fa-2.0.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 17, 2026.

Transparency log

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page