diff --git a/server/tp_core/core/ts_http_rpc.cpp b/server/tp_core/core/ts_http_rpc.cpp index ac747de..e954e74 100644 --- a/server/tp_core/core/ts_http_rpc.cpp +++ b/server/tp_core/core/ts_http_rpc.cpp @@ -345,6 +345,7 @@ void TsHttpRpc::_rpc_func_request_session(const Json::Value& json_param, ex_astr return; } + // TODO: 解密操作应该延迟到使用密码/密钥时才进行,尽量减少明文出现的时间。 if(is_enc) { if (user_auth.length() > 0) diff --git a/server/www/teleport/app/eom_app/controller/host.py b/server/www/teleport/app/eom_app/controller/host.py index 0a9d015..8b4294d 100644 --- a/server/www/teleport/app/eom_app/controller/host.py +++ b/server/www/teleport/app/eom_app/controller/host.py @@ -890,6 +890,11 @@ class AdminGetSessionId(SwxAuthJsonHandler): return host_auth_id = args['host_auth_id'] + # host_auth_id 瀵瑰簲鐨勬槸 ts_auth_info 琛ㄤ腑鐨勬煇涓潯鐩紝鍚湁鍏蜂綋鐨勮璇佹暟鎹紝鍥犱负绠$悊鍛樻棤闇鎺堟潈鍗冲彲璁块棶鎵鏈夎繙绋嬩富鏈猴紝鍥犳 + # 鐩存帴缁欏嚭 host_auth_id锛屼笖account鐩存帴鎸囨槑鏄痑dmin锛孴ODO: 搴旇鏄綋鍓嶇櫥褰曠敤鎴风殑鐢ㄦ埛鍚嶏紝杩欐牱鑳藉鑷傚簲 + + # TODO: 浠庢暟鎹簱涓煡璇㈠搴旂殑璁よ瘉鏁版嵁鍚庯紝缂撳瓨鍒板唴瀛樹腑骞跺搴斾竴涓礋鏁扮殑auth_id锛屽彂缁檆ore鏈嶅姟锛屼粠鑰屽彇寰椾竴涓猻ession-id. + values = host.get_host_auth_info(host_auth_id) if values is None: self.write_json(-1) @@ -908,11 +913,18 @@ class AdminGetSessionId(SwxAuthJsonHandler): ts_server_rpc_port = cfg.core.rpc.port url = 'http://{}:{}/request_session'.format(ts_server_rpc_ip, ts_server_rpc_port) + req = {'method': 'request_session', 'param': {'authid': auth_id}} # values['auth_id'] = auth_id - return_data = post_http(url, values) + # return_data = post_http(url, values) + # if return_data is None: + # return self.write_json(-1) + # return_data = json.loads(return_data) + + _yr = async_post_http(url, req) + return_data = yield _yr if return_data is None: return self.write_json(-1) - return_data = json.loads(return_data) + if 'code' not in return_data: return self.write_json(-1) _code = return_data['code'] diff --git a/server/www/teleport/app/eom_app/controller/rpc.py b/server/www/teleport/app/eom_app/controller/rpc.py index 93a4505..ddbe697 100644 --- a/server/www/teleport/app/eom_app/controller/rpc.py +++ b/server/www/teleport/app/eom_app/controller/rpc.py @@ -62,7 +62,7 @@ class RpcHandler(SwxJsonHandler): def _get_auth_info(self, param): # todo: 濡傛灉鏄〉闈笂杩涜杩炴帴娴嬭瘯锛堝鍔犳垨淇敼涓绘満鍜岀敤鎴锋椂锛夛紝淇℃伅骞朵笉鍐欏叆鏁版嵁搴擄紝鑰屾槸鍦ㄥ唴瀛樹腑瀛樺湪锛屼紶閫掔粰core鏈嶅姟鐨 - # 搴旇鏄殢鏈哄瓧绗︿覆鍋歛uthid锛屽悕绉颁负 tauthid銆傛湰鎺ュ彛搴旇鏀寔鍖哄垎杩欎袱绉嶈璇両D銆 + # 搴旇鏄礋鏁板舰寮忕殑authid銆傛湰鎺ュ彛搴旇鏀寔鍖哄垎杩欎袱绉嶈璇両D銆 if 'authid' not in param: self.write_json(-1, message='invalid request.') diff --git a/server/www/teleport/app/eom_app/module/host.py b/server/www/teleport/app/eom_app/module/host.py index 0869302..27fdf66 100644 --- a/server/www/teleport/app/eom_app/module/host.py +++ b/server/www/teleport/app/eom_app/module/host.py @@ -785,24 +785,9 @@ def get_auth_info(auth_id): ','.join(['d.{}'.format(i) for i in field_d]), auth_id) - # print(str_sql) - - """ - "SELECT a.auth_id as auth_id, a.account_name as account_name, \ - // a.host_auth_id as host_auth_id, a.host_id as host_id,host_lock, \ - // b.host_sys_type as host_sys_type, host_ip, host_port, protocol, \ - // c.user_pswd as user_pswd, c.cert_id as cert_id, c.user_name as user_name, \ - // c.encrypt as encrypt, c.auth_mode as auth_mode,c.user_param as user_param, \ - // d.account_lock as account_lock FROM ts_auth as a \ - // LEFT JOIN ts_host_info as b ON a.host_id = b.host_id \ - // LEFT JOIN ts_auth_info as c ON a.host_auth_id = c.id \ - // LEFT JOIN ts_account as d ON a.account_name = d.account_name \ - // WHERE a.auth_id=%d", auth_id - """ - db_ret = sql_exec.ExecProcQuery(str_sql) - if db_ret is None or len(db_ret) > 1: + if db_ret is None or len(db_ret) != 1: return None db_item = DbItem() @@ -826,8 +811,6 @@ def get_auth_info(auth_id): ret['auth_mode'] = db_item.c_auth_mode ret['user_name'] = db_item.c_user_name ret['user_param'] = db_item.c_user_param - # ret['user_pswd'] = db_item.c_user_pswd - # ret['cert_id'] = db_item.c_cert_id if db_item.c_auth_mode == 1: ret['user_auth'] = db_item.c_user_pswd @@ -836,7 +819,6 @@ def get_auth_info(auth_id): str_sql = 'SELECT cert_pri FROM ts_cert WHERE cert_id={}'.format(cert_id) db_ret = sql_exec.ExecProcQuery(str_sql) - print(db_ret) if db_ret is None or len(db_ret) > 1: return None ret['user_auth'] = db_ret[0][0]