Skip to main content

Advanced authentication with OTP and phone number verification

Project description

Moses

Moses is the Django app that provides OTP authentication and phone number email verification by 6-digit verification codes.

Quick start

  1. Add "moses" to your INSTALLED_APPS setting like this::
    INSTALLED_APPS = [
        ...
        'moses',
        'django.contrib.admin',
        ...
    ]
  1. Set moses's CustomUser model as AUTH_USER_MODEL::
    AUTH_USER_MODEL = 'moses.CustomUser'
  1. Allow OTP header in django-cors-headers config::
    CORS_ALLOW_HEADERS = (
        *default_headers,
        "otp",
   )
  1. Add MFAModelBackend as Authentication backend to process OTP on authentication::
    AUTHENTICATION_BACKENDS = [
        'moses.authentication.MFAModelBackend',
        ...
    ]
  1. Add JWTAuthentication to REST_FRAMEWORK's DEFAULT_AUTHENTICATION_CLASSES::
    REST_FRAMEWORK = {
        ...
        'DEFAULT_AUTHENTICATION_CLASSES': [
            'moses.authentication.JWTAuthentication',
        ]
    }
  1. Specify Moses's serializers for Djoser::
    MOSES = {
        "DEFAULT_LANGUAGE": 'en',
        "SEND_SMS_HANDLER": "project.common.sms.send",
        "SENDER_EMAIL": "noreply@example.com",
        "PHONE_NUMBER_VALIDATOR": "project.common.sms.validate_phone_number",
        "DOMAIN": DOMAIN,
        "URL_PREFIX": "http://localhost:8000", # without trailing slash
        "IP_HEADER": "HTTP_CF_CONNECTING_IP" if DEBUG else None,
        "LANGUAGE_CHOICES": (
            ('en', _("English")),
        ),
    }
  1. Add to your root urls.py::
    from moses.admin import OTPAdminAuthenticationForm

    admin.site.site_header = _('Admin Panel')
    admin.site.index_title = 'Welcome'
    admin.site.login_form = OTPAdminAuthenticationForm
  1. Run python manage.py migrate to create the accounts models.

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_moses-0.12.0.tar.gz (19.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_moses-0.12.0-py3-none-any.whl (27.8 kB view details)

Uploaded Python 3

File details

Details for the file django_moses-0.12.0.tar.gz.

File metadata

  • Download URL: django_moses-0.12.0.tar.gz
  • Upload date:
  • Size: 19.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.13.2 Darwin/24.3.0

File hashes

Hashes for django_moses-0.12.0.tar.gz
Algorithm Hash digest
SHA256 6ebfc7d5d1810e2b8042b94a0c76a5829e8d8b43007cc605633fe90d49a71a69
MD5 b3aa68f7366a434b5aac59327c7cc1a1
BLAKE2b-256 ffaad74be710665a0627519f15dedf35eb3874e1acc03e0b89fb738d7c1ab9bf

See more details on using hashes here.

File details

Details for the file django_moses-0.12.0-py3-none-any.whl.

File metadata

  • Download URL: django_moses-0.12.0-py3-none-any.whl
  • Upload date:
  • Size: 27.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.13.2 Darwin/24.3.0

File hashes

Hashes for django_moses-0.12.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2bd45ff3d0db8f62efe9da179e41d860b361dbb9849253b2c7b8de37c777202b
MD5 51b6dbbf4da85e58cfcc9aed04f67b0a
BLAKE2b-256 31edeb20ac92acabb4efd4cb78ba58b892cc76239271f50713de0a4c11313afb

See more details on using hashes here.

Supported by

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