Skip to main content

2-Factor Authentication for Django projects

Project description

django-j2fa

2-factor SMS authentication for Django projects. Supports Django 3.x and 4.x.

Install

  1. Add ‘j2fa’ to project settings INSTALLED_APPS

  2. Add j2fa.middleware.Ensure2FactorAuthenticatedMiddleware to project settings MIDDLEWARE (after session middleware)

  3. Make sure user.profile.phone resolves to phone number and user.profile.require_2fa resolves to True/False. Alternatively, you can override Ensure2FactorAuthenticatedMiddleware.is_2fa_required

  4. Set project settings SMS_TOKEN and SMS_SENDER_NAME

  5. Add TwoFactorAuth.as_view() to urls with name=’j2fa-obtain-auth’

Supported Settings

in settings: * SMS_TOKEN: Kajala Group (https://kajala.com) SMS API token. Contact info@kajala.com for access * SMS_SENDER_NAME: SMS sender name, max 13 characters * J2FA_ENABLED: Enabled/disable 2FA system-wide. Default is True * J2FA_SEND_TO_EMAIL: Send 2FA codes also to email. Default is False. * J2FA_FALLBACK_TO_EMAIL: Send 2FA codes to email if SMS sending fails. Default is False.

Static Code Analysis

The library passes both prospector and mypy checking. To install:

pip install prospector pip install mypy

To analyze:

prospector mypy .

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

django_j2fa-3.8.15.tar.gz (45.8 kB view details)

Uploaded Source

File details

Details for the file django_j2fa-3.8.15.tar.gz.

File metadata

  • Download URL: django_j2fa-3.8.15.tar.gz
  • Upload date:
  • Size: 45.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.12

File hashes

Hashes for django_j2fa-3.8.15.tar.gz
Algorithm Hash digest
SHA256 588b4c5d0f1b9f80241f4630d5db3f3160b4e748a626d22c74278633b8bb1504
MD5 0b2fd2c3349d082bb84138235e25beb4
BLAKE2b-256 72250812a097e95b051e09739c42c26edfbfadb3da256720309db84f551f12ae

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page