示例#1
0
from ppmessage.core.constant import REDIS_HOST
from ppmessage.core.constant import REDIS_PORT

from ppmessage.db.models import DeviceInfo
from ppmessage.db.models import ApiTokenData

import redis

class my_authenticate(authenticate):
    def __init__(self):
        self.redis = redis.Redis(REDIS_HOST, REDIS_PORT, db=1)
        return
    
    def verify_client_id(self, client_id):
        _key = DeviceInfo.__tablename__ + ".uuid." + client_id
        if not self.redis.exists(_key):
            return False
        return True
    
    def verify_user_password(self, user_id, password):
        _key = ApiTokenData.__tablename__ + ".api_token." + password
        if not self.redis.exists(_key):
            return False
        return True

if __name__ == "__main__":
    parse_command_line()
    mqtt_authenticate(my_authenticate)
    mqtt_server()

示例#2
0
def mqtt_message_main():
    parse_command_line()
    mqtt_authenticate(my_authenticate)
    mqtt_server()
    return
示例#3
0
from ppmessage.core.constant import REDIS_PORT

from ppmessage.db.models import DeviceInfo
from ppmessage.db.models import ApiTokenData

import redis


class my_authenticate(authenticate):
    def __init__(self):
        self.redis = redis.Redis(REDIS_HOST, REDIS_PORT, db=1)
        return

    def verify_client_id(self, client_id):
        _key = DeviceInfo.__tablename__ + ".uuid." + client_id
        if not self.redis.exists(_key):
            return False
        return True

    def verify_user_password(self, user_id, password):
        _key = ApiTokenData.__tablename__ + ".api_token." + password
        if not self.redis.exists(_key):
            return False
        return True


if __name__ == "__main__":
    parse_command_line()
    mqtt_authenticate(my_authenticate)
    mqtt_server()
示例#4
0
def mqtt_message_main():
    parse_command_line()
    mqtt_authenticate(my_authenticate)
    mqtt_server()
    return