From a3dab996cc3ba6c7157100a8f5ef71e2adebe0cd Mon Sep 17 00:00:00 2001 From: Apex Liu Date: Fri, 22 Dec 2017 23:17:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=EF=BC=9A=E6=9C=89=E4=BA=9BRD?= =?UTF-8?q?P=E8=BF=9C=E7=A8=8B=E8=BF=9E=E6=8E=A5=E5=9C=A8=E4=BC=9A?= =?UTF-8?q?=E8=AF=9D=E5=AE=A1=E8=AE=A1=E9=A1=B5=E9=9D=A2=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E4=B8=BA=E2=80=9C=E6=9C=AA=E7=9F=A5=E2=80=9D=E5=8D=8F=E8=AE=AE?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../teleport/webroot/app/controller/ops.py | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/server/www/teleport/webroot/app/controller/ops.py b/server/www/teleport/webroot/app/controller/ops.py index 7a4c298..8b4a661 100644 --- a/server/www/teleport/webroot/app/controller/ops.py +++ b/server/www/teleport/webroot/app/controller/ops.py @@ -99,6 +99,13 @@ class DoGetSessionIDHandler(TPBaseJsonHandler): # # WEB服务根据上述信息产生临时的远程连接ID,核心服务通过此远程连接ID来获取远程连接所需数据,生成会话ID。 + try: + _mode = int(args['mode']) + _protocol_type = int(args['protocol_type']) + _protocol_sub_type = int(args['protocol_sub_type']) + except: + return self.write_json(TPE_PARAM) + conn_info = dict() conn_info['_enc'] = 1 conn_info['host_id'] = 0 @@ -106,28 +113,21 @@ class DoGetSessionIDHandler(TPBaseJsonHandler): conn_info['user_id'] = self.get_current_user()['id'] conn_info['user_username'] = self.get_current_user()['username'] - protocol_sub_type = TP_PROTOCOL_TYPE_UNKNOWN - - if 'mode' not in args: - return self.write_json(TPE_PARAM) # mode = 0: test connect # mode = 1: user connect # mode = 2: admin connect - - if args['mode'] == 1: + if _mode == 1: if 'auth_id' not in args or 'protocol_sub_type' not in args: return self.write_json(TPE_PARAM) # 根据auth_id从数据库中取得此授权相关的用户、主机、账号三者详细信息 auth_id = args['auth_id'] - protocol_sub_type = int(args['protocol_sub_type']) ops_auth, err = ops.get_auth(auth_id) if err != TPE_OK: return self.write_json(err) acc_id = ops_auth['a_id'] host_id = ops_auth['h_id'] - user_id = ops_auth['u_id'] # TODO: 如果当前用户具有管理权限,则替换上述信息中的用户信息,否则检查当前用户是否是授权的用户 # TODO: 条件均满足的情况下,将主机、账号信息放入临时授权信息中(仅10秒有效期),并生产一个临时授权ID @@ -139,7 +139,7 @@ class DoGetSessionIDHandler(TPBaseJsonHandler): # log.v(acc_info) # elif len(args) == 2 and 'acc_id' in args and 'host_id' in args: - elif args['mode'] == 2: + elif _mode == 2: acc_id = args['acc_id'] host_id = args['host_id'] @@ -147,7 +147,7 @@ class DoGetSessionIDHandler(TPBaseJsonHandler): if err != TPE_OK: return self.write_json(err) - elif args['mode'] == 0: + elif _mode == 0: conn_info['_test'] = 1 try: acc_id = int(args['acc_id']) @@ -156,8 +156,8 @@ class DoGetSessionIDHandler(TPBaseJsonHandler): username = args['username'] password = args['password'] pri_key = args['pri_key'] - protocol_type = int(args['protocol_type']) - protocol_sub_type = int(args['protocol_sub_type']) + # protocol_type = int(args['protocol_type']) + # protocol_sub_type = int(args['protocol_sub_type']) protocol_port = int(args['protocol_port']) except: return self.write_json(TPE_PARAM) @@ -168,7 +168,7 @@ class DoGetSessionIDHandler(TPBaseJsonHandler): acc_info = dict() acc_info['auth_type'] = auth_type - acc_info['protocol_type'] = protocol_type + acc_info['protocol_type'] = _protocol_type acc_info['protocol_port'] = protocol_port acc_info['username'] = username @@ -216,7 +216,7 @@ class DoGetSessionIDHandler(TPBaseJsonHandler): conn_info['protocol_flag'] = 1 conn_info['protocol_type'] = acc_info['protocol_type'] - conn_info['protocol_sub_type'] = protocol_sub_type + conn_info['protocol_sub_type'] = _protocol_sub_type conn_info['auth_type'] = acc_info['auth_type'] if acc_info['auth_type'] == TP_AUTH_TYPE_PASSWORD: