Skip to main content

Connection with Iranian SMS services for user authentication or sending messages.

This project has been archived.

The maintainers of this project have marked this project as archived. No new releases are expected.

Project description

Django Iran SMS

Overview

A Django-based SMS integration system for simplifying in-country SMS usage in Iran, leveraging the parsianwebco.ir service with JWT authentication. Developed by the Chelseru team, this package is designed to support additional services in future releases.

Features

  • Integration with parsianwebco.ir
  • JWT-based authentication using rest_framework_simplejwt
  • Scalable and extensible for other SMS providers
  • Easy installation and configuration

Installation

Prerequisites

  • Python 3.11
  • Django 5.1 or higher

Installation via pip

pip install django-iran-sms

Configuration

In your Django project's settings.py, add the following parameters:

settings.py

INSTALLED_APPS = [
...
'drfiransms', # When used in DRF.

]
DJANGO_IRAN_SMS = {
    'AUTHENTICATION': 'rest_framework_simplejwt',  # Specify the authentication method
    'SMS_BACKEND': 'PARSIAN_WEBCO_IR',  # Set the SMS provider backend
    'OTP_CODE': {
        'LENGTH': 8,  # Default length of OTP code = 6
        'EXPIRE_PER_MINUTES': 4,  # Default expiration time per minutes = 2
    },
    'PARSIAN_WEBCO_IR': {
        'API_KEY': 'API_KEY obtained from sms.parsianwebco.ir',  # API key from the SMS provider
        'TEMPLATES': {
            'OTP_CODE': 1,  # Template ID for OTP code
        }
    }
}

Usage

URL Configuration

In your urls.py, include the following views:

  • OTPCodeSend: For sending OTP codes.
  • Authentication: For handling authentication and optional registration.
  • MessageSend: For sending Messages.

urls.py

from drfiransms.views import OTPCodeSend, Authentication, MessageSend

urlpatterns += [
    path('lur/send-code/', OTPCodeSend.as_view(), name='send_code'),  # Endpoint to send OTP code
    path('lur/authentication/', Authentication.as_view(), name='authentication'),  # Endpoint for authentication
    path('lur/send-message/', MessageSend.as_view(), name='send_message'),  # Endpoint to send a message
]

Sending Verification Code via API

To send a POST request for receiving a verification code for a mobile number, use the following structure:

curl -X POST https://djangoiransms.chelseru.com/lur/send-code/ \
     -H "Content-Type: application/json" \
     -d '{
           "mobile_number": "09123456789"
         }'
curl -X POST https://djangoiransms.chelseru.com/lur/authentication/ \
     -H "Content-Type: application/json" \
     -d '{
           "mobile_number": "09123456789",
           "code": "108117114"
         }'
curl -X POST https://djangoiransms.chelseru.com/lur/send-message/ \
     -H "Content-Type: application/json" \
     -d '{
           "mobile_number": "09123456789",
           "message_text": "hello luristan."
         }'

User Table

This package automatically creates a User table in the Django admin with two fields:

  • mobile: Stores the user's mobile number.
  • user: A one-to-one relationship with Django's default User model.

OTP Code Table

This package automatically creates an OTP Code table in the Django admin with two fields:

  • mobile: Stores the user's mobile number.
  • code: Stores the OTP Code.

JWT Authentication

This package supports JWT authentication using the rest_framework_simplejwt package. The system is compatible with this authentication method for secure communication with the SMS gateway. Other authentication and login methods are currently under development.

Future Plans

  • Support for additional SMS providers.
  • Enhanced error handling.
  • Rate limiting and monitoring.
  • Contribution

Contributions are welcome! Please submit pull requests or report issues on the GitHub repository.

License

MIT License

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_iran_sms-1.1.0.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

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

django_iran_sms-1.1.0-py3-none-any.whl (11.6 kB view details)

Uploaded Python 3

File details

Details for the file django_iran_sms-1.1.0.tar.gz.

File metadata

  • Download URL: django_iran_sms-1.1.0.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.11.11

File hashes

Hashes for django_iran_sms-1.1.0.tar.gz
Algorithm Hash digest
SHA256 cc14ca058dda4caa4f193c6bfd4f1a550d08f1e851529bf7f8be78beb57ec53f
MD5 c986ddb133ab61f284b86a1ea842909d
BLAKE2b-256 1fc3c6cc42a7fb0b0753266232d4342cabede1d8cd32abb827f00af5e847a1ed

See more details on using hashes here.

File details

Details for the file django_iran_sms-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: django_iran_sms-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.11.11

File hashes

Hashes for django_iran_sms-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f53d7aaad551fd12de0abfb0e7edcd99b9948d24d71d3dbf2ce20b80d5453432
MD5 8a35766785fb0a6fef9f7cc659b1d26d
BLAKE2b-256 0747aaf8944470b0d2324b8ccd61bca26a96af81f8bc38383f0ffaff46abfb16

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