django_phone_confirmation


Namedjango_phone_confirmation JSON
Version 0.3.7 PyPI version JSON
download
home_pagehttps://github.com/ricardosasilva/django_phone_confirmation
SummaryA Django app to validate cell phone numbers through SMS messages and REST.
upload_time2018-08-12 06:45:04
maintainer
docs_urlNone
authorRicardo S. A. Silva
requires_python
licenseMIT
keywords django cell phone confirmation
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Introduction #


A Django app to validate cell phone numbers through SMS messages.

 It uses Django Rest to implement a couple of endpoints to confirm the number and django-sendsms to send messages.


## Installation ##


1. Install package:

        pip install django_phone_confirmation

2. Add phone_confirmation app to INSTALLED_APPS in your django settings.py:

        INSTALLED_APPS = (
            ...,
            'rest_framework',
            'phone_confirmation',
        )

3. Add in urls.py:

        urlpatterns = patterns('',
          url(r'^phone-confirmation/', include('phone_confirmation.urls', namespace='phone_confirmation')),
        )


## A basic flow ##

1. User inputs cell phone number.
1. The app/page make a POST request to the **phone-confirmation/confirmation/** endpoint with the phone number entered by the user.
1. An SMS message is sent to the phone number with a 4 number code.
1. The user enter the code on the App/Page
1. The app/page make a POST request to the **phone-confirmation/activation-key/** endpoint with the code entered by the user.
     The response is a signed activation key if the code is correct, or a 400 status response otherwise.
1. Then the app/page can use the phone number or save the activation key to use it later.


## Endpoints ##

### phone-confirmation/confirmation/ ###

Request example:

    curl -X POST \
      http://localhost:8000/phone-confirmation/confirmation/ \
      -H 'cache-control: no-cache' \
      -H 'content-type: application/json' \
      -d '{
    	"phone_number": "+1-202-555-1234"
    }'

Response example:

    {"phone_number": "+12025551234"}

And the code 6108 (just a example, the code is picked randomly) is sent by SMS to the phone.


### phone-confirmation/activation-key/ ###


Request example:

    curl -X POST \
      http://localhost:8000/phone-confirmation/activation-key/ \
      -H 'cache-control: no-cache' \
      -H 'content-type: application/json' \
      -d '{
    	"phone_number": "+1-202-555-1234",
    	"code": "6108"
    }'

Successful response example:

    {"activation_key":"eyJwaG9uZV9udW1iZXIiOiIrMTIwMjU1NTEyMzQifQ:1dHsio:RvZd7XLwZPvWrN0OI4jA2R5PT8Q"}

Fail response example:

    {"error": "Invalid activation key"}


### phone-confirmation/activation-key/{activation key}/ ###

Request example:


    curl -X GET \
      http://localhost:8000/phone-confirmation/activation-key/eyJwaG9uZV9udW1iZXIiOiIrMTIwMjU1NTEyMzQifQ:1dHsio:RvZd7XLwZPvWrN0OI4jA2R5PT8Q/ \
      -H 'cache-control: no-cache' \
      -H 'content-type: application/json'


Response example:

    {"phone_number": "+12025551234"}



## Settings ##

  These are the default settings:

    PHONE_CONFIRMATION = {
        "SALT": "phonenumber",
        "ACTIVATION_TIMEOUT": 15,
        "SMS_MESSAGE": "Your confirmation code is %(code)s",
        "FROM_NUMBER": "",
        "MAX_CONFIRMATIONS": 10
    }


**SALT**

  Used as salt when creating activation keys.

**ACTIVATION_TIMEOUT**

  How many seconds the user have to confirm the number after the initial requesting

**SMS_MESSAGE**
  The SMS message that will be send to users. The default message is "Your confirmation code is %(code)s".
  Use %{code}s variable to indicate where the confirmation code should be placed.

**FROM_NUMBER**

  The number to use as sender of the SMS messages. You should use the number provided by your SMS gateway. This is the only required setting.

**MAX_CONFIRMATIONS**

  The maximum number of confirmations to keep in database for each phone number. When this amount is reached, the oldest confirmation is removed.


   **NOTE:** As we use the django-sendsms package you need to configure it with your SMS Gateway in order to delivery SMS messages.

**SILENT_CONFIRMATIONS_FILTER**

  A callable with a single argument to ignore fake tests numbers. If it returns True the SMS won't be send.

    Example:
    SILENT_CONFIRMATIONS_FILTER = lambda to: to[:8] == '+1212555'  # Ignore numbers starting with +1212555.


## Throttle Scope ##

  - phone-number-confirmation: Endpoint to request a phone number confirmation (Wiil sent SMS)
  - phone-confirmation-activation-key: Endpoints to validate codes and activation keys.


## Changelog ##

0.3.3 - Changed settings ACTIVATION_MINUTES to ACTIVATION_TIMEOUT and the period time to seconds. Changed settingg SMS_TEMPLATE to SMS_MESSAGE.
0.3.4 - Add activation_key_created signal.
0.3.5 - Add user to activation_key_created signal.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ricardosasilva/django_phone_confirmation",
    "name": "django_phone_confirmation",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "django cell phone confirmation",
    "author": "Ricardo S. A. Silva",
    "author_email": "ricardo@salamandra.cc",
    "download_url": "https://files.pythonhosted.org/packages/11/7b/c0463fde1464e9d22b744a45de02c18ccf87686464f72db88b1c4841431f/django_phone_confirmation-0.3.7.tar.gz",
    "platform": "",
    "description": "# Introduction #\n\n\nA Django app to validate cell phone numbers through SMS messages.\n\n It uses Django Rest to implement a couple of endpoints to confirm the number and django-sendsms to send messages.\n\n\n## Installation ##\n\n\n1. Install package:\n\n        pip install django_phone_confirmation\n\n2. Add phone_confirmation app to INSTALLED_APPS in your django settings.py:\n\n        INSTALLED_APPS = (\n            ...,\n            'rest_framework',\n            'phone_confirmation',\n        )\n\n3. Add in urls.py:\n\n        urlpatterns = patterns('',\n          url(r'^phone-confirmation/', include('phone_confirmation.urls', namespace='phone_confirmation')),\n        )\n\n\n## A basic flow ##\n\n1. User inputs cell phone number.\n1. The app/page make a POST request to the **phone-confirmation/confirmation/** endpoint with the phone number entered by the user.\n1. An SMS message is sent to the phone number with a 4 number code.\n1. The user enter the code on the App/Page\n1. The app/page make a POST request to the **phone-confirmation/activation-key/** endpoint with the code entered by the user.\n     The response is a signed activation key if the code is correct, or a 400 status response otherwise.\n1. Then the app/page can use the phone number or save the activation key to use it later.\n\n\n## Endpoints ##\n\n### phone-confirmation/confirmation/ ###\n\nRequest example:\n\n    curl -X POST \\\n      http://localhost:8000/phone-confirmation/confirmation/ \\\n      -H 'cache-control: no-cache' \\\n      -H 'content-type: application/json' \\\n      -d '{\n    \t\"phone_number\": \"+1-202-555-1234\"\n    }'\n\nResponse example:\n\n    {\"phone_number\": \"+12025551234\"}\n\nAnd the code 6108 (just a example, the code is picked randomly) is sent by SMS to the phone.\n\n\n### phone-confirmation/activation-key/ ###\n\n\nRequest example:\n\n    curl -X POST \\\n      http://localhost:8000/phone-confirmation/activation-key/ \\\n      -H 'cache-control: no-cache' \\\n      -H 'content-type: application/json' \\\n      -d '{\n    \t\"phone_number\": \"+1-202-555-1234\",\n    \t\"code\": \"6108\"\n    }'\n\nSuccessful response example:\n\n    {\"activation_key\":\"eyJwaG9uZV9udW1iZXIiOiIrMTIwMjU1NTEyMzQifQ:1dHsio:RvZd7XLwZPvWrN0OI4jA2R5PT8Q\"}\n\nFail response example:\n\n    {\"error\": \"Invalid activation key\"}\n\n\n### phone-confirmation/activation-key/{activation key}/ ###\n\nRequest example:\n\n\n    curl -X GET \\\n      http://localhost:8000/phone-confirmation/activation-key/eyJwaG9uZV9udW1iZXIiOiIrMTIwMjU1NTEyMzQifQ:1dHsio:RvZd7XLwZPvWrN0OI4jA2R5PT8Q/ \\\n      -H 'cache-control: no-cache' \\\n      -H 'content-type: application/json'\n\n\nResponse example:\n\n    {\"phone_number\": \"+12025551234\"}\n\n\n\n## Settings ##\n\n  These are the default settings:\n\n    PHONE_CONFIRMATION = {\n        \"SALT\": \"phonenumber\",\n        \"ACTIVATION_TIMEOUT\": 15,\n        \"SMS_MESSAGE\": \"Your confirmation code is %(code)s\",\n        \"FROM_NUMBER\": \"\",\n        \"MAX_CONFIRMATIONS\": 10\n    }\n\n\n**SALT**\n\n  Used as salt when creating activation keys.\n\n**ACTIVATION_TIMEOUT**\n\n  How many seconds the user have to confirm the number after the initial requesting\n\n**SMS_MESSAGE**\n  The SMS message that will be send to users. The default message is \"Your confirmation code is %(code)s\".\n  Use %{code}s variable to indicate where the confirmation code should be placed.\n\n**FROM_NUMBER**\n\n  The number to use as sender of the SMS messages. You should use the number provided by your SMS gateway. This is the only required setting.\n\n**MAX_CONFIRMATIONS**\n\n  The maximum number of confirmations to keep in database for each phone number. When this amount is reached, the oldest confirmation is removed.\n\n\n   **NOTE:** As we use the django-sendsms package you need to configure it with your SMS Gateway in order to delivery SMS messages.\n\n**SILENT_CONFIRMATIONS_FILTER**\n\n  A callable with a single argument to ignore fake tests numbers. If it returns True the SMS won't be send.\n\n    Example:\n    SILENT_CONFIRMATIONS_FILTER = lambda to: to[:8] == '+1212555'  # Ignore numbers starting with +1212555.\n\n\n## Throttle Scope ##\n\n  - phone-number-confirmation: Endpoint to request a phone number confirmation (Wiil sent SMS)\n  - phone-confirmation-activation-key: Endpoints to validate codes and activation keys.\n\n\n## Changelog ##\n\n0.3.3 - Changed settings ACTIVATION_MINUTES to ACTIVATION_TIMEOUT and the period time to seconds. Changed settingg SMS_TEMPLATE to SMS_MESSAGE.\n0.3.4 - Add activation_key_created signal.\n0.3.5 - Add user to activation_key_created signal.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A Django app to validate cell phone numbers through SMS messages and REST.",
    "version": "0.3.7",
    "split_keywords": [
        "django",
        "cell",
        "phone",
        "confirmation"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "aa28f53aed7c2efd7cf6bf669b0f1a76",
                "sha256": "9214d4a9f7241e80417307caea3e56f423e99ba54e57348e4a77b71a11212c07"
            },
            "downloads": -1,
            "filename": "django_phone_confirmation-0.3.7.tar.gz",
            "has_sig": false,
            "md5_digest": "aa28f53aed7c2efd7cf6bf669b0f1a76",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 9002,
            "upload_time": "2018-08-12T06:45:04",
            "upload_time_iso_8601": "2018-08-12T06:45:04.717518Z",
            "url": "https://files.pythonhosted.org/packages/11/7b/c0463fde1464e9d22b744a45de02c18ccf87686464f72db88b1c4841431f/django_phone_confirmation-0.3.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2018-08-12 06:45:04",
    "github": true,
    "github_user": "ricardosasilva",
    "github_project": "django_phone_confirmation",
    "travis_ci": false,
    "coveralls": false,
    "lcname": "django_phone_confirmation"
}
        
Elapsed time: 0.09233s