Skip to main content

django-trench

https://cybersecurity-excellence-awards.com/wp-content/uploads/2021/06/badges_2022_Silver.png
https://github.com/panevo/django-trench-reboot/actions/workflows/django-package.yml/badge.svg https://readthedocs.org/projects/django-trench/badge/?version=latest https://img.shields.io/pypi/v/django-trench-reboot?cacheSeconds=3600
django-trench provides a set of REST API endpoints to supplement django-rest-framework with multi-factor authentication (MFA, 2FA). It supports both standard built-in authentication methods, as well as JWT (JSON Web Token).

We deliver a couple of sample secondary authentication methods including sending OTP based code by:
  • E-mail

  • SMS / text

  • 3rd party mobile apps

  • YubiKey

Developers can easily add their own authentication backends supporting any communication channel.

This is a fork of django_trench. As this package has gone unmaintained for some time, we have decided to maintain a temporary package in order to provide support for Django 4.2 and beyond (if necessary).

Features

  • Easily pluggable and compatible with django-rest-framework

  • Allows user to pick an additional authentication method from range of backends defined by a developer. Read more: backends

  • Comes out of a box with email, SMS, mobile apps and YubiKey support

Supported versions

  • Python 3.10, 3.11, 3.12, 3.13, 3.14

  • Django 4.2, 5.0, 5.1, 5.2, 6.0, 6.1

  • Django REST Framework 3.10, 3.11, 3.12, 3.13, 3.14, 3.15

If you are going to use JWT authentication:

Quick Start

  1. Install the package using pip:

pip install django-trench

or add it to your requirements file.

  1. Add trench library to INSTALLED_APPS in your app settings file:

INSTALLED_APPS = (
    ...,
    'rest_framework',
    'rest_framework.authtoken',  # In case of implementing Token Based Authentication
    ...,
    'trench',
)
  1. Run migrations

Read further in: installation.

Translation

Trench uses Transifex service to translate our package into other languages.

We will appreciate your help with translation.

https://www.transifex.com/merixstudio/django-trench/dashboard/

Local development

  1. Clone the repo.

  2. Crete virtual environment named e.g. .venv:

    virtualenv .venv
  3. Activate the virtual environment:

    source .venv/bin/activate
  4. Install dependencies:

    pip install black mypy
    pip install -r testproject/requirements.txt
  5. Set environment variables:

    export PYTHONPATH=./testproject
    export DJANGO_SETTINGS_MODULE=settings
    export SECRET_KEY=YOURsecretGOEShere
  6. Create a symbolic link to the trench/ module inside the testproject/ directory to emulate the trench package being installed.

    # make sure you run this command from the root directory of this project
    ln -s $(pwd)/trench/ $(pwd)/testproject/trench
  7. Check whether the tests are passing:

    pytest --cov=testproject/trench testproject/tests/

Remember - anytime you change something in the django-trench source code you need to re-build and re-install the package (steps 6-7) for the changes to be present during e.g. running the tests.

  1. [OPTIONAL] To make the tests run faster you can try to execute them in parallel.

    To do so you need to install the pytest-xdist package and run the tests with additional parameter of -n 8 where 8 stands for the number of threads that will be spawned for executing the tests. Depending on the machine you’re using using this tool can speed up the test execution process up to 5 times.

    pytest -n 8 --cov=testproject/trench testproject/tests/

Metadata

Release files for django-trench-reboot 0.4.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 django-trench-reboot 0.4.0
File Size Uploaded
django_trench_reboot-0.4.0.tar.gz 38.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-trench-reboot 0.4.0
File Interpreter ABI Platform
django_trench_reboot-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 85.2 kB

Release files / django_trench_reboot-0.4.0.tar.gz

Download URL django_trench_reboot-0.4.0.tar.gz
Size 38.8 kB
Tags Source
SHA-256 checksum
How to use checksums
5a7ca286e7cc0d85c64267739d9e2cb611cc9663350f1f2a0568bd24ee2d9abc
BLAKE2b-256 checksum
How to use checksums
7e6435bafe4f00027fd0e8620d0201e964452c94c5c4c5afa7e0feaec395a974
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 14, 2026.

Transparency log

Release files / django_trench_reboot-0.4.0-py3-none-any.whl

Download URL django_trench_reboot-0.4.0-py3-none-any.whl
Size 46.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d9443ca4937ff45a7209b880ba254b2b1bc93c221684e120508a3b58a0b0e336
BLAKE2b-256 checksum
How to use checksums
79c88c76de8cf60646cbb52e877b9da240a6ffc1fc2c8d429a9f6988ff843431
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 14, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files

0.3.10

2 release files

0.3.7

2 release files

0.3.6

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

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