فعالسازی احراز هویت دوعاملی در سیموتل

فعالسازی احراز هویت دومرحله‌ای در سیموتل (Two-Step Authentication)

برای فعال‌سازی احراز هویت دومرحله‌ای در سیموتل لازم است یک سرویس فایل پایتون ایجاد کنیم تا پیامک حاوی کد ورود را برای کاربران ارسال کند. این فایل نقش واسط بین سیموتل و سرویس پیامکی را داشته و با استفاده از API سامانه پیامکی، پیامک ارسال می‌کند.

نکته مهم:
قالب کلی کد برای تمام سرویس‌های پیامکی یکسان است و فقط تابع send_message بر اساس API سرویس پیامکی شما باید تغییر کند پارامترهای بدنه و آدرس URL

نمونه فایل سرویس پیامکی (مناسب فراپیامک)


# Define module parameters for the SMS service

module_param = {“username”: “my_sername”, “password”: “my_pass”, “src”: “my_src_number”}

 

import sys

import base64

import requests

 

def send_message(phone_number, message):

    """

    Send an SMS message via a specified service provider (in this case, ippanel).

   

    IMPORTANT:

    If you are using a different SMS service provider, you will need to modify this function

    to meet the specific requirements and API specifications of your chosen provider.

   

    Args:

    - phone_number (str): The phone number to send the SMS to.

    - message (str): The content of the SMS message.

   

    Returns:

    None

    """

   

    \# URL for the ippanel SMS API

    url = ‘https://rest.payamak….’

    \# Construct the payload with provided parameters and arguments

    data = {

        “username”: module_param\[“username”\],

        “password”: module_param\[“password”\],

        “to”: phone_number,

        “from”: module_param\[“src”\],

        “text”: message,

        “isFlash”: False

    }

   

    \# Send the request to the ippanel service

    response = requests.post(url, json=data)

 

    \# Check the response and print appropriate messages

    if response.status_code == 200:

        print(response)

    else:

        print(“whatever you want”)

 

\# Check the number of arguments provided

\# If there are 3 arguments, decode the phone number and message from base64

if len(sys.argv) == 3:

    phone_number = base64.b64decode(sys.argv\[1\]).decode(“utf-8”)

    message = base64.b64decode(sys.argv\[2\]).decode(“utf-8”)

    send_message(phone_number, message)

    print(“sending message %s to %s” % (message, phone_number))

   

\# If there are 4 arguments, check if the last argument is “test"

elif len(sys.argv) == 4:

    \# this part is just for test your sms service command sample: python3.8 simotel_sms_service_template.py “0915xxxxxxx” “my_message” test

    phone_number = sys.argv\[1\]

    message = sys.argv\[2\]

    if sys.argv\[3\] == “test":

        send_message(phone_number, message)

        print(“sending message %s to %s” % (message, phone_number))

    else:

        print(“invalid command”)

else:

    \# If the number of arguments doesn’t match expected values, print an error message

    print(sys.argv)

    print(“unable to get message”)

 

مراحل اتصال فایل به سیموتل

نکته قابل توجه لازم است نسخه سیموتل 6.8.35 به بعد باشد

· افزودن سرویس فایل پیامکی

مسیر زیر را باز کنید:

maintenance → settings → sms service → add service

فایل .py را آپلود کنید.
پس از آپلود، در همان صفحه در بخش sms service فایل را به عنوان سرویس فعال انتخاب کنید.

· مقداردهی پارامترهای ارسال پیامک

لازم است پارامترهای username، password و src که سه پارامتر اصلی ارسال پیامک هستند برای استفاده سرویس فایل مقداردهی شوند مطابق شکل زیر:

پس از ذخیره هردو صفحه در این بخش نیاز است برای یوزرهای سیموتل شماره موبایل تعریف شود.

· ثبت شماره موبایل برای کاربران سیموتل

به بخش maintenance → account مراجعه و برای تمام یوزرها در بخش تعیین شده شماره موبایل جهت فعالسازی احراز دوعاملی تعریف می شود. این شماره موبایل همان شماره یکتایی می باشد که پیامک کد مرحله دوم را دریافت میکند و حتما لازم است تمام یوزرها شماره موبایل یکسان وارد کنند

تصویر

· فعال‌سازی احراز هویت دو مرحله‌ای

از مسیرgeneral setting maintenance → settings → بخش login type پارامتر two step انتخاب و صفحه save شود.

· تست و ورود

اکنون یکبار از سیموتل Logout کرده و دوباره وارد شوید. پس از وارد کردن نام کاربری و رمز عبور، یک صفحه جدید برای ورود کد پیامکی نمایش داده می‌شود. با وارد کردن کد، ورود با موفقیت انجام می‌شود.

1 پسندیده