mirror of https://github.com/jumpserver/jumpserver
fixed merge...
commit
4d844548c2
|
@ -46,12 +46,12 @@ def scriptToJSON(scriptf, timing=None):
|
|||
ret = []
|
||||
|
||||
with closing(scriptf):
|
||||
print "# %s #" % scriptf.readline() # ignore first header line from script file
|
||||
scriptf.readline() # ignore first header line from script file
|
||||
offset = 0
|
||||
for t in timing:
|
||||
dt = scriptf.read(t[1])
|
||||
data = escapeString(dt)
|
||||
print ('###### (%s, %s)' % (t[1], repr(data)))
|
||||
# print ('###### (%s, %s)' % (t[1], repr(data)))
|
||||
offset += t[0]
|
||||
ret.append((data, offset))
|
||||
return dumps(ret)
|
||||
|
|
|
@ -457,6 +457,7 @@ class Tasks(Command):
|
|||
|
||||
return result
|
||||
|
||||
|
||||
class CustomAggregateStats(callbacks.AggregateStats):
|
||||
"""
|
||||
Holds stats about per-host activity during playbook runs.
|
||||
|
|
|
@ -22,6 +22,7 @@ class SysUser(models.Model):
|
|||
class PermSudo(models.Model):
|
||||
name = models.CharField(max_length=100, unique=True)
|
||||
date_added = models.DateTimeField(auto_now=True)
|
||||
runas = models.CharField(max_length=200, default='root')
|
||||
commands = models.TextField()
|
||||
comment = models.CharField(max_length=100, null=True, blank=True, default='')
|
||||
|
||||
|
|
|
@ -96,23 +96,21 @@ def gen_sudo(role_custom, role_name, role_chosen):
|
|||
return sudo_file_path
|
||||
|
||||
|
||||
def get_add_sudo_script(sudo_chosen_aliase, sudo_chosen_obj):
|
||||
def get_add_sudo_script(role_chosen_aliase, sudo_alias):
|
||||
"""
|
||||
get the sudo file
|
||||
:param kwargs:
|
||||
:return:
|
||||
"""
|
||||
sudo_j2 = get_template('jperm/role_sudo.j2')
|
||||
sudo_content = sudo_j2.render(Context({"sudo_chosen_aliase": sudo_chosen_aliase,
|
||||
"sudo_chosen_obj": sudo_chosen_obj}))
|
||||
sudo_content = sudo_j2.render(Context({"role_chosen_aliase": role_chosen_aliase,
|
||||
"sudo_alias": sudo_alias}))
|
||||
sudo_file = NamedTemporaryFile(delete=False)
|
||||
sudo_file.write(sudo_content)
|
||||
sudo_file.close()
|
||||
print(sudo_file.name)
|
||||
return sudo_file.name
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print gen_keys()
|
||||
|
||||
|
|
222
jperm/views.py
222
jperm/views.py
|
@ -69,7 +69,6 @@ def perm_rule_add(request):
|
|||
# 渲染数据
|
||||
header_title, path1, path2 = "授权规则", "规则管理", "添加规则"
|
||||
|
||||
if request.method == 'GET':
|
||||
# 渲染数据, 获取所有 用户,用户组,资产,资产组,用户角色, 用于添加授权规则
|
||||
users = User.objects.all()
|
||||
user_groups = UserGroup.objects.all()
|
||||
|
@ -77,9 +76,7 @@ def perm_rule_add(request):
|
|||
asset_groups = AssetGroup.objects.all()
|
||||
roles = PermRole.objects.all()
|
||||
|
||||
return my_render('jperm/perm_rule_add.html', locals(), request)
|
||||
|
||||
elif request.method == 'POST':
|
||||
if request.method == 'POST':
|
||||
# 获取用户选择的 用户,用户组,资产,资产组,用户角色
|
||||
users_select = request.POST.getlist('user', [])
|
||||
user_groups_select = request.POST.getlist('usergroup', [])
|
||||
|
@ -88,28 +85,32 @@ def perm_rule_add(request):
|
|||
roles_select = request.POST.getlist('role', [])
|
||||
rule_name = request.POST.get('rulename')
|
||||
rule_comment = request.POST.get('rule_comment')
|
||||
rule_ssh_key = request.POST.get("use_publicKey")
|
||||
|
||||
try:
|
||||
rule = get_object(PermRule, name=rule_name)
|
||||
if rule:
|
||||
raise ServerError(u'授权规则 %s 已存在' % rule_name)
|
||||
|
||||
# 获取需要授权的主机列表
|
||||
assets_obj = [Asset.objects.get(ip=asset) for asset in assets_select]
|
||||
asset_groups_obj = [AssetGroup.objects.get(name=group) for group in asset_groups_select]
|
||||
group_assets_obj = [asset for asset in [group.asset_set.all() for group in asset_groups_obj]]
|
||||
calc_assets = set(group_assets_obj) | set(assets_obj)
|
||||
assets_obj = [Asset.objects.get(id=asset_id) for asset_id in assets_select]
|
||||
asset_groups_obj = [AssetGroup.objects.get(id=group_id) for group_id in asset_groups_select]
|
||||
# group_assets_obj = [asset for asset in [group.asset_set.all() for group in asset_groups_obj]]
|
||||
# calc_assets = set(group_assets_obj) | set(assets_obj)
|
||||
|
||||
# 获取需要授权的用户列表
|
||||
users_obj = [User.objects.get(name=user) for user in users_select]
|
||||
user_groups_obj = [UserGroup.objects.get(name=group) for group in user_groups_select]
|
||||
group_users_obj = [user for user in [group.user_set.all() for group in user_groups_obj]]
|
||||
calc_users = set(group_users_obj) | set(users_obj)
|
||||
users_obj = [User.objects.get(id=user_id) for user_id in users_select]
|
||||
user_groups_obj = [UserGroup.objects.get(id=group_id) for group_id in user_groups_select]
|
||||
# group_users_obj = [user for user in [group.user_set.all() for group in user_groups_obj]]
|
||||
# calc_users = set(group_users_obj) | set(users_obj)
|
||||
|
||||
# 获取授予的角色列表
|
||||
roles_obj = [PermRole.objects.get(name=role) for role in roles_select]
|
||||
roles_obj = [PermRole.objects.get(id=role_id) for role_id in roles_select]
|
||||
|
||||
# 仅授权成功的,写回数据库(授权规则,用户,用户组,资产,资产组,用户角色)
|
||||
rule = PermRule(name=rule_name, comment=rule_comment)
|
||||
rule.save()
|
||||
rule.user = users_obj
|
||||
rule.usergroup = user_groups_obj
|
||||
rule.user_group = user_groups_obj
|
||||
rule.asset = assets_obj
|
||||
rule.asset_group = asset_groups_obj
|
||||
rule.role = roles_obj
|
||||
|
@ -117,16 +118,10 @@ def perm_rule_add(request):
|
|||
|
||||
msg = u"添加授权规则:%s" % rule.name
|
||||
# 渲染数据
|
||||
header_title, path1, path2 = "授权规则", "规则管理", "查看规则"
|
||||
rules_list = PermRule.objects.all()
|
||||
|
||||
# TODO: 搜索和分页
|
||||
keyword = request.GET.get('search', '')
|
||||
if keyword:
|
||||
rules_list = rules_list.filter(Q(name=keyword))
|
||||
rules_list, p, rules, page_range, current_page, show_first, show_end = pages(rules_list, request)
|
||||
|
||||
return my_render('jperm/perm_rule_list.html', locals(), request)
|
||||
return HttpResponseRedirect('/jperm/rule/')
|
||||
except ServerError, e:
|
||||
error = e
|
||||
return my_render('jperm/perm_rule_add.html', locals(), request)
|
||||
|
||||
|
||||
@require_role('admin')
|
||||
|
@ -155,7 +150,6 @@ def perm_rule_edit(request):
|
|||
assets = Asset.objects.all()
|
||||
asset_groups = AssetGroup.objects.all()
|
||||
roles = PermRole.objects.all()
|
||||
|
||||
return my_render('jperm/perm_rule_edit.html', locals(), request)
|
||||
|
||||
elif request.method == 'POST' and rule_id:
|
||||
|
@ -168,24 +162,23 @@ def perm_rule_edit(request):
|
|||
asset_groups_select = request.POST.getlist('assetgroup', [])
|
||||
roles_select = request.POST.getlist('role', [])
|
||||
|
||||
# 获取需要授权的主机列表
|
||||
assets_obj = [Asset.objects.get(ip=asset) for asset in assets_select]
|
||||
asset_groups_obj = [AssetGroup.objects.get(name=group) for group in asset_groups_select]
|
||||
group_assets_obj = [asset for asset in [group.asset_set.all() for group in asset_groups_obj]]
|
||||
calc_assets = set(group_assets_obj) | set(assets_obj)
|
||||
assets_obj = [Asset.objects.get(id=asset_id) for asset_id in assets_select]
|
||||
asset_groups_obj = [AssetGroup.objects.get(id=group_id) for group_id in asset_groups_select]
|
||||
# group_assets_obj = [asset for asset in [group.asset_set.all() for group in asset_groups_obj]]
|
||||
# calc_assets = set(group_assets_obj) | set(assets_obj)
|
||||
|
||||
# 获取需要授权的用户列表
|
||||
users_obj = [User.objects.get(name=user) for user in users_select]
|
||||
user_groups_obj = [UserGroup.objects.get(name=group) for group in user_groups_select]
|
||||
group_users_obj = [user for user in [group.user_set.all() for group in user_groups_obj]]
|
||||
calc_users = set(group_users_obj) | set(users_obj)
|
||||
users_obj = [User.objects.get(id=user_id) for user_id in users_select]
|
||||
user_groups_obj = [UserGroup.objects.get(id=group_id) for group_id in user_groups_select]
|
||||
# group_users_obj = [user for user in [group.user_set.all() for group in user_groups_obj]]
|
||||
# calc_users = set(group_users_obj) | set(users_obj)
|
||||
|
||||
# 获取授予的角色列表
|
||||
roles_obj = [PermRole.objects.get(name=role) for role in roles_select]
|
||||
roles_obj = [PermRole.objects.get(id=role_id) for role_id in roles_select]
|
||||
|
||||
# 仅授权成功的,写回数据库(授权规则,用户,用户组,资产,资产组,用户角色)
|
||||
rule.user = users_obj
|
||||
rule.usergroup = user_groups_obj
|
||||
rule.user_group = user_groups_obj
|
||||
rule.asset = assets_obj
|
||||
rule.asset_group = asset_groups_obj
|
||||
rule.role = roles_obj
|
||||
|
@ -194,17 +187,8 @@ def perm_rule_edit(request):
|
|||
rule.save()
|
||||
|
||||
msg = u"更新授权规则:%s" % rule.name
|
||||
# 渲染数据
|
||||
header_title, path1, path2 = "授权规则", "规则管理", "查看规则"
|
||||
rules_list = PermRule.objects.all()
|
||||
|
||||
# TODO: 搜索和分页
|
||||
keyword = request.GET.get('search', '')
|
||||
if keyword:
|
||||
rules_list = rules_list.filter(Q(name=keyword))
|
||||
rules_list, p, rules, page_range, current_page, show_first, show_end = pages(rules_list, request)
|
||||
|
||||
return my_render('jperm/perm_rule_list.html', locals(), request)
|
||||
return HttpResponseRedirect('/jperm/rule/')
|
||||
|
||||
|
||||
@require_role('admin')
|
||||
|
@ -254,37 +238,37 @@ def perm_role_add(request):
|
|||
"""
|
||||
# 渲染数据
|
||||
header_title, path1, path2 = "系统角色", "角色管理", "添加角色"
|
||||
|
||||
if request.method == "GET":
|
||||
default_password = get_rand_pass()
|
||||
sudos = PermSudo.objects.all()
|
||||
return my_render('jperm/perm_role_add.html', locals(), request)
|
||||
|
||||
elif request.method == "POST":
|
||||
# 获取参数: name, comment, sudo
|
||||
name = request.POST.get("role_name")
|
||||
comment = request.POST.get("role_comment")
|
||||
password = request.POST.get("role_password")
|
||||
sudos_name = request.POST.getlist("sudo_name")
|
||||
sudos_obj = [PermSudo.objects.get(name=sudo_name) for sudo_name in sudos_name]
|
||||
if request.method == "POST":
|
||||
# 获取参数: name, comment
|
||||
name = request.POST.get("role_name", "")
|
||||
comment = request.POST.get("role_comment", "")
|
||||
password = request.POST.get("role_password", "")
|
||||
key_content = request.POST.get("role_key", "")
|
||||
sudo_ids = request.POST.getlist('sudo_name')
|
||||
|
||||
try:
|
||||
if get_object(PermRole, name=name):
|
||||
raise ServerError('已经存在该用户 %s' % name)
|
||||
if password:
|
||||
encrypt_pass = CRYPTOR.encrypt(password)
|
||||
else:
|
||||
encrypt_pass = CRYPTOR.encrypt(CRYPTOR.gen_rand_pass(20))
|
||||
# 生成随机密码,生成秘钥对
|
||||
|
||||
sudos_obj = [get_object(PermSudo, id=sudo_id) for sudo_id in sudo_ids]
|
||||
if key_content:
|
||||
key_path = gen_keys(key=key_content)
|
||||
else:
|
||||
key_path = gen_keys()
|
||||
logger.debug('generate role key: %s' % key_path)
|
||||
role = PermRole(name=name, comment=comment, password=encrypt_pass, key_path=key_path)
|
||||
role.save()
|
||||
role.sudo = sudos_obj
|
||||
role.save()
|
||||
|
||||
msg = u"添加角色: %s" % name
|
||||
# 渲染 刷新数据
|
||||
header_title, path1, path2 = "系统角色", "角色管理", "查看角色"
|
||||
roles_list = PermRole.objects.all()
|
||||
# TODO: 搜索和分页
|
||||
keyword = request.GET.get('search', '')
|
||||
if keyword:
|
||||
roles_list = roles_list.filter(Q(name=keyword))
|
||||
|
||||
return HttpResponseRedirect('/jperm/role/')
|
||||
except ServerError, e:
|
||||
error = e
|
||||
|
||||
return my_render('jperm/perm_role_add.html', locals(), request)
|
||||
|
||||
|
@ -352,6 +336,7 @@ def perm_role_edit(request):
|
|||
role_id = request.GET.get("id")
|
||||
role = PermRole.objects.get(id=role_id)
|
||||
role_pass = CRYPTOR.decrypt(role.password)
|
||||
sudo_all = PermSudo.objects.all()
|
||||
role_sudos = role.sudo.all()
|
||||
sudo_all = PermSudo.objects.all()
|
||||
if request.method == "GET":
|
||||
|
@ -363,7 +348,7 @@ def perm_role_edit(request):
|
|||
role_password = request.POST.get("role_password")
|
||||
role_comment = request.POST.get("role_comment")
|
||||
role_sudo_names = request.POST.getlist("sudo_name")
|
||||
role_sudos = [PermSudo.objects.get(name=sudo_name) for sudo_name in role_sudo_names]
|
||||
role_sudos = [PermSudo.objects.get(id=sudo_id) for sudo_id in role_sudo_names]
|
||||
key_content = request.POST.get("role_key", "")
|
||||
|
||||
try:
|
||||
|
@ -382,11 +367,9 @@ def perm_role_edit(request):
|
|||
logger.debug('Recreate role key: %s' % role.key_path)
|
||||
# 写入数据库
|
||||
role.name = role_name
|
||||
role.password = encrypt_role_pass
|
||||
role.comment = role_comment
|
||||
role.sudo = role_sudos
|
||||
|
||||
|
||||
role.save()
|
||||
msg = u"更新系统角色: %s" % role.name
|
||||
return HttpResponseRedirect('/jperm/role/')
|
||||
|
@ -404,23 +387,19 @@ def perm_role_push(request):
|
|||
# 渲染数据
|
||||
header_title, path1, path2 = "系统角色", "角色管理", "角色推送"
|
||||
|
||||
if request.method == "GET":
|
||||
# 渲染数据
|
||||
roles = PermRole.objects.all()
|
||||
assets = Asset.objects.all()
|
||||
asset_groups = AssetGroup.objects.all()
|
||||
|
||||
return my_render('jperm/perm_role_push.html', locals(), request)
|
||||
|
||||
if request.method == "POST":
|
||||
# 获取推荐角色的名称列表
|
||||
role_names = request.POST.getlist("roles")
|
||||
role_ids = request.POST.getlist("roles")
|
||||
|
||||
# 计算出需要推送的资产列表
|
||||
asset_ips = request.POST.getlist("assets")
|
||||
asset_group_names = request.POST.getlist("asset_groups")
|
||||
assets_obj = [Asset.objects.get(ip=asset_ip) for asset_ip in asset_ips]
|
||||
asset_groups_obj = [AssetGroup.objects.get(name=asset_group_name) for asset_group_name in asset_group_names]
|
||||
asset_ids = request.POST.getlist("assets")
|
||||
asset_group_ids = request.POST.getlist("asset_groups")
|
||||
assets_obj = [Asset.objects.get(id=asset_id) for asset_id in asset_ids]
|
||||
asset_groups_obj = [AssetGroup.objects.get(id=asset_group_id) for asset_group_id in asset_group_ids]
|
||||
group_assets_obj = []
|
||||
for asset_group in asset_groups_obj:
|
||||
group_assets_obj.extend(asset_group.asset_set.all())
|
||||
|
@ -442,10 +421,9 @@ def perm_role_push(request):
|
|||
# "username": username,
|
||||
# "password": password})
|
||||
push_resource = gen_resource(calc_assets)
|
||||
print push_resource
|
||||
|
||||
# 获取角色的推送方式,以及推送需要的信息
|
||||
roles_obj = [PermRole.objects.get(name=role_name) for role_name in role_names]
|
||||
roles_obj = [PermRole.objects.get(id=role_id) for role_id in role_ids]
|
||||
role_pass = {}
|
||||
role_key = {}
|
||||
for role in roles_obj:
|
||||
|
@ -476,31 +454,28 @@ def perm_role_push(request):
|
|||
ret_failed["step2-2"] = "failed"
|
||||
|
||||
# 3. 推送sudo配置文件
|
||||
sudo_chosen_aliase = {}
|
||||
sudo_alias = []
|
||||
role_chosen_aliase = {} # {'dev': [sudo1, sudo2], 'sa': [sudo2, sudo3]}
|
||||
sudo_alias = set() # set(sudo1, sudo2, sudo3)
|
||||
for role in roles_obj:
|
||||
role_alias = [sudo.name for sudo in role.sudo.all()]
|
||||
sudo_alias.extend(role_alias)
|
||||
sudo_chosen_aliase[role.name] = ','.join(role_alias)
|
||||
sudo_chosen_obj = [PermSudo.objects.get(name=sudo_name) for sudo_name in set(sudo_alias)]
|
||||
|
||||
add_sudo_script = get_add_sudo_script(sudo_chosen_aliase, sudo_chosen_obj)
|
||||
sudos = set([sudo for sudo in role.sudo.all()])
|
||||
sudo_alias.update(sudos)
|
||||
role_chosen_aliase[role.name] = sudos
|
||||
add_sudo_script = get_add_sudo_script(role_chosen_aliase, sudo_alias)
|
||||
ret_sudo = task.push_sudo_file(add_sudo_script)
|
||||
|
||||
if ret_sudo["step1"] != "ok" or ret_sudo["step2"] != "ok":
|
||||
ret_failed["step3"] = "failed"
|
||||
# os.remove(add_sudo_script)
|
||||
os.remove(add_sudo_script)
|
||||
|
||||
print ret
|
||||
|
||||
|
||||
# 结果汇总统计
|
||||
if ret_failed:
|
||||
# 推送失败
|
||||
error = u"推送失败, 原因: %s 失败" % ','.join(ret_failed.keys())
|
||||
else:
|
||||
# 推送成功 回写push表
|
||||
msg = u"推送系统角色: %s" % ','.join(role_names)
|
||||
msg = u"推送系统角色: %s" % ','.join(role_chosen_aliase.keys())
|
||||
push = PermPush(is_public_key=bool(key_push), is_password=bool(password_push))
|
||||
push.save()
|
||||
push.asset_group = asset_groups_obj
|
||||
|
@ -508,16 +483,7 @@ def perm_role_push(request):
|
|||
push.role = roles_obj
|
||||
push.save()
|
||||
|
||||
# 渲染 刷新数据
|
||||
header_title, path1, path2 = "系统角色", "角色管理", "查看角色"
|
||||
roles_list = PermRole.objects.all()
|
||||
# TODO: 搜索和分页
|
||||
keyword = request.GET.get('search', '')
|
||||
if keyword:
|
||||
roles_list = roles_list.filter(Q(name=keyword))
|
||||
|
||||
roles_list, p, roles, page_range, current_page, show_first, show_end = pages(roles_list, request)
|
||||
return my_render('jperm/perm_role_list.html', locals(), request)
|
||||
return my_render('jperm/perm_role_push.html', locals(), request)
|
||||
|
||||
|
||||
@require_role('admin')
|
||||
|
@ -553,34 +519,22 @@ def perm_sudo_add(request):
|
|||
# 渲染数据
|
||||
header_title, path1, path2 = "Sudo命令", "别名管理", "添加别名"
|
||||
|
||||
if request.method == "GET":
|
||||
return my_render('jperm/perm_sudo_add.html', locals(), request)
|
||||
|
||||
elif request.method == "POST":
|
||||
if request.method == "POST":
|
||||
# 获取参数: name, comment
|
||||
name = request.POST.get("sudo_name")
|
||||
comment = request.POST.get("sudo_comment")
|
||||
commands = request.POST.get("sudo_commands")
|
||||
name = request.POST.get("sudo_name").strip()
|
||||
runas = request.POST.get('sudo_runas', 'root').strip()
|
||||
comment = request.POST.get("sudo_comment").strip()
|
||||
commands = request.POST.get("sudo_commands").strip()
|
||||
|
||||
sudo = PermSudo(name=name.strip(), comment=comment, commands=commands.strip())
|
||||
if get_object(PermSudo, name=name):
|
||||
error = 'Sudo别名 %s已经存在' % name
|
||||
else:
|
||||
sudo = PermSudo(name=name.strip(), runas=runas, comment=comment, commands=commands.strip())
|
||||
sudo.save()
|
||||
|
||||
msg = u"添加Sudo命令别名: %s" % name
|
||||
# 渲染数据
|
||||
header_title, path1, path2 = "Sudo命令", "别名管理", "查看别名"
|
||||
# 获取所有sudo 命令别名
|
||||
sudos_list = PermSudo.objects.all()
|
||||
|
||||
# TODO: 搜索和分页
|
||||
keyword = request.GET.get('search', '')
|
||||
if keyword:
|
||||
roles_list = sudos_list.filter(Q(name=keyword))
|
||||
|
||||
sudos_list, p, sudos, page_range, current_page, show_first, show_end = pages(sudos_list, request)
|
||||
|
||||
return my_render('jperm/perm_sudo_list.html', locals(), request)
|
||||
else:
|
||||
return HttpResponse(u"不支持该操作")
|
||||
return my_render('jperm/perm_sudo_add.html', locals(), request)
|
||||
|
||||
|
||||
@require_role('admin')
|
||||
|
@ -595,29 +549,21 @@ def perm_sudo_edit(request):
|
|||
|
||||
sudo_id = request.GET.get("id")
|
||||
sudo = PermSudo.objects.get(id=sudo_id)
|
||||
if request.method == "GET":
|
||||
return my_render('jperm/perm_sudo_edit.html', locals(), request)
|
||||
|
||||
if request.method == "POST":
|
||||
name = request.POST.get("sudo_name")
|
||||
commands = request.POST.get("sudo_commands")
|
||||
runas = request.POST.get('sudo_runas', 'root')
|
||||
comment = request.POST.get("sudo_comment")
|
||||
sudo.name = name.strip()
|
||||
sudo.commands = commands.strip()
|
||||
sudo.runas = runas.strip()
|
||||
sudo.comment = comment
|
||||
sudo.save()
|
||||
|
||||
msg = u"更新命令别名: %s" % name
|
||||
# 渲染数据
|
||||
header_title, path1, path2 = "Sudo命令", "别名管理", "查看别名"
|
||||
# 获取所有sudo 命令别名
|
||||
sudos_list = PermSudo.objects.all()
|
||||
# TODO: 搜索和分页
|
||||
keyword = request.GET.get('search', '')
|
||||
if keyword:
|
||||
sudos_list = sudos_list.filter(Q(name=keyword))
|
||||
sudos_list, p, sudos, page_range, current_page, show_first, show_end = pages(sudos_list, request)
|
||||
return my_render('jperm/perm_sudo_list.html', locals(), request)
|
||||
|
||||
return my_render('jperm/perm_sudo_edit.html', locals(), request)
|
||||
|
||||
|
||||
@require_role('admin')
|
||||
|
|
|
@ -250,6 +250,7 @@ class WebTerminalHandler(tornado.websocket.WebSocketHandler):
|
|||
if asset:
|
||||
roles = user_have_perm(self.user, asset)
|
||||
logger.debug(roles)
|
||||
logger.debug('rolename: %s' % role_name)
|
||||
login_role = ''
|
||||
for role in roles:
|
||||
if role.name == role_name:
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
<div class="col-sm-7" style="padding-left: 0px">
|
||||
<label>
|
||||
<select name="idc" class="form-control m-b" onchange="change_info()">
|
||||
<option value="">IDC机房</option>
|
||||
<option value="">机房</option>
|
||||
{% for idc in idc_all %}
|
||||
{% ifequal idc.name idc_name %}
|
||||
<option value="{{idc.name}}" selected> {{ idc.name }}</option>
|
||||
|
@ -57,7 +57,7 @@
|
|||
|
||||
<label>
|
||||
<select name="asset_type" class="form-control m-b" onchange="change_info()">
|
||||
<option value="">所有类型</option>
|
||||
<option value="">资产类型</option>
|
||||
{% for type in asset_types %}
|
||||
{% ifequal type.0|int2str asset_type %}
|
||||
<option value="{{ type.0 }}" selected> {{ type.1 }}</option>
|
||||
|
@ -70,7 +70,7 @@
|
|||
|
||||
<label>
|
||||
<select name="status" class="form-control m-b" onchange="change_info()">
|
||||
<option value="">所有状态</option>
|
||||
<option value="">资产状态</option>
|
||||
{% for s in asset_status %}
|
||||
{% ifequal s.0|int2str status %}
|
||||
<option value="{{ s.0 }}" selected> {{ s.1 }}</option>
|
||||
|
@ -215,7 +215,7 @@
|
|||
maxmin: true,
|
||||
shade: false,
|
||||
area: ['628px', '452px'],
|
||||
content: new_url
|
||||
content: new_url+data
|
||||
});
|
||||
//window.open(new_url + data, '', 'location=no, resizeable=no, height=410, width=625, top=89px, left=99px,toolbar=no,menubar=no,scrollbars=auto,status=no');
|
||||
} else if (dataArray.length == '1' && data == 'error'){
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
</div>
|
||||
<div class="ibox-content">
|
||||
<div class="">
|
||||
<a target="_blank" href="/jasset/idc_add" class="btn btn-sm btn-primary "> 添加IDC </a>
|
||||
<a target="_blank" href="/jasset/idc_add" class="btn btn-sm btn-primary "> 添加机房 </a>
|
||||
<input type="button" id="del_check" class="btn btn-danger btn-sm" name="del_button" value="删除所选"/>
|
||||
<form id="search_form" method="get" action="" class="pull-right mail-search">
|
||||
<div class="input-group">
|
||||
|
|
|
@ -97,7 +97,7 @@
|
|||
<td class="text-center"> {{ post.login_type }} </td>
|
||||
<td class="text-center"><a href="/jlog/history/?id={{ post.id }}" class="log_command"> 统计 </a></td>
|
||||
<td class="text-center"><a class="monitor" file_path="{{ post.log_path }}"> 监控 </a></td>
|
||||
<td class="text-center"><input type="button" id="cut" class="btn btn-danger btn-xs" name="cut" value="阻断" onclick='cut("{{ post.pid }}", "{{ post.remote_ip }}")' /></td>
|
||||
<td class="text-center"><input type="button" id="cut" class="btn btn-danger btn-xs" name="cut" value="阻断" onclick='cut("{{ post.pid }}", "{{ post.login_type }}")' /></td>
|
||||
<td class="text-center" id="start_time"> {{ post.start_time|date:"Y-m-d H:i:s" }} </td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
@ -189,9 +189,9 @@
|
|||
});
|
||||
});
|
||||
|
||||
function cut(num, host){
|
||||
console.log(host);
|
||||
if (host=='Web'){
|
||||
function cut(num, login_type){
|
||||
console.log(login_type);
|
||||
if (login_type=='web'){
|
||||
var g_url = '{{ web_kill_uri }}' + '?id=' + num;
|
||||
} else {
|
||||
var g_url = "/jlog/log_kill/?id=" + num;
|
||||
|
|
|
@ -56,11 +56,11 @@
|
|||
</div>
|
||||
<div class="hr-line-dashed"></div>
|
||||
<div class="form-group">
|
||||
<label for="sudo" class="col-sm-2 control-label">角色Sudo命令<span class="red-fonts">*</span></label>
|
||||
<label for="sudo" class="col-sm-2 control-label">角色Sudo命令</label>
|
||||
<div class="col-sm-8" id="sudo_name">
|
||||
<select name="sudo_name" data-placeholder="请选择Sudo别名" class="chosen-select form-control m-b" multiple tabindex="2">
|
||||
{% for sudo in sudos %}
|
||||
<option >{{ sudo.name }}</option>
|
||||
<option value="{{ sudo.id }}">{{ sudo.name }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
|
@ -93,9 +93,9 @@ $('#roleForm').validator({
|
|||
theme: "yellow_right_effect",
|
||||
rules: {
|
||||
check_name: [/^\w{2,20}$/, '大小写字母数字和下划线,2-20位'],
|
||||
either: function(){
|
||||
return $('#role_password').val() == ''
|
||||
}
|
||||
{# either: function(){#}
|
||||
{# return $('#role_password').val() == ''#}
|
||||
{# }#}
|
||||
},
|
||||
|
||||
fields: {
|
||||
|
@ -105,12 +105,12 @@ $('#roleForm').validator({
|
|||
ok: "",
|
||||
msg: {required: "角色名称必填"}
|
||||
},
|
||||
"role_key": {
|
||||
rule: "required(either)",
|
||||
tip: "输入密钥",
|
||||
ok: "",
|
||||
msg: {required: "密码和密钥必填一个!"}
|
||||
}
|
||||
{# "role_key": {#}
|
||||
{# rule: "required(either)",#}
|
||||
{# tip: "输入密钥",#}
|
||||
{# ok: "",#}
|
||||
{# msg: {required: "密码和密钥必填一个!"}#}
|
||||
{# }#}
|
||||
},
|
||||
valid: function(form) {
|
||||
form.submit();
|
||||
|
|
|
@ -61,7 +61,7 @@
|
|||
<div class="col-sm-8">
|
||||
<select name="sudo_name" data-placeholder="请选择Sudo别名" class="chosen-select form-control m-b" multiple tabindex="2">
|
||||
{% for sudo in sudo_all %}
|
||||
<option value="{{ sudo.name }}" {% if sudo in role_sudos %} selected {% endif %}>{{ sudo.name }}</option>
|
||||
<option value="{{ sudo.id }}" {% if sudo in role_sudos %} selected {% endif %}>{{ sudo.name }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
<div class="ibox-content">
|
||||
<div class="">
|
||||
<a href="/jperm/role/perm_role_add/" class="btn btn-sm btn-primary "> 添加角色 </a>
|
||||
<a href="/jperm/role/perm_role_push/" class="btn btn-sm btn-primary "> 推送角色 </a>
|
||||
<a href="/jperm/role/perm_role_push/" class="btn btn-sm btn-danger "> 推送角色 </a>
|
||||
<form id="search_form" method="get" action="" class="pull-right mail-search">
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control input-sm" id="search_input" name="search" placeholder="Search">
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="ibox-content">
|
||||
<form method="post" id="userForm" class="form-horizontal" action="">
|
||||
<form method="post" id="pushForm" class="form-horizontal" action="">
|
||||
{% if error %}
|
||||
<div class="alert alert-warning text-center">{{ error }}</div>
|
||||
{% endif %}
|
||||
|
@ -34,22 +34,22 @@
|
|||
<div class="alert alert-success text-center">{{ msg }}</div>
|
||||
{% endif %}
|
||||
<div class="form-group">
|
||||
<label for="asset" class="col-sm-2 control-label">资产<span class="red-fonts">*</span></label>
|
||||
<label for="asset" class="col-sm-2 control-label">资产</label>
|
||||
<div class="col-sm-8">
|
||||
<select name="assets" data-placeholder="请选择资产" class="chosen-select form-control m-b" multiple tabindex="2">
|
||||
<select name="assets" id="assets" data-placeholder="请选择资产" class="chosen-select form-control m-b" multiple tabindex="2">
|
||||
{% for asset in assets %}
|
||||
<option value="{{ asset.ip }}">{{ asset.ip }}</option>
|
||||
<option value="{{ asset.id }}">{{ asset.ip }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="hr-line-dashed"></div>
|
||||
<div class="form-group">
|
||||
<label for="assetgroup" class="col-sm-2 control-label">资产组<span class="red-fonts">*</span></label>
|
||||
<label for="assetgroup" class="col-sm-2 control-label">资产组</label>
|
||||
<div class="col-sm-8">
|
||||
<select name="asset_groups" data-placeholder="请选择资产组" class="chosen-select form-control m-b" multiple tabindex="2">
|
||||
{% for asset_group in asset_groups %}
|
||||
<option value="{{ asset_group.name }}">{{ asset_group.name }}</option>
|
||||
<option value="{{ asset_group.id }}">{{ asset_group.name }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
|
@ -60,7 +60,7 @@
|
|||
<div class="col-sm-8">
|
||||
<select name="roles" data-placeholder="请选择角色" class="chosen-select form-control m-b" multiple tabindex="2">
|
||||
{% for role in roles %}
|
||||
<option value="{{ role.name }}">{{ role.name }}</option>
|
||||
<option value="{{ role.id }}">{{ role.name }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
|
@ -68,11 +68,11 @@
|
|||
<div class="hr-line-dashed"></div>
|
||||
<div class="row">
|
||||
<div class="form-group">
|
||||
<label for="j_group" class="col-sm-2 control-label">使用秘钥</label>
|
||||
<label for="j_group" class="col-sm-2 control-label">使用密钥</label>
|
||||
<div class="col-sm-1">
|
||||
<div class="radio i-checks">
|
||||
<label>
|
||||
<input type="checkbox" value="1" id="use_publicKey" name="use_publicKey">
|
||||
<input type="checkbox" value="1" id="use_publicKey" name="use_publicKey" checked>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -111,37 +111,33 @@
|
|||
{% endblock %}
|
||||
{% block self_footer_js %}
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
$("input.role").click(function(){
|
||||
if($("input.role[value=GA]").is( ":checked" )){
|
||||
$("#admin_groups").css("display", 'none');
|
||||
$('#pushForm').validator({
|
||||
timely: 2,
|
||||
theme: "yellow_right_effect",
|
||||
rules: {
|
||||
check_name: [/^\w{2,20}$/, '大小写字母数字和下划线,2-20位'],
|
||||
check_asset: function(){
|
||||
return $('#assets').val() == null
|
||||
}
|
||||
else {
|
||||
|
||||
$("#admin_groups").css("display", 'block');
|
||||
},
|
||||
fields: {
|
||||
"asset_groups": {
|
||||
rule: "required(check_asset)",
|
||||
tip: "输入资产组",
|
||||
msg: {required: "资产和资产组必选一个!"}
|
||||
},
|
||||
"roles": {
|
||||
rule: "required",
|
||||
tip: "请选择角色",
|
||||
msg: {required: "必须选择角色"}
|
||||
}
|
||||
},
|
||||
valid: function(form) {
|
||||
form.submit();
|
||||
}
|
||||
});
|
||||
|
||||
$('#use_password').click(function(){
|
||||
if ($(this).is(':checked')){
|
||||
$('#admin_account_password').css('display', 'block')
|
||||
}
|
||||
else {
|
||||
|
||||
$('#admin_account_password').css('display', 'none')
|
||||
}
|
||||
});
|
||||
|
||||
$('#use_publicKey').click(function(){
|
||||
if ($(this).is(':checked')){
|
||||
|
||||
$('#admin_account_publicKey').css('display', 'block')
|
||||
}
|
||||
else {
|
||||
$('#admin_account_publicKey').css('display', 'none')
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var config = {
|
||||
'.chosen-select' : {},
|
||||
|
|
|
@ -44,9 +44,8 @@
|
|||
<label for="user" class="col-sm-2 control-label">用户</label>
|
||||
<div class="col-sm-8">
|
||||
<select name="user" id="user" data-placeholder="用户名" class="chosen-select form-control m-b" multiple tabindex="2">
|
||||
|
||||
{% for user in users %}
|
||||
<option>{{ user.name }}</option>
|
||||
<option value="{{ user.id }}">{{ user.name }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<span class="help-block m-b-none">用户和用户组必选一个</span>
|
||||
|
@ -58,7 +57,7 @@
|
|||
<select name="usergroup" id="usergroup" data-placeholder="请选择用户组" class="chosen-select form-control m-b" multiple tabindex="2">
|
||||
|
||||
{% for user_group in user_groups %}
|
||||
<option value="{{ user_group.name }}">{{ user_group.name }}</option>
|
||||
<option value="{{ user_group.id }}">{{ user_group.name }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
|
@ -69,7 +68,7 @@
|
|||
<div class="col-sm-8">
|
||||
<select name="asset" id="asset" data-placeholder="请选择资产" class="chosen-select form-control m-b" multiple tabindex="2">
|
||||
{% for asset in assets %}
|
||||
<option value="{{ asset.ip }}">{{ asset.ip }}</option>
|
||||
<option value="{{ asset.id }}">{{ asset.ip }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<span class="help-block m-b-none">资产和资产组必选一个</span>
|
||||
|
@ -80,7 +79,7 @@
|
|||
<div class="col-sm-8">
|
||||
<select name="assetgroup" data-placeholder="请选择资产组" class="chosen-select form-control m-b" multiple tabindex="2">
|
||||
{% for asset_group in asset_groups %}
|
||||
<option value="{{ asset_group.name }}">{{ asset_group.name }}</option>
|
||||
<option value="{{ asset_group.id }}">{{ asset_group.name }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
|
@ -91,7 +90,7 @@
|
|||
<div class="col-sm-8" id="role_name">
|
||||
<select name="role" data-placeholder="请选择角色" class="chosen-select form-control m-b" multiple tabindex="2">
|
||||
{% for role in roles %}
|
||||
<option value="{{ role.name }}">{{ role.name }}</option>
|
||||
<option value="{{ role.id }}">{{ role.name }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
<div class="col-sm-8">
|
||||
<select name="user" data-placeholder="用户名" class="chosen-select form-control m-b" multiple tabindex="2">
|
||||
{% for user in users %}
|
||||
<option value="{{ user.name }}" {% if user in users_select %} selected {% endif %}>{{ user.name }}</option>
|
||||
<option value="{{ user.id }}" {% if user in users_select %} selected {% endif %}>{{ user.name }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
|
@ -56,7 +56,7 @@
|
|||
<div class="col-sm-8">
|
||||
<select name="usergroup" data-placeholder="请选择用户组" class="chosen-select form-control m-b" multiple tabindex="2">
|
||||
{% for user_group in user_groups %}
|
||||
<option value="{{ user_group.name }}"{% if user_group in users_groups_select %} selected {% endif %}>{{ user_group.name }}</option>
|
||||
<option value="{{ user_group.id }}"{% if user_group in user_groups_select %} selected {% endif %}>{{ user_group.name }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
|
@ -67,7 +67,7 @@
|
|||
<div class="col-sm-8">
|
||||
<select name="asset" data-placeholder="请选择资产" class="chosen-select form-control m-b" multiple tabindex="2">
|
||||
{% for asset in assets %}
|
||||
<option value="{{ asset.ip }}"{% if asset in assets_select %} selected {% endif %}>{{ asset.ip }}</option>
|
||||
<option value="{{ asset.id }}"{% if asset in assets_select %} selected {% endif %}>{{ asset.ip }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
|
@ -78,7 +78,7 @@
|
|||
<div class="col-sm-8">
|
||||
<select name="assetgroup" data-placeholder="请选择资产组" class="chosen-select form-control m-b" multiple tabindex="2">
|
||||
{% for asset_group in asset_groups %}
|
||||
<option value="{{ asset_group.name }}"{% if asset_group in asset_groups_select %} selected {% endif %}>{{ asset_group.name }}</option>
|
||||
<option value="{{ asset_group.id }}"{% if asset_group in asset_groups_select %} selected {% endif %}>{{ asset_group.name }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
|
@ -89,7 +89,7 @@
|
|||
<div class="col-sm-8">
|
||||
<select name="role" data-placeholder="请选择角色" class="chosen-select form-control m-b" multiple tabindex="2">
|
||||
{% for role in roles %}
|
||||
<option value="{{ role.name }}"{% if role in roles_select %} selected {% endif %}>{{ role.name }}</option>
|
||||
<option value="{{ role.id }}"{% if role in roles_select %} selected {% endif %}>{{ role.name }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
|
@ -118,37 +118,6 @@
|
|||
{% endblock %}
|
||||
{% block self_footer_js %}
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
$("input.role").click(function(){
|
||||
if($("input.role[value=GA]").is( ":checked" )){
|
||||
$("#admin_groups").css("display", 'none');
|
||||
}
|
||||
else {
|
||||
|
||||
$("#admin_groups").css("display", 'block');
|
||||
}
|
||||
});
|
||||
|
||||
$('#use_password').click(function(){
|
||||
if ($(this).is(':checked')){
|
||||
$('#admin_account_password').css('display', 'block')
|
||||
}
|
||||
else {
|
||||
|
||||
$('#admin_account_password').css('display', 'none')
|
||||
}
|
||||
});
|
||||
|
||||
$('#use_publicKey').click(function(){
|
||||
if ($(this).is(':checked')){
|
||||
|
||||
$('#admin_account_publicKey').css('display', 'block')
|
||||
}
|
||||
else {
|
||||
$('#admin_account_publicKey').css('display', 'none')
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var config = {
|
||||
'.chosen-select' : {},
|
||||
|
|
|
@ -36,9 +36,17 @@
|
|||
</div>
|
||||
<div class="hr-line-dashed"></div>
|
||||
<div class="form-group">
|
||||
<label for="sudo_commands_label" class="col-sm-2 control-label">系统命令<span class="red-fonts">*</span></label>
|
||||
<label for="sudo_runas" class="col-sm-2 control-label">RunAs<span class="red-fonts">*</span></label>
|
||||
<div class="col-sm-8">
|
||||
<textarea id="sudo_commands" name="sudo_commands" class="form-control" rows="3"></textarea>
|
||||
<input id="sudo_runas" name="sudo_runas" placeholder="Sudo RunAs User" type="text" class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
<div class="hr-line-dashed"></div>
|
||||
<div class="form-group">
|
||||
<label for="sudo_commands" class="col-sm-2 control-label">系统命令<span class="red-fonts">*</span></label>
|
||||
<div class="col-sm-8">
|
||||
<textarea id="sudo_commands" name="sudo_commands" class="form-control" rows="3" placeholder="/bin/grep, /bin/find"></textarea>
|
||||
<span class="help-block m-b-none">sudo命令,逗号分隔, 不支持换行</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="hr-line-dashed"></div>
|
||||
|
@ -64,7 +72,28 @@
|
|||
{% endblock %}
|
||||
{% block self_footer_js %}
|
||||
<script>
|
||||
$('#sudoForm').validator({
|
||||
timely: 2,
|
||||
theme: "yellow_right_effect",
|
||||
rules: {
|
||||
check_name: [/^\w{2,20}$/, '大小写字母数字和下划线,2-20位']
|
||||
},
|
||||
|
||||
fields: {
|
||||
"sudo_name": {
|
||||
rule: "required;check_name"
|
||||
},
|
||||
"sudo_runas": {
|
||||
rule: "required;check_name"
|
||||
},
|
||||
"sudo_commands": {
|
||||
rule: "required"
|
||||
}
|
||||
},
|
||||
valid: function(form) {
|
||||
form.submit();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
|
|
|
@ -40,6 +40,13 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="hr-line-dashed"></div>
|
||||
<div class="form-group">
|
||||
<label for="sudo_runas" class="col-sm-2 control-label">RunAs<span class="red-fonts">*</span></label>
|
||||
<div class="col-sm-8">
|
||||
<input id="sudo_runas" name="sudo_runas" placeholder="Sudo RunAs User" type="text" class="form-control" value="{{ sudo.runas }}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="hr-line-dashed"></div>
|
||||
<div class="form-group">
|
||||
<label for="sudo_commands_label" class="col-sm-2 control-label">系统命令<span class="red-fonts">*</span></label>
|
||||
<div class="col-sm-8">
|
||||
|
|
|
@ -6,7 +6,7 @@ sudo_file=/etc/sudoers
|
|||
|
||||
# Add Command Aliases
|
||||
add_cmd_alias() {
|
||||
{% for sudo in sudo_chosen_obj %}
|
||||
{% for sudo in sudo_alias %}
|
||||
if $(grep '^Cmnd_Alias {{ sudo.name }}' ${sudo_file} &> /dev/null); then
|
||||
sed -i 's@^Cmnd_Alias.*{{ sudo.name }}.*@Cmnd_Alias {{ sudo.name }} = {{ sudo.commands }}@g' ${sudo_file}
|
||||
else
|
||||
|
@ -17,13 +17,15 @@ add_cmd_alias() {
|
|||
|
||||
|
||||
add_role_chosen() {
|
||||
{% for role, alias in sudo_chosen_aliase.items %}
|
||||
if $(grep '^{{ role }}' ${sudo_file} &> /dev/null); then
|
||||
sed -i 's@^{{ role }}.*@{{ role }} ALL = {{ alias }}@g' ${sudo_file}
|
||||
{% for role, sudos in role_chosen_aliase.items %}
|
||||
{% for sudo in sudos %}
|
||||
if $(grep '^{{ role }}.*sudo.name' ${sudo_file} &> /dev/null); then
|
||||
sed -i 's@^{{ role }}.*sudo.name@{{ role }} ALL = ({{ sudo.runas }}) NOPASSWD: {{ sudo.name }}@g' ${sudo_file}
|
||||
else
|
||||
echo "{{ role }} ALL = {{ alias }}" >> ${sudo_file}
|
||||
echo "{{ role }} ALL = ({{ sudo.runas }}) NOPASSWD: {{ sudo.name }}" >> ${sudo_file}
|
||||
fi
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -28,14 +28,12 @@
|
|||
<a href="/jperm/rule/">授权规则</a>
|
||||
</li>
|
||||
|
||||
<li class="sudo_list sudo_edit sudo_add cmd_list cmd_edit cmd_add sudo_detail">
|
||||
<li class="role">
|
||||
<a href="/jperm/role/">系统角色</a>
|
||||
</li>
|
||||
<li class="sudo_list sudo_edit sudo_add cmd_list cmd_edit cmd_add sudo_detail">
|
||||
<li class="sudo">
|
||||
<a href="/jperm/sudo/">Sudo命令</a>
|
||||
</li>
|
||||
<li class="apply_show online"><a href="/jperm/apply_show/online/">权限审批</a></li>
|
||||
<li class="apply_show online"><a href="/jperm/log/">授权记录</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
|
|
@ -45,17 +45,11 @@
|
|||
<div class="alert alert-success text-center">{{ msg }}</div>
|
||||
{% endif %}
|
||||
<div class="form-group">
|
||||
<label for="username" class="col-sm-2 control-label">默认用户名<span class="red-fonts">*</span></label>
|
||||
<label for="username" class="col-sm-2 control-label">默认管理用户<span class="red-fonts">*</span></label>
|
||||
<input name="setting" value="default" style="display: none">
|
||||
<div class="col-sm-8">
|
||||
<input id="username" name="username" placeholder="Username" type="text" value="{{ setting_default.field1 }}" class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
<div class="hr-line-dashed"></div>
|
||||
<div class="form-group">
|
||||
<label for="port" class="col-sm-2 control-label">默认ssh端口<span class="red-fonts">*</span></label>
|
||||
<div class="col-sm-8">
|
||||
<input id="port" name="port" placeholder="Port" type="text" value="{{ setting_default.field2 }}" class="form-control">
|
||||
<span class="help-block m-b-none">该用户为root或用户NOPASS:ALL sudo权限的用户</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="hr-line-dashed"></div>
|
||||
|
@ -67,6 +61,13 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="hr-line-dashed"></div>
|
||||
<div class="form-group">
|
||||
<label for="port" class="col-sm-2 control-label">默认ssh端口<span class="red-fonts">*</span></label>
|
||||
<div class="col-sm-8">
|
||||
<input id="port" name="port" placeholder="Port" type="text" value="{{ setting_default.field2 }}" class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
<div class="hr-line-dashed"></div>
|
||||
<div class="form-group">
|
||||
<label for="key" class="col-sm-2 control-label">默认密钥</label>
|
||||
<div class="col-sm-8">
|
||||
|
@ -118,7 +119,7 @@
|
|||
fields: {
|
||||
"username": {
|
||||
rule: "required;check_name",
|
||||
tip: "输入用户名",
|
||||
tip: "输入管理用户名",
|
||||
ok: "",
|
||||
msg: {required: "用户名称必填"}
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue