Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jumpserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
jumpserver
Commits
b7cfac4d
Commit
b7cfac4d
authored
Dec 07, 2015
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug fix
parent
5be26337
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
55 additions
and
56 deletions
+55
-56
connect.py
connect.py
+3
-2
views.py
jlog/views.py
+5
-0
api.py
jumpserver/api.py
+0
-11
mytags.py
jumpserver/templatetags/mytags.py
+1
-1
urls.py
juser/urls.py
+0
-3
views.py
juser/views.py
+4
-6
log_exec.html
templates/jlog/log_exec.html
+13
-14
log_file.html
templates/jlog/log_file.html
+13
-14
log_offline.html
templates/jlog/log_offline.html
+1
-2
log_online.html
templates/jlog/log_online.html
+12
-1
user_list.html
templates/juser/user_list.html
+1
-0
nav.html
templates/nav.html
+2
-2
No files found.
connect.py
View file @
b7cfac4d
...
@@ -312,6 +312,7 @@ class Tty(object):
...
@@ -312,6 +312,7 @@ class Tty(object):
port
=
connect_info
.
get
(
'port'
),
port
=
connect_info
.
get
(
'port'
),
username
=
connect_info
.
get
(
'role_name'
),
username
=
connect_info
.
get
(
'role_name'
),
password
=
connect_info
.
get
(
'role_pass'
),
password
=
connect_info
.
get
(
'role_pass'
),
allow_agent
=
False
,
look_for_keys
=
False
)
look_for_keys
=
False
)
except
paramiko
.
ssh_exception
.
AuthenticationException
,
paramiko
.
ssh_exception
.
SSHException
:
except
paramiko
.
ssh_exception
.
AuthenticationException
,
paramiko
.
ssh_exception
.
SSHException
:
...
@@ -748,7 +749,7 @@ def main():
...
@@ -748,7 +749,7 @@ def main():
else
:
else
:
try
:
try
:
asset
=
nav
.
search_result
[
int
(
option
)]
asset
=
nav
.
search_result
[
int
(
option
)]
roles
=
get_role
(
login_user
,
asset
)
roles
=
nav
.
user_perm
.
get
(
'asset'
)
.
get
(
asset
)
.
get
(
'role'
)
if
len
(
roles
)
>
1
:
if
len
(
roles
)
>
1
:
role_check
=
dict
(
zip
(
range
(
len
(
roles
)),
roles
))
role_check
=
dict
(
zip
(
range
(
len
(
roles
)),
roles
))
print
"
\033
[32m[ID] 角色
\033
[0m"
print
"
\033
[32m[ID] 角色
\033
[0m"
...
@@ -766,7 +767,7 @@ def main():
...
@@ -766,7 +767,7 @@ def main():
color_print
(
'请输入正确ID'
,
'red'
)
color_print
(
'请输入正确ID'
,
'red'
)
continue
continue
elif
len
(
roles
)
==
1
:
elif
len
(
roles
)
==
1
:
role
=
roles
[
0
]
role
=
list
(
roles
)
[
0
]
else
:
else
:
color_print
(
'没有映射用户'
,
'red'
)
color_print
(
'没有映射用户'
,
'red'
)
continue
continue
...
...
jlog/views.py
View file @
b7cfac4d
...
@@ -23,7 +23,12 @@ def log_list(request, offset):
...
@@ -23,7 +23,12 @@ def log_list(request, offset):
cmd
=
request
.
GET
.
get
(
'cmd'
,
''
)
cmd
=
request
.
GET
.
get
(
'cmd'
,
''
)
if
offset
==
'online'
:
if
offset
==
'online'
:
keyword
=
request
.
GET
.
get
(
'keyword'
,
''
)
posts
=
Log
.
objects
.
filter
(
is_finished
=
False
)
.
order_by
(
'-start_time'
)
posts
=
Log
.
objects
.
filter
(
is_finished
=
False
)
.
order_by
(
'-start_time'
)
if
keyword
:
posts
=
posts
.
filter
(
Q
(
user__icontains
=
keyword
)
|
Q
(
host__icontains
=
keyword
)
|
Q
(
login_type_icontains
=
keyword
))
elif
offset
==
'exec'
:
elif
offset
==
'exec'
:
posts
=
ExecLog
.
objects
.
all
()
.
order_by
(
'-id'
)
posts
=
ExecLog
.
objects
.
all
()
.
order_by
(
'-id'
)
keyword
=
request
.
GET
.
get
(
'keyword'
,
''
)
keyword
=
request
.
GET
.
get
(
'keyword'
,
''
)
...
...
jumpserver/api.py
View file @
b7cfac4d
...
@@ -71,17 +71,6 @@ def get_asset_info(asset):
...
@@ -71,17 +71,6 @@ def get_asset_info(asset):
return
info
return
info
def
get_role
(
user
,
asset
):
"""
获取用户在这个资产上的授权角色列表
"""
roles
=
[]
rules
=
PermRule
.
objects
.
filter
(
user
=
user
,
asset
=
asset
)
for
rule
in
rules
:
roles
.
extend
(
list
(
rule
.
role
.
all
()))
return
roles
def
get_role_key
(
user
,
role
):
def
get_role_key
(
user
,
role
):
"""
"""
由于role的key的权限是所有人可以读的, ansible执行命令等要求为600,所以拷贝一份到特殊目录
由于role的key的权限是所有人可以读的, ansible执行命令等要求为600,所以拷贝一份到特殊目录
...
...
jumpserver/templatetags/mytags.py
View file @
b7cfac4d
...
@@ -237,7 +237,7 @@ def key_exist(username):
...
@@ -237,7 +237,7 @@ def key_exist(username):
"""
"""
ssh key is exist or not
ssh key is exist or not
"""
"""
if
os
.
path
.
isfile
(
os
.
path
.
join
(
KEY_DIR
,
'user'
,
username
+
'pem'
)):
if
os
.
path
.
isfile
(
os
.
path
.
join
(
KEY_DIR
,
'user'
,
username
+
'
.
pem'
)):
return
True
return
True
else
:
else
:
return
False
return
False
...
...
juser/urls.py
View file @
b7cfac4d
...
@@ -25,9 +25,6 @@ urlpatterns = patterns('juser.views',
...
@@ -25,9 +25,6 @@ urlpatterns = patterns('juser.views',
(
r'^forget_password/$'
,
forget_password
),
(
r'^forget_password/$'
,
forget_password
),
(
r'^change_info/$'
,
'change_info'
),
(
r'^change_info/$'
,
'change_info'
),
(
r'^change_role/$'
,
'chg_role'
),
(
r'^regen_ssh_key/$'
,
'regen_ssh_key'
),
(
r'^regen_ssh_key/$'
,
'regen_ssh_key'
),
(
r'^down_key/$'
,
'down_key'
),
(
r'^down_key/$'
,
'down_key'
),
(
r'runcommand/$'
,
'RunCommand'
),
)
)
juser/views.py
View file @
b7cfac4d
...
@@ -248,10 +248,11 @@ def user_del(request):
...
@@ -248,10 +248,11 @@ def user_del(request):
user_id_list
=
user_ids
.
split
(
','
)
user_id_list
=
user_ids
.
split
(
','
)
else
:
else
:
return
HttpResponse
(
'错误请求'
)
return
HttpResponse
(
'错误请求'
)
for
user_id
in
user_id_list
:
for
user_id
in
user_id_list
:
user
=
get_object
(
User
,
id
=
user_id
)
user
=
get_object
(
User
,
id
=
user_id
)
if
user
:
if
user
and
user
.
username
!=
'admin'
:
logger
.
debug
(
"删除用户
%
s "
%
user
.
username
)
logger
.
debug
(
u
"删除用户
%
s "
%
user
.
username
)
bash
(
'userdel -r
%
s'
%
user
.
username
)
bash
(
'userdel -r
%
s'
%
user
.
username
)
user
.
delete
()
user
.
delete
()
return
HttpResponse
(
'删除成功'
)
return
HttpResponse
(
'删除成功'
)
...
@@ -418,9 +419,6 @@ def change_info(request):
...
@@ -418,9 +419,6 @@ def change_info(request):
error
=
'密码须大于6位'
error
=
'密码须大于6位'
if
not
error
:
if
not
error
:
# if password != user.password:
# password = CRYPTOR.md5_crypt(password)
User
.
objects
.
filter
(
id
=
user_id
)
.
update
(
name
=
name
,
email
=
email
)
User
.
objects
.
filter
(
id
=
user_id
)
.
update
(
name
=
name
,
email
=
email
)
if
len
(
password
)
>
0
:
if
len
(
password
)
>
0
:
user
.
set_password
(
password
)
user
.
set_password
(
password
)
...
@@ -454,7 +452,7 @@ def down_key(request):
...
@@ -454,7 +452,7 @@ def down_key(request):
user
=
get_object
(
User
,
uuid
=
uuid_r
)
user
=
get_object
(
User
,
uuid
=
uuid_r
)
if
user
:
if
user
:
username
=
user
.
username
username
=
user
.
username
private_key_file
=
os
.
path
.
join
(
KEY_DIR
,
'user'
,
username
+
'pem'
)
private_key_file
=
os
.
path
.
join
(
KEY_DIR
,
'user'
,
username
+
'
.
pem'
)
print
private_key_file
print
private_key_file
if
os
.
path
.
isfile
(
private_key_file
):
if
os
.
path
.
isfile
(
private_key_file
):
f
=
open
(
private_key_file
)
f
=
open
(
private_key_file
)
...
...
templates/jlog/log_exec.html
View file @
b7cfac4d
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
<div
class=
"wrapper wrapper-content animated fadeInRight"
>
<div
class=
"wrapper wrapper-content animated fadeInRight"
>
<div
class=
"row"
>
<div
class=
"row"
>
<div
class=
"col-sm-1
0
"
>
<div
class=
"col-sm-1
2
"
>
<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>
批量命令日志
</h5>
<h5>
批量命令日志
</h5>
...
@@ -33,20 +33,19 @@
...
@@ -33,20 +33,19 @@
<li><a
href=
"/jlog/log_list/offline/"
class=
"text-center"
><i
class=
"fa fa-bar-chart-o"
></i>
历史记录
</a></li>
<li><a
href=
"/jlog/log_list/offline/"
class=
"text-center"
><i
class=
"fa fa-bar-chart-o"
></i>
历史记录
</a></li>
<li
class=
"active"
><a
href=
"/jlog/log_list/exec/"
class=
"text-center"
><i
class=
"fa fa-bar-chart-o"
></i>
命令记录
</a></li>
<li
class=
"active"
><a
href=
"/jlog/log_list/exec/"
class=
"text-center"
><i
class=
"fa fa-bar-chart-o"
></i>
命令记录
</a></li>
<li><a
href=
"/jlog/log_list/file/"
class=
"text-center"
><i
class=
"fa fa-bar-chart-o"
></i>
上传下载
</a></li>
<li><a
href=
"/jlog/log_list/file/"
class=
"text-center"
><i
class=
"fa fa-bar-chart-o"
></i>
上传下载
</a></li>
</ul>
<div
class=
""
style=
"float: right"
>
</div>
<form
id=
"search_form"
method=
"get"
action=
""
class=
"pull-right mail-search"
>
<br/>
<div
class=
"input-group"
>
<div
class=
""
>
<input
type=
"text"
class=
"form-control input-sm"
id=
"keyword"
name=
"keyword"
value=
"{{ keyword }}"
placeholder=
"Search"
>
<form
id=
"search_form"
method=
"get"
action=
""
class=
"pull-right mail-search"
>
<div
class=
"input-group-btn"
>
<div
class=
"input-group"
>
<button
id=
'search_btn'
type=
"submit"
class=
"btn btn-sm btn-primary"
>
<input
type=
"text"
class=
"form-control input-sm"
id=
"keyword"
name=
"keyword"
value=
"{{ keyword }}"
placeholder=
"Search"
>
-搜索-
<div
class=
"input-group-btn"
>
</button>
<button
id=
'search_btn'
type=
"submit"
class=
"btn btn-sm btn-primary"
>
</div>
-搜索-
</div>
</button>
</form>
</div>
</div>
</div>
</
form
>
</
ul
>
</div>
</div>
<div
class=
"tab-content"
>
<div
class=
"tab-content"
>
<table
class=
"table table-striped table-bordered table-hover "
>
<table
class=
"table table-striped table-bordered table-hover "
>
...
...
templates/jlog/log_file.html
View file @
b7cfac4d
...
@@ -33,20 +33,19 @@
...
@@ -33,20 +33,19 @@
<li><a
href=
"/jlog/log_list/offline/"
class=
"text-center"
><i
class=
"fa fa-bar-chart-o"
></i>
历史记录
</a></li>
<li><a
href=
"/jlog/log_list/offline/"
class=
"text-center"
><i
class=
"fa fa-bar-chart-o"
></i>
历史记录
</a></li>
<li><a
href=
"/jlog/log_list/exec/"
class=
"text-center"
><i
class=
"fa fa-bar-chart-o"
></i>
命令记录
</a></li>
<li><a
href=
"/jlog/log_list/exec/"
class=
"text-center"
><i
class=
"fa fa-bar-chart-o"
></i>
命令记录
</a></li>
<li
class=
"active"
><a
href=
"/jlog/log_list/file/"
class=
"text-center"
><i
class=
"fa fa-bar-chart-o"
></i>
上传下载
</a></li>
<li
class=
"active"
><a
href=
"/jlog/log_list/file/"
class=
"text-center"
><i
class=
"fa fa-bar-chart-o"
></i>
上传下载
</a></li>
</ul>
<div
class=
""
style=
"float: right"
>
</div>
<form
id=
"search_form"
method=
"get"
action=
""
class=
"pull-right mail-search"
>
<br/>
<div
class=
"input-group"
>
<div
class=
""
>
<input
type=
"text"
class=
"form-control input-sm"
id=
"keyword"
name=
"keyword"
value=
"{{ keyword }}"
placeholder=
"Search"
>
<form
id=
"search_form"
method=
"get"
action=
""
class=
"pull-right mail-search"
>
<div
class=
"input-group-btn"
>
<div
class=
"input-group"
>
<button
id=
'search_btn'
type=
"submit"
class=
"btn btn-sm btn-primary"
>
<input
type=
"text"
class=
"form-control input-sm"
id=
"keyword"
name=
"keyword"
value=
"{{ keyword }}"
placeholder=
"Search"
>
-搜索-
<div
class=
"input-group-btn"
>
</button>
<button
id=
'search_btn'
type=
"submit"
class=
"btn btn-sm btn-primary"
>
</div>
-搜索-
</div>
</button>
</form>
</div>
</div>
</div>
</
form
>
</
ul
>
</div>
</div>
<div
class=
"tab-content"
>
<div
class=
"tab-content"
>
<table
class=
"table table-striped table-bordered table-hover "
>
<table
class=
"table table-striped table-bordered table-hover "
>
...
@@ -70,7 +69,7 @@
...
@@ -70,7 +69,7 @@
<td
class=
"text-center"
>
{{ post.id }}
</td>
<td
class=
"text-center"
>
{{ post.id }}
</td>
<td
class=
"text-center"
>
{{ post.user }}
</td>
<td
class=
"text-center"
>
{{ post.user }}
</td>
<td
class=
"text-center"
>
{{ post.host | truncatechars:30 }}
</td>
<td
class=
"text-center"
>
{{ post.host | truncatechars:30 }}
</td>
<td
class=
"text-center"
>
{{ post.filename | truncatechars:
3
0 }}
</td>
<td
class=
"text-center"
>
{{ post.filename | truncatechars:
2
0 }}
</td>
<td
class=
"text-center"
>
{{ post.type }}
</td>
<td
class=
"text-center"
>
{{ post.type }}
</td>
<td
class=
"text-center"
>
{{ post.remote_ip }}
</td>
<td
class=
"text-center"
>
{{ post.remote_ip }}
</td>
<td
class=
"text-center"
>
{{ post.datetime|date:"Y-m-d H:i:s"}}
</td>
<td
class=
"text-center"
>
{{ post.datetime|date:"Y-m-d H:i:s"}}
</td>
...
...
templates/jlog/log_offline.html
View file @
b7cfac4d
...
@@ -58,7 +58,6 @@
...
@@ -58,7 +58,6 @@
<li><a
href=
"/jlog/log_list/file/"
class=
"text-center"
><i
class=
"fa fa-bar-chart-o"
></i>
上传下载
</a></li>
<li><a
href=
"/jlog/log_list/file/"
class=
"text-center"
><i
class=
"fa fa-bar-chart-o"
></i>
上传下载
</a></li>
</ul>
</ul>
</div>
</div>
<br/>
<form
class=
"form-inline"
action=
""
method=
"get"
>
<form
class=
"form-inline"
action=
""
method=
"get"
>
<div
class=
"form-group"
id=
"date_5"
>
<div
class=
"form-group"
id=
"date_5"
>
<div
class=
"input-daterange input-group"
id=
"datepicker"
>
<div
class=
"input-daterange input-group"
id=
"datepicker"
>
...
@@ -89,7 +88,7 @@
...
@@ -89,7 +88,7 @@
<input
id=
"cmd"
name=
"cmd"
placeholder=
"命令"
type=
"text"
class=
"form-control"
value=
"{{ cmd }}"
style=
"width: 200px;"
>
<input
id=
"cmd"
name=
"cmd"
placeholder=
"命令"
type=
"text"
class=
"form-control"
value=
"{{ cmd }}"
style=
"width: 200px;"
>
</div>
</div>
<button
id=
'search_btn'
type=
"submit"
class=
"btn btn-sm btn-primary"
>
<button
id=
'search_btn'
type=
"submit"
class=
"btn btn-sm btn-primary"
>
Search
- 搜索 -
</button>
</button>
</form>
</form>
<div
class=
"tab-content"
>
<div
class=
"tab-content"
>
...
...
templates/jlog/log_online.html
View file @
b7cfac4d
...
@@ -71,9 +71,20 @@
...
@@ -71,9 +71,20 @@
<li><a
href=
"/jlog/log_list/offline/"
class=
"text-center"
><i
class=
"fa fa-bar-chart-o"
></i>
历史记录
</a></li>
<li><a
href=
"/jlog/log_list/offline/"
class=
"text-center"
><i
class=
"fa fa-bar-chart-o"
></i>
历史记录
</a></li>
<li><a
href=
"/jlog/log_list/exec/"
class=
"text-center"
><i
class=
"fa fa-bar-chart-o"
></i>
命令记录
</a></li>
<li><a
href=
"/jlog/log_list/exec/"
class=
"text-center"
><i
class=
"fa fa-bar-chart-o"
></i>
命令记录
</a></li>
<li><a
href=
"/jlog/log_list/file/"
class=
"text-center"
><i
class=
"fa fa-bar-chart-o"
></i>
上传下载
</a></li>
<li><a
href=
"/jlog/log_list/file/"
class=
"text-center"
><i
class=
"fa fa-bar-chart-o"
></i>
上传下载
</a></li>
<div
class=
""
style=
"float: right"
>
<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=
"keyword"
name=
"keyword"
value=
"{{ keyword }}"
placeholder=
"Search"
>
<div
class=
"input-group-btn"
>
<button
id=
'search_btn'
type=
"submit"
class=
"btn btn-sm btn-primary"
>
-搜索-
</button>
</div>
</div>
</form>
</div>
</ul>
</ul>
</div>
</div>
<br/>
<div
class=
"tab-content"
>
<div
class=
"tab-content"
>
<table
class=
"table table-striped table-bordered table-hover "
>
<table
class=
"table table-striped table-bordered table-hover "
>
<thead>
<thead>
...
...
templates/juser/user_list.html
View file @
b7cfac4d
...
@@ -123,6 +123,7 @@
...
@@ -123,6 +123,7 @@
$
(
".gradeX input:checked"
).
each
(
function
()
{
$
(
".gradeX input:checked"
).
each
(
function
()
{
check_array
.
push
(
$
(
this
).
attr
(
"value"
))
check_array
.
push
(
$
(
this
).
attr
(
"value"
))
});
});
console
.
log
(
check_array
.
join
(
","
));
$
.
post
(
"/juser/user_del/"
,
$
.
post
(
"/juser/user_del/"
,
{
id
:
check_array
.
join
(
","
)},
{
id
:
check_array
.
join
(
","
)},
function
(
data
){
function
(
data
){
...
...
templates/nav.html
View file @
b7cfac4d
...
@@ -9,8 +9,8 @@
...
@@ -9,8 +9,8 @@
<li
id=
"juser"
>
<li
id=
"juser"
>
<a
href=
"#"
><i
class=
"fa fa-group"
></i>
<span
class=
"nav-label"
>
用户管理
</span><span
class=
"fa arrow"
></span></a>
<a
href=
"#"
><i
class=
"fa fa-group"
></i>
<span
class=
"nav-label"
>
用户管理
</span><span
class=
"fa arrow"
></span></a>
<ul
class=
"nav nav-second-level"
>
<ul
class=
"nav nav-second-level"
>
<li
class=
"group_list group_edit"
><a
href=
"/juser/group_list/"
>
查看用户组
</a></li>
<li
class=
"group_list group_edit
group_add
"
><a
href=
"/juser/group_list/"
>
查看用户组
</a></li>
<li
class=
"user_list user_edit user_detail"
><a
href=
"/juser/user_list/"
>
查看用户
<span
class=
"label {% ifequal user_active_num user_total_num %}label-primary {% else %}label-warning {% endifequal %}pull-right"
>
{{ user_active_num }}/{{ user_total_num }}
</span></a></li>
<li
class=
"user_list user_edit user_detail
user_add
"
><a
href=
"/juser/user_list/"
>
查看用户
<span
class=
"label {% ifequal user_active_num user_total_num %}label-primary {% else %}label-warning {% endifequal %}pull-right"
>
{{ user_active_num }}/{{ user_total_num }}
</span></a></li>
</ul>
</ul>
</li>
</li>
<li
id=
"jasset"
>
<li
id=
"jasset"
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment