Skip to main content

A Django app to support phone number verification using security code sent via SMS.

Project description

https://github.com/CuriousLearner/django-phone-verify/actions/workflows/main.yml/badge.svg?branch=master https://coveralls.io/repos/github/CuriousLearner/django-phone-verify/badge.svg?branch=master License https://static.pepy.tech/badge/django-phone-verify?period=total&units=international_system&left_color=black&right_color=darkgreen&left_text=Downloads https://img.shields.io/badge/Made%20with-Python-1f425f.svg https://img.shields.io/badge/Maintained%3F-yes-green.svg https://badge.fury.io/py/django-phone-verify.svg https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square

A Django app to support phone number verification using the security code sent via SMS.

Salient Features

  • Let’s devs verify phone numbers via SMS.

  • Extensibility to provide tokens with varying lengths.

  • Comes with Twilio and Nexmo already integrated.

  • Set expiration time on tokens.

  • Provides an interface for writing custom SMS sending backend for easy extensibility.

  • Does not mess up with existing AUTH_USER_MODEL at all.

  • Can be used for several potential use-cases, and not just auth.

  • Provides ready endpoints for sending SMS and verification (See api_endpoints.rst).

Installation

pip install django-phone-verify[all]

You also have option to install only the required dependencies for Twilio or Nexmo:

pip install django-phone-verify[twilio]
pip install django-phone-verify[nexmo]

Configuration

  • Add app to INSTALLED_APPS

# In settings.py:

# Add app to `INSTALLED_APPS`
INSTALLED_APPS = [
    ...
    "phone_verify",
    ...
]
  • Add settings for Phone Verify as you desire:

# In settings.py
# Add settings for phone_verify to work
PHONE_VERIFICATION = {
    "BACKEND": "phone_verify.backends.twilio.TwilioBackend",
    "OPTIONS": {
        "SID": "fake",
        "SECRET": "fake",
        "FROM": "+14755292729",
        "SANDBOX_TOKEN": "123456",
    },
    "TOKEN_LENGTH": 6,
    "MESSAGE": "Welcome to {app}! Please use security code {security_code} to proceed.",
    "APP_NAME": "Phone Verify",
    "SECURITY_CODE_EXPIRATION_TIME": 3600,  # In seconds only
    "VERIFY_SECURITY_CODE_ONLY_ONCE": False,  # If False, then a security code can be used multiple times for verification
}

Usage

  • To explore more about how to use, integrate and leverage the existing functionality of Django Phone Verify, have a look at getting_started.rst

Note: Django Phone Verify also provides Nexmo as a backend service other than Twilio. To switch to Nexmo, replace BACKEND within your PHONE_VERIFICATION setting with phone_verify.backends.nexmo.NexmoBackend and define KEY within OPTIONS of PHONE_VERIFICATION setting, with your Nexmo API key, in place of already available SID.

Compatibility

  • Python 3.6+

  • Django 2.1+

  • Django REST Framework 3.9+

Contributing

No code is bug-free and I’m sure this app will have bugs. If you find any bugs, please create an issue on GitHub.

Licence

GPLv3

Changelog

See changelog.rst

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_phone_verify-3.0.1.tar.gz (32.4 kB view details)

Uploaded Source

Built Distribution

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

django_phone_verify-3.0.1-py3-none-any.whl (33.2 kB view details)

Uploaded Python 3

File details

Details for the file django_phone_verify-3.0.1.tar.gz.

File metadata

  • Download URL: django_phone_verify-3.0.1.tar.gz
  • Upload date:
  • Size: 32.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.16

File hashes

Hashes for django_phone_verify-3.0.1.tar.gz
Algorithm Hash digest
SHA256 fb4f1429eaed67b60e0757740a15ea3d78278512148f7cca5675c2fbca9c9f53
MD5 bedc67faafb04181a0aeea3005cf41d6
BLAKE2b-256 ce9b6aea2f0a5690772bf823b99d0cba54a94a6fe1daf5f638d1cd1a408ae95b

See more details on using hashes here.

File details

Details for the file django_phone_verify-3.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for django_phone_verify-3.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 45807c969aa95133be6cb1d58f352f5faf989f6a1e6fa3471844b0bef011de63
MD5 10f3223cfa16b82f40f78436dc8b16ec
BLAKE2b-256 0c4dbf6ac29f6efa256685c0ac7a0928c8368d98414d444aa32c8622b27248cc

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