Ejemplo n.º 1
0
    def post(self):
        try:
            platform = self.get_argument("platform", "")
            tmp_auth_params = self.get_argument("tmp_auth_params", "")
            auth_params = self.get_argument("auth_params", "")

            if not auth_utils.check_param_legal(platform):
                self.finish(json_encode({"mc": MsgCode['ParamError']}))
                return

            try:
                params_list = auth_params.split("|")
                account_id = params_list[0].split("_")[1]
                password = params_list[1].split("_")[1]  # 自己的账号系统

                params_list1 = tmp_auth_params.split("|")
                tmp_account_id = params_list1[0].split("_")[1]
                tmp_password = params_list1[1].split("_")[1]  # 自己的账号系统

                if not auth_utils.check_param_legal(
                        account_id, password, tmp_account_id, tmp_password):
                    raise

                if len(account_id) < 6 or len(account_id) > 18 or len(
                        password) < 6 or len(password) > 18:
                    raise
            except Exception, e:
                self.finish(
                    json_encode({"mc": MsgCode['AccountRegistParamsError']}))
                return

            complete_account_id = "%s_%s" % (platform, tmp_account_id)
            complete_account_id1 = "%s_%s" % (platform, account_id)
            if not Account.check_user_password(complete_account_id,
                                               tmp_password):
                self.finish(json_encode({"mc": MsgCode['AccountAuthFail']}))
                return

            # 只有临时账户可以绑定账号
            if Account.account_type(complete_account_id) != 0:
                self.finish(json_encode({"mc": MsgCode['AccountBindRepeat']}))
                return

            if Account.check_account_exist(complete_account_id1):
                self.finish(json_encode({"mc":
                                         MsgCode['AccountAlreadyExist']}))
                return

            result = Account.bind_account_auth_data(complete_account_id,
                                                    complete_account_id1,
                                                    password)
            if result:
                self.write(json_encode({"mc": MsgCode['AccountBindSucc']}))
            else:
                self.write(json_encode({"mc": MsgCode['AccountBindFail']}))
Ejemplo n.º 2
0
    def post(self):
        try:
            platform = self.get_argument("platform", "")
            tmp_auth_params = self.get_argument("tmp_auth_params", "")
            auth_params = self.get_argument("auth_params", "")

            if not auth_utils.check_param_legal(platform):
                self.finish(json_encode({"mc": MsgCode['ParamError']}))
                return

            try:
                params_list = auth_params.split("|")
                account_id = params_list[0].split("_")[1]
                password = params_list[1].split("_")[1] # 自己的账号系统

                params_list1 = tmp_auth_params.split("|")
                tmp_account_id = params_list1[0].split("_")[1]
                tmp_password = params_list1[1].split("_")[1] # 自己的账号系统

                if not auth_utils.check_param_legal(account_id, password, tmp_account_id, tmp_password):
                    raise

                if len(account_id) < 6 or len(account_id) > 18 or len(password) < 6 or len(password) > 18:
                    raise
            except Exception,e:
                self.finish(json_encode({"mc": MsgCode['AccountRegistParamsError']}))
                return

            complete_account_id = "%s_%s" % (platform, tmp_account_id)
            complete_account_id1 = "%s_%s" % (platform, account_id)
            if not Account.check_user_password(complete_account_id, tmp_password):
                self.finish(json_encode({"mc": MsgCode['AccountAuthFail']}))
                return

            # 只有临时账户可以绑定账号
            if Account.account_type(complete_account_id) != 0:
                self.finish(json_encode({"mc": MsgCode['AccountBindRepeat']}))
                return

            if Account.check_account_exist(complete_account_id1):
                self.finish(json_encode({"mc": MsgCode['AccountAlreadyExist']}))
                return

            result = Account.bind_account_auth_data(complete_account_id, complete_account_id1, password)
            if result:
                self.write(json_encode({"mc": MsgCode['AccountBindSucc']}))
            else:
                self.write(json_encode({"mc": MsgCode['AccountBindFail']}))
Ejemplo n.º 3
0
def auth_XTZJ(platform, params):
    """
    uid_100010|session_28BzIMEXzVUMqBac
    """
    try:
        params_list = params.split("|")

        uid = params_list[0].split("_")[1]
        session = params_list[1].split("_")[1]  # 开发阶段,自己的账号系统 session即password
    except:
        return False, MsgCode['AccountAuthParamError'], None

    if not auth_utils.check_param_legal(platform, uid, session):
        return False, MsgCode['AccountAuthParamError'], None

    # 检查玩家账号是否存在,不存在则注册,若存在则验证密码通过
    complete_account_id = "%s_%s" % (platform, uid)
    if not Account.check_account_exist(complete_account_id):
        return False, MsgCode['AccountAuthFail'], None
        # Account.register(complete_account_id, session, 1)

    if not Account.check_user_password(complete_account_id, session):
        return False, MsgCode['AccountPasswordError'], None

    return True, None, complete_account_id
Ejemplo n.º 4
0
def auth_EZ(platform, params):
    """
        易接
    """
    try:
        params_list = params.split("|")

        sdk = params_list[0].split("_")[1]
        app = params_list[1].split("_")[1]
        uin = params_list[2].split("_")[1]
        sess = params_list[3].split("_",1)[1]

        if not auth_utils.check_param_legal(platform):
            raise
    except:
        return False, MsgCode['AccountAuthParamError'], None

    headers = {"Content-Type": "application/x-www-form-urlencoded"}
    url = "http://sync.1sdk.cn/login/check.html"
    params = "?sdk=%s&app=%s&uin=%s&sess=%s" % (sdk, app, uin, sess)

    try:
        data = requests.get(url + params, timeout=5).json()
    except requests.exceptions.Timeout:
        return False, MsgCode['AccountAuthFail'], None

    account_id = uin if uin else sess
    if data == 0:
        return True, None, "%s_%s" % (platform, account_id)
    else:
        logging.error("【 PLATFORM AUTH 】auth %s failed, reason: code [%s], 返回0表示用户已登录,其他表示未登陆" % (platform, data))
        return False, MsgCode['AccountAuthFail'], None
Ejemplo n.º 5
0
def auth_XTZJ(platform, params):
    """
    uid_100010|session_28BzIMEXzVUMqBac
    """
    try:
        params_list = params.split("|")

        uid = params_list[0].split("_")[1]
        session = params_list[1].split("_")[1]  # 开发阶段,自己的账号系统 session即password
    except:
        return False, MsgCode['AccountAuthParamError'], None

    if not auth_utils.check_param_legal(platform, uid, session):
        return False, MsgCode['AccountAuthParamError'], None

    # 检查玩家账号是否存在,不存在则注册,若存在则验证密码通过
    complete_account_id = "%s_%s" % (platform, uid)
    if not Account.check_account_exist(complete_account_id):
        return False, MsgCode['AccountAuthFail'], None
        # Account.register(complete_account_id, session, 1)

    if not Account.check_user_password(complete_account_id, session):
        return False, MsgCode['AccountPasswordError'], None

    return True, None, complete_account_id
Ejemplo n.º 6
0
def auth_EZ(platform, params):
    """
        易接
    """
    try:
        params_list = params.split("|")

        sdk = params_list[0].split("_")[1]
        app = params_list[1].split("_")[1]
        uin = params_list[2].split("_")[1]
        sess = params_list[3].split("_", 1)[1]

        if not auth_utils.check_param_legal(platform):
            raise
    except:
        return False, MsgCode['AccountAuthParamError'], None

    headers = {"Content-Type": "application/x-www-form-urlencoded"}
    url = "http://sync.1sdk.cn/login/check.html"
    params = "?sdk=%s&app=%s&uin=%s&sess=%s" % (sdk, app, uin, sess)

    try:
        data = requests.get(url + params, timeout=5).json()
    except requests.exceptions.Timeout:
        return False, MsgCode['AccountAuthFail'], None

    account_id = uin if uin else sess
    if data == 0:
        return True, None, "%s_%s" % (platform, account_id)
    else:
        logging.error(
            "【 PLATFORM AUTH 】auth %s failed, reason: code [%s], 返回0表示用户已登录,其他表示未登陆"
            % (platform, data))
        return False, MsgCode['AccountAuthFail'], None
Ejemplo n.º 7
0
    def post(self):
        try:
            plat_sign = self.get_argument("platform", "")

            if not auth_utils.check_param_legal(plat_sign):
                self.finish(json_encode({"mc": MsgCode['ParamError']}))
                return

            platform = Platform.get_platform_info()
            platform_data = {}
            if not platform:
                self.write(json_encode({"mc": MsgCode['PlatformNotExist']}))
            else:
                platform_data["cdn_url"] = platform["cdn_url"]
                platform_data["remote_manifest_url"] = platform[
                    "remote_manifest_url"]

                if auth_utils.white_ip_check(self):
                    platform_data["resource_version"] = platform[
                        "test_resource_version"]
                else:
                    platform_data["resource_version"] = platform[
                        "prod_resource_version"]

                msg = {}
                msg["mc"] = 100
                msg["data"] = {}
                msg["data"]["platform"] = platform_data

                self.write(json_encode(msg))
        except Exception, e:
            self.interal_error_handle(e)
Ejemplo n.º 8
0
    def post(self):
        platform = self.get_argument("platform", "")
        auth_params = self.get_argument("auth_params", "")

        if not auth_utils.check_param_legal(platform):
            self.finish(json_encode({"mc": MsgCode['ParamError']}))
            return

        # 根据平台不同进行分发
        platform_config = Platform.get_plat_config(platform)
        if not platform_config:
            self.finish(json_encode({"mc": MsgCode['PlatformNotExist']}))
            return

        if not hasattr(platform_auth, platform_config["checker"]):
            self.finish(json_encode({"mc": MsgCode['AccountAuthParamError']}))
            return

        func = getattr(platform_auth, platform_config["checker"])
        success, code, complete_account_id = func(platform, auth_params)

        if not success:
            self.finish(json_encode({"mc": code}))
            return

        if platform_config["sign"] in NEED_OPEN_ID_PLATS:
            account = Account.get_account(complete_account_id)
            if not account.open_id:  # 0 - 未检测 1 - 已预约 2 - 没预约 3 - 已兑奖
                open_id = platform_auth.fetch_plat_openid(auth_params)
                account.update_open_id(open_id)

        account_id = complete_account_id.split("_")[1]
        msg = build_login_game_data(platform, account_id,
                                    auth_utils.white_ip_check(self))
        self.write(json_encode(msg))
Ejemplo n.º 9
0
    def post(self):
        try:
            platform = self.get_argument("platform", "")

            if not auth_utils.check_param_legal(platform):
                self.finish(json_encode({"mc": MsgCode['ParamError']}))
                return

            tmp_account_id = None
            while not tmp_account_id:
                tmp_account_id = gen_account_id()
                account = Account.get_account("%s_%s" %
                                              (platform, tmp_account_id))
                if not isinstance(account, Account):
                    tmp_account_id = None

            tmp_password = gen_password()

            complete_account_id = "%s_%s" % (platform, tmp_account_id)
            Account.register(complete_account_id, tmp_password, 0)

            msg = build_login_game_data(platform, tmp_account_id,
                                        auth_utils.white_ip_check(self))
            msg["data"]["password"] = tmp_password

            self.write(json_encode(msg))
        except Exception, e:
            self.interal_error_handle(e)
Ejemplo n.º 10
0
    def post(self):
        try:
            plat_sign = self.get_argument("platform", "")

            if not auth_utils.check_param_legal(plat_sign):
                self.finish(json_encode({"mc": MsgCode['ParamError']}))
                return

            platform = Platform.get_platform_info()
            platform_data = {}
            if not platform:
                self.write(json_encode({"mc": MsgCode['PlatformNotExist']}))
            else:
                platform_data["cdn_url"] = platform["cdn_url"]
                platform_data["remote_manifest_url"] = platform["remote_manifest_url"]

                if auth_utils.white_ip_check(self):
                    platform_data["resource_version"] = platform["test_resource_version"]
                else:
                    platform_data["resource_version"] = platform["prod_resource_version"]

                msg = {}
                msg["mc"] = 100
                msg["data"] = {}
                msg["data"]["platform"] = platform_data

                self.write(json_encode(msg))
        except Exception,e:
            self.interal_error_handle(e)
Ejemplo n.º 11
0
    def post(self):
        platform = self.get_argument("platform", "")
        auth_params = self.get_argument("auth_params", "")

        if not auth_utils.check_param_legal(platform):
            self.finish(json_encode({"mc": MsgCode['ParamError']}))
            return

        # 根据平台不同进行分发
        platform_config = Platform.get_plat_config(platform)
        if not platform_config:
            self.finish(json_encode({"mc": MsgCode['PlatformNotExist']}))
            return

        if not hasattr(platform_auth, platform_config["checker"]):
            self.finish(json_encode({"mc": MsgCode['AccountAuthParamError']}))
            return

        func = getattr(platform_auth, platform_config["checker"])
        success, code, complete_account_id = func(platform, auth_params)

        if not success:
            self.finish(json_encode({"mc": code}))
            return

        if platform_config["sign"] in NEED_OPEN_ID_PLATS:
            account = Account.get_account(complete_account_id)
            if not account.open_id: # 0 - 未检测 1 - 已预约 2 - 没预约 3 - 已兑奖
                open_id = platform_auth.fetch_plat_openid(auth_params)
                account.update_open_id(open_id)

        account_id = complete_account_id.split("_")[1]
        msg = build_login_game_data(platform, account_id, auth_utils.white_ip_check(self))
        self.write(json_encode(msg))
Ejemplo n.º 12
0
    def post(self):
        try:
            platform = self.get_argument("platform", "")

            if not auth_utils.check_param_legal(platform):
                self.finish(json_encode({"mc": MsgCode['ParamError']}))
                return

            tmp_account_id = None
            while not tmp_account_id:
                tmp_account_id = gen_account_id()
                account = Account.get_account("%s_%s" % (platform, tmp_account_id))
                if not isinstance(account, Account):
                    tmp_account_id = None

            tmp_password = gen_password()

            complete_account_id = "%s_%s" % (platform, tmp_account_id)
            Account.register(complete_account_id, tmp_password, 0)

            msg = build_login_game_data(platform, tmp_account_id, auth_utils.white_ip_check(self))
            msg["data"]["password"] = tmp_password

            self.write(json_encode(msg))
        except Exception,e:
            self.interal_error_handle(e)
Ejemplo n.º 13
0
    def post(self):
        try:
            platform = self.get_argument("platform", "")
            auth_params = self.get_argument("auth_params", "")

            if not auth_utils.check_param_legal(platform):
                self.finish(json_encode({"mc": MsgCode['ParamError']}))
                return

            try:
                params_list = auth_params.split("|")

                account_id = params_list[0].split("_")[1]
                password = params_list[1].split("_")[1]  # 自己的账号系统

                if not auth_utils.check_param_legal(account_id, password):
                    raise

                if len(account_id) < 6 or len(account_id) > 18 or len(
                        password) < 6 or len(password) > 18:
                    raise
            except:
                self.finish(
                    json_encode({"mc": MsgCode['AccountRegistParamsError']}))
                return

            complete_account_id = "%s_%s" % (platform, account_id)

            if Account.check_account_exist(complete_account_id):
                self.finish(json_encode({"mc":
                                         MsgCode['AccountAlreadyExist']}))
                return

            Account.register(complete_account_id, password)

            msg = build_login_game_data(platform, account_id,
                                        auth_utils.white_ip_check(self))
            self.write(json_encode(msg))
        except Exception, e:
            self.interal_error_handle(e)
Ejemplo n.º 14
0
def auth_WHWJ(platform, params):
    """
        万好万家
    """
    try:
        params_list = params.split("|")

        userid = params_list[0].split("_")[1]
        ticket = params_list[1].split("_")[1]
        seqnum = params_list[2].split("_")[1]
        prtchid = params_list[3].split("_")[1]

        if not auth_utils.check_param_legal(platform):
            raise
    except:
        return False, MsgCode['AccountAuthParamError'], None

    app_cfg = settings.PLATFORM_APP_ID_MAPPING.get("WHWJ", {})
    if not app_cfg:
        return False, MsgCode['PlatformNotExist'], None, sid

    sign_str = "cpid=%s&prtchid=%s&seqnum=%s&ticket=%s&userid=%s" % (
        app_cfg["AppId"], prtchid, seqnum, ticket, userid)
    signature = utils.md5(sign_str + app_cfg["AppKey"])

    headers = {"Content-Type": "application/x-www-form-urlencoded"}
    url = "http://service.wangamedia.com/sdkcore/user/service/checkonlineuser.html"
    param = {
        "cpid": app_cfg["AppId"],
        "userid": userid,
        "ticket": ticket,
        "seqnum": seqnum,
        "prtchid": prtchid,
        "sign": signature,
    }

    try:
        data = requests.post(url, data=param, headers=headers,
                             timeout=5).json()
    except requests.exceptions.Timeout:
        return False, MsgCode['AccountAuthFail'], None

    if data["success"]:
        return True, None, "%s_%s" % (platform, userid)
    else:
        reason = data.get("errorCode", "no error msg.")
        logging.error("【 PLATFORM AUTH 】auth %s failed, reason: %s" %
                      (platform, reason))
        return False, MsgCode['AccountAuthFail'], None
Ejemplo n.º 15
0
    def post(self):
        try:
            platform = self.get_argument("platform", "")
            auth_params = self.get_argument("auth_params", "")

            if not auth_utils.check_param_legal(platform):
                self.finish(json_encode({"mc": MsgCode['ParamError']}))
                return

            try:
                params_list = auth_params.split("|")

                account_id = params_list[0].split("_")[1]
                password = params_list[1].split("_")[1] # 自己的账号系统

                if not auth_utils.check_param_legal(account_id, password):
                    raise

                if len(account_id) < 6 or len(account_id) > 18 or len(password) < 6 or len(password) > 18:
                    raise
            except:
                self.finish(json_encode({"mc": MsgCode['AccountRegistParamsError']}))
                return

            complete_account_id = "%s_%s" % (platform, account_id)

            if Account.check_account_exist(complete_account_id):
                self.finish(json_encode({"mc": MsgCode['AccountAlreadyExist']}))
                return

            Account.register(complete_account_id, password)

            msg = build_login_game_data(platform, account_id, auth_utils.white_ip_check(self))
            self.write(json_encode(msg))
        except Exception,e:
            self.interal_error_handle(e)
Ejemplo n.º 16
0
def auth_WHWJ(platform, params):
    """
        万好万家
    """
    try:
        params_list = params.split("|")

        userid = params_list[0].split("_")[1]
        ticket = params_list[1].split("_")[1]
        seqnum = params_list[2].split("_")[1]
        prtchid = params_list[3].split("_")[1]

        if not auth_utils.check_param_legal(platform):
            raise
    except:
        return False, MsgCode['AccountAuthParamError'], None

    app_cfg = settings.PLATFORM_APP_ID_MAPPING.get("WHWJ", {})
    if not app_cfg:
        return False, MsgCode['PlatformNotExist'], None, sid

    sign_str = "cpid=%s&prtchid=%s&seqnum=%s&ticket=%s&userid=%s" % (app_cfg["AppId"], prtchid, seqnum, ticket, userid)
    signature = utils.md5(sign_str+app_cfg["AppKey"])

    headers = {"Content-Type": "application/x-www-form-urlencoded"}
    url = "http://service.wangamedia.com/sdkcore/user/service/checkonlineuser.html"
    param = {
        "cpid": app_cfg["AppId"],
        "userid": userid,
        "ticket": ticket,
        "seqnum": seqnum,
        "prtchid": prtchid,
        "sign": signature,
    }

    try:
        data = requests.post(url, data=param, headers=headers, timeout=5).json()
    except requests.exceptions.Timeout:
        return False, MsgCode['AccountAuthFail'], None

    if data["success"]:
        return True, None, "%s_%s" % (platform, userid)
    else:
        reason = data.get("errorCode", "no error msg.")
        logging.error("【 PLATFORM AUTH 】auth %s failed, reason: %s" % (platform, reason))
        return False, MsgCode['AccountAuthFail'], None