Skip to main content

This is a fork from https://github.com/merixstudio/django-trench meant to be used with baseapp packages

https://cybersecurity-excellence-awards.com/wp-content/uploads/2021/06/badges_2022_Silver.png
https://github.com/merixstudio/django-trench/actions/workflows/django-package.yml/badge.svg https://codecov.io/gh/merixstudio/django-trench/branch/master/graph/badge.svg?token=U4yDiXUDkb https://readthedocs.org/projects/django-trench/badge/?version=latest https://img.shields.io/pypi/v/django-trench
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.

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.7, 3.8, 3.9, 3.10, 3.11

  • Django 2.0, 2.1, 2.2, 3.0, 3.1, 3.2, 4.0, 4.1

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

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 baseapp-django-trench 0.4.4

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

Source distribution (sdist)

Source distribution for baseapp-django-trench 0.4.4
File Size Uploaded Provenance
baseapp-django-trench-0.4.4.tar.gz 31.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for baseapp-django-trench 0.4.4
File Interpreter ABI Platform
baseapp_django_trench-0.4.4-py3-none-any.whl Python 3 none any Details

Total release size: 72.1 kB

Release files / baseapp-django-trench-0.4.4.tar.gz

Download URL baseapp-django-trench-0.4.4.tar.gz
Size 31.4 kB
Tags Source
SHA-256 checksum
How to use checksums
b76795a893b01b217484192d7c9777a0ec4864ac775d179808194ac55568474a
BLAKE2b-256 checksum
How to use checksums
73261deadc720b5015879f491690eec9c269a684a137661ec84ee16ecff565d8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.12

Release files / baseapp_django_trench-0.4.4-py3-none-any.whl

Download URL baseapp_django_trench-0.4.4-py3-none-any.whl
Size 40.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c751e0c5671d8dc0c50214e2ae08172c351034d3f1765d2f14b7c252552ef31a
BLAKE2b-256 checksum
How to use checksums
f9387a59082733305f5d3056ecac167c67b9ba261e1a9abec0d24767e7fa83b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.12

Security for baseapp-django-trench 0.4.4

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.

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