mirror of https://github.com/jumpserver/jumpserver
Merge branch 'dev' of https://git.coding.net/jumpserver/jumpserver into dev
commit
742e56fc5f
|
@ -211,8 +211,8 @@ class Tty(object):
|
||||||
获取需要登陆的主机的信息和映射用户的账号密码
|
获取需要登陆的主机的信息和映射用户的账号密码
|
||||||
"""
|
"""
|
||||||
asset_info = get_asset_info(self.asset)
|
asset_info = get_asset_info(self.asset)
|
||||||
|
role_key = get_role_key(self.user, self.role)
|
||||||
role_pass = CRYPTOR.decrypt(self.role.password)
|
role_pass = CRYPTOR.decrypt(self.role.password)
|
||||||
role_key = os.path.join(self.role.key_path, 'id_rsa')
|
|
||||||
self.connect_info = {'user': self.user, 'asset': self.asset, 'ip': asset_info.get('ip'),
|
self.connect_info = {'user': self.user, 'asset': self.asset, 'ip': asset_info.get('ip'),
|
||||||
'port': int(asset_info.get('port')), 'role_name': self.role.name,
|
'port': int(asset_info.get('port')), 'role_name': self.role.name,
|
||||||
'role_pass': role_pass, 'role_key': role_key}
|
'role_pass': role_pass, 'role_key': role_key}
|
||||||
|
@ -234,7 +234,7 @@ class Tty(object):
|
||||||
ssh.load_system_host_keys()
|
ssh.load_system_host_keys()
|
||||||
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||||
try:
|
try:
|
||||||
role_key = get_role_key(self.user, self.role)
|
role_key = connect_info.get('role_key')
|
||||||
if role_key and os.path.isfile(role_key):
|
if role_key and os.path.isfile(role_key):
|
||||||
try:
|
try:
|
||||||
ssh.connect(connect_info.get('ip'),
|
ssh.connect(connect_info.get('ip'),
|
||||||
|
@ -245,6 +245,7 @@ class Tty(object):
|
||||||
self.ssh = ssh
|
self.ssh = ssh
|
||||||
return ssh
|
return ssh
|
||||||
except (paramiko.ssh_exception.AuthenticationException, paramiko.ssh_exception.SSHException):
|
except (paramiko.ssh_exception.AuthenticationException, paramiko.ssh_exception.SSHException):
|
||||||
|
logger.warning('Use ssh key %s Failed.' % role_key)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
ssh.connect(connect_info.get('ip'),
|
ssh.connect(connect_info.get('ip'),
|
||||||
|
|
|
@ -51,6 +51,7 @@ def log_list(request, offset):
|
||||||
|
|
||||||
web_monitor_uri = 'ws://%s/monitor' % WEB_SOCKET_HOST
|
web_monitor_uri = 'ws://%s/monitor' % WEB_SOCKET_HOST
|
||||||
web_kill_uri = 'http://%s/kill' % WEB_SOCKET_HOST
|
web_kill_uri = 'http://%s/kill' % WEB_SOCKET_HOST
|
||||||
|
session_id = request.session.session_key
|
||||||
return render_to_response('jlog/log_%s.html' % offset, locals(), context_instance=RequestContext(request))
|
return render_to_response('jlog/log_%s.html' % offset, locals(), context_instance=RequestContext(request))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,10 @@ def get_asset_info(asset):
|
||||||
if default:
|
if default:
|
||||||
info['port'] = default.default_port
|
info['port'] = default.default_port
|
||||||
info['username'] = default.default_user
|
info['username'] = default.default_user
|
||||||
|
try:
|
||||||
info['password'] = CRYPTOR.decrypt(default.default_password)
|
info['password'] = CRYPTOR.decrypt(default.default_password)
|
||||||
|
except ServerError:
|
||||||
|
pass
|
||||||
info['ssh_key'] = default.default_pri_key_path
|
info['ssh_key'] = default.default_pri_key_path
|
||||||
else:
|
else:
|
||||||
info['port'] = asset.port
|
info['port'] = asset.port
|
||||||
|
|
|
@ -42,7 +42,7 @@ def require_auth(role='user'):
|
||||||
if request.get_cookie('sessionid'):
|
if request.get_cookie('sessionid'):
|
||||||
session_key = request.get_cookie('sessionid')
|
session_key = request.get_cookie('sessionid')
|
||||||
else:
|
else:
|
||||||
session_key = request.get_secure_cookie('sessionid')
|
session_key = request.get_argument('sessionid', '')
|
||||||
|
|
||||||
logger.debug('Websocket: session_key: %s' % session_key)
|
logger.debug('Websocket: session_key: %s' % session_key)
|
||||||
if session_key:
|
if session_key:
|
||||||
|
@ -62,7 +62,10 @@ def require_auth(role='user'):
|
||||||
return func(request, *args, **kwargs)
|
return func(request, *args, **kwargs)
|
||||||
else:
|
else:
|
||||||
logger.debug('Websocket: session expired: %s' % session_key)
|
logger.debug('Websocket: session expired: %s' % session_key)
|
||||||
|
try:
|
||||||
request.close()
|
request.close()
|
||||||
|
except AttributeError:
|
||||||
|
pass
|
||||||
logger.warning('Websocket: Request auth failed.')
|
logger.warning('Websocket: Request auth failed.')
|
||||||
# asset_id = int(request.get_argument('id', 9999))
|
# asset_id = int(request.get_argument('id', 9999))
|
||||||
# print asset_id
|
# print asset_id
|
||||||
|
@ -99,14 +102,7 @@ class EventHandler(ProcessEvent):
|
||||||
def __init__(self, client=None):
|
def __init__(self, client=None):
|
||||||
self.client = client
|
self.client = client
|
||||||
|
|
||||||
def process_IN_CREATE(self, event):
|
|
||||||
print "Create file:%s." % os.path.join(event.path, event.name)
|
|
||||||
|
|
||||||
def process_IN_DELETE(self, event):
|
|
||||||
print "Delete file:%s." % os.path.join(event.path, event.name)
|
|
||||||
|
|
||||||
def process_IN_MODIFY(self, event):
|
def process_IN_MODIFY(self, event):
|
||||||
print "Modify file:%s." % os.path.join(event.path, event.name)
|
|
||||||
self.client.write_message(f.read())
|
self.client.write_message(f.read())
|
||||||
|
|
||||||
|
|
||||||
|
@ -222,12 +218,11 @@ class WebTerminalKillHandler(tornado.web.RequestHandler):
|
||||||
ws_id = self.get_argument('id')
|
ws_id = self.get_argument('id')
|
||||||
Log.objects.filter(id=ws_id).update(is_finished=True)
|
Log.objects.filter(id=ws_id).update(is_finished=True)
|
||||||
for ws in WebTerminalHandler.clients:
|
for ws in WebTerminalHandler.clients:
|
||||||
print ws.id
|
|
||||||
if ws.id == int(ws_id):
|
if ws.id == int(ws_id):
|
||||||
print "killed"
|
logger.debug("Kill log id %s" % ws_id)
|
||||||
ws.log.save()
|
ws.log.save()
|
||||||
ws.close()
|
ws.close()
|
||||||
print len(WebTerminalHandler.clients)
|
logger.debug('Websocket: web terminal client num: %s' % len(WebTerminalHandler.clients))
|
||||||
|
|
||||||
|
|
||||||
class WebTerminalHandler(tornado.websocket.WebSocketHandler):
|
class WebTerminalHandler(tornado.websocket.WebSocketHandler):
|
||||||
|
|
|
@ -50,7 +50,7 @@
|
||||||
<div class="col-lg-12">
|
<div class="col-lg-12">
|
||||||
<div class="ibox float-e-margins">
|
<div class="ibox float-e-margins">
|
||||||
<div id="ibox-content" class="ibox-title">
|
<div id="ibox-content" class="ibox-title">
|
||||||
<h5> 用户日志详细信息列表 <input type="button" id="test_connect" class="btn btn-primary" value="测试连接 web terminal" /> </h5>
|
<h5> 用户日志详细信息列表 </h5>
|
||||||
<div class="ibox-tools">
|
<div class="ibox-tools">
|
||||||
<a class="collapse-link">
|
<a class="collapse-link">
|
||||||
<i class="fa fa-chevron-up"></i>
|
<i class="fa fa-chevron-up"></i>
|
||||||
|
@ -186,29 +186,17 @@
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
{# function log_search(){#}
|
|
||||||
{# $.ajax({#}
|
|
||||||
{# type: "GET",#}
|
|
||||||
{# url: "/jlog/search/?env=online",#}
|
|
||||||
{# data: $("#search_form").serialize(),#}
|
|
||||||
{# success: function (data) {#}
|
|
||||||
{# $(".tab-content").html(data);#}
|
|
||||||
{# }#}
|
|
||||||
{# });#}
|
|
||||||
{# }#}
|
|
||||||
|
|
||||||
|
|
||||||
function cut(num, host){
|
function cut(num, host){
|
||||||
console.log(host);
|
console.log(host);
|
||||||
if (host=='Web'){
|
if (host=='Web'){
|
||||||
var g_url = '{{ web_kill_uri }}' + '?id=' + num;
|
var g_url = '{{ web_kill_uri }}' + '?id=' + num;
|
||||||
} else {
|
} else {
|
||||||
g_url = "/jlog/log_kill/?id=" + num;
|
var g_url = "/jlog/log_kill/?id=" + num;
|
||||||
}
|
}
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "GET",
|
type: "GET",
|
||||||
url: g_url,
|
url: g_url+"&sessionid={{ session_id }}",
|
||||||
success: window.open("/jlog/log_list/online/", "_self")
|
success: window.open("/jlog/log_list/online/", "_self")
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue