Skip to content

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).

develop
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
.tx
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

django-trench

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
  • Django 2.0, 2.1, 2.2, 3.0
  • Django REST Framework 3.10
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/

Demo project

You can also check our live demo.

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 pytest pytest-cov black flake8 isort mypy
    pip install -r testproject/requirements.txt
  5. Set environment variables:

    export PYTHONPATH=./testproject
    export DJANGO_SETTINGS_MODULE=settings
    export SECRET_KEY=YOURsecretGOEShere
  6. Build your django-trench package distribution locally:

    python setup.py sdist

    This will create a dist directory and place a file named django-trench-x.x.x.tar.gz where x.x.x will be replaced with the current package's version.

  7. Install the django-trench package that you just built:

    pip install dist/django-trench-x.x.x.tar.gz

    Use the actual distribution file name, the one above is just an example.

  8. 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.

About

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).

Topics

Resources

License

Packages

No packages published

Languages