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
c1d8de45
Commit
c1d8de45
authored
Apr 18, 2015
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ϲ
parent
0873211d
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
51 additions
and
47 deletions
+51
-47
connect.py
connect.py
+6
-1
views.py
jasset/views.py
+1
-8
views.py
jperm/views.py
+13
-12
jumpserver.conf
jumpserver.conf
+2
-3
api.py
jumpserver/api.py
+5
-0
views.py
jumpserver/views.py
+8
-5
error.html
templates/error.html
+1
-1
group_add.html
templates/jasset/group_add.html
+2
-1
group_edit.html
templates/jasset/group_edit.html
+1
-1
log_online.html
templates/jlog/log_online.html
+3
-2
perm_detail.html
templates/jperm/perm_detail.html
+1
-1
perm_list.html
templates/jperm/perm_list.html
+1
-0
dept_list.html
templates/juser/dept_list.html
+2
-2
user_detail.html
templates/juser/user_detail.html
+2
-7
nav.html
templates/nav.html
+2
-2
success.html
templates/success.html
+1
-1
No files found.
connect.py
View file @
c1d8de45
# coding: utf-8
import
socket
import
sys
reload
(
sys
)
sys
.
setdefaultencoding
(
'utf8'
)
import
socket
import
os
import
re
import
ast
...
...
@@ -218,6 +222,7 @@ def print_user_host(username):
hosts
.
sort
()
for
ip
in
hosts
:
print
'
%-15
s --
%
s'
%
(
ip
,
hosts_attr
[
ip
][
2
])
print
''
def
print_user_hostgroup
(
username
):
...
...
jasset/views.py
View file @
c1d8de45
...
...
@@ -4,8 +4,6 @@ import ast
from
django.db.models
import
Q
from
django.template
import
RequestContext
from
django.shortcuts
import
render_to_response
from
jperm.models
import
Perm
from
jumpserver.api
import
*
...
...
@@ -20,11 +18,6 @@ def my_render(template, data, request):
return
render_to_response
(
template
,
data
,
context_instance
=
RequestContext
(
request
))
def
httperror
(
request
,
emg
):
message
=
emg
return
render_to_response
(
'error.html'
,
locals
(),
context_instance
=
RequestContext
(
request
))
def
get_host_groups
(
groups
):
""" 获取主机所属的组类 """
ret
=
[]
...
...
@@ -832,7 +825,7 @@ def dept_host_ajax(request):
else
:
hosts
=
Asset
.
objects
.
all
()
return
my_render
(
'jasset/dept_host_ajax.html'
,
locals
())
return
my_render
(
'jasset/dept_host_ajax.html'
,
locals
()
,
request
)
@require_login
...
...
jperm/views.py
View file @
c1d8de45
...
...
@@ -187,18 +187,15 @@ def perm_edit_adm(request):
@require_admin
def
perm_detail
(
request
):
header_title
,
path1
,
path2
=
u'编辑授权'
,
u'授权管理'
,
u'授权详情'
perm_id
=
request
.
GET
.
get
(
'id'
)
perm
=
Perm
.
objects
.
filter
(
id
=
perm_id
)
if
perm
:
perm
=
perm
[
0
]
user_groups
=
perm
.
user_group
.
all
()
asset_groups
=
perm
.
asset_group
.
all
()
users_list
=
[]
group_id
=
request
.
GET
.
get
(
'id'
)
user_group
=
UserGroup
.
objects
.
filter
(
id
=
group_id
)
if
user_group
:
user_group
=
user_group
[
0
]
users_list
=
user_group
.
user_set
.
all
()
perms
=
user_group
.
perm_set
.
all
()
asset_groups
=
[
perm
.
asset_group
for
perm
in
perms
]
assets_list
=
[]
for
user_group
in
user_groups
:
users_list
.
extend
(
user_group
.
user_set
.
all
())
for
asset_group
in
asset_groups
:
assets_list
.
extend
(
asset_group
.
asset_set
.
all
())
...
...
@@ -478,7 +475,7 @@ def sudo_refresh(request):
asset_groups_select
=
sudo_perm
.
asset_group
.
all
()
cmd_groups_select
=
sudo_perm
.
cmd_group
.
all
()
sudo_ldap_add
(
user_group
,
user_runas
,
asset_groups_select
,
cmd_groups_select
)
return
HttpResponse
(
'
ok
'
)
return
HttpResponse
(
'
刷新sudo授权成功
'
)
# @require_admin
...
...
@@ -652,7 +649,11 @@ def cmd_detail(request):
cmd_ids
=
request
.
GET
.
get
(
'id'
)
.
split
(
','
)
cmds
=
[]
if
len
(
cmd_ids
)
==
1
:
cmd_group
=
CmdGroup
.
objects
.
filter
(
id
=
cmd_ids
[
0
])
if
cmd_ids
[
0
]:
cmd_id
=
cmd_ids
[
0
]
else
:
cmd_id
=
1
cmd_group
=
CmdGroup
.
objects
.
filter
(
id
=
cmd_id
)
if
cmd_group
:
cmd_group
=
cmd_group
[
0
]
cmds
.
extend
(
cmd_group
.
cmd
.
split
(
','
))
...
...
jumpserver.conf
View file @
c1d8de45
...
...
@@ -6,7 +6,6 @@ port = 80
key
=
88
aaaf7ffe3c6c04
[
db
]
host
=
127
.
0
.
0
.
1
port
=
3306
...
...
@@ -17,14 +16,14 @@ database = jumpserver
[
ldap
]
ldap_enable
=
1
host_url
=
ldap
://
1
92
.
168
.
0
.
129
:
389
host_url
=
ldap
://
1
27
.
0
.
0
.
1
:
389
base_dn
=
dc
=
jumpserver
,
dc
=
org
root_dn
=
cn
=
admin
,
dc
=
jumpserver
,
dc
=
org
root_pw
=
secret234
[
websocket
]
web_socket_host
=
192
.
168
.
0
.
12
9
:
3000
web_socket_host
=
192
.
168
.
20
.
20
9
:
3000
[
mail
]
...
...
jumpserver/api.py
View file @
c1d8de45
...
...
@@ -487,3 +487,7 @@ def is_dir(dir_name, username='root', mode=0755):
def
success
(
request
,
msg
):
return
render_to_response
(
'success.html'
,
locals
())
def
httperror
(
request
,
emg
):
message
=
emg
return
render_to_response
(
'error.html'
,
locals
())
\ No newline at end of file
jumpserver/views.py
View file @
c1d8de45
...
...
@@ -231,16 +231,19 @@ def filter_ajax_api(request):
def
install
(
request
):
from
juser.models
import
DEPT
,
User
dept
=
DEPT
(
id
=
1
,
name
=
"超管部"
,
comment
=
"SUPER DEPT"
)
if
User
.
objects
.
filter
(
id
=
5000
):
return
httperror
(
request
,
'Jumpserver已初始化,不能重复安装!'
)
dept
=
DEPT
(
id
=
1
,
name
=
"超管部"
,
comment
=
"超级管理部门"
)
dept
.
save
()
dept2
=
DEPT
(
id
=
2
,
name
=
"默认"
,
comment
=
"
DEFAULT DEPT
"
)
dept2
=
DEPT
(
id
=
2
,
name
=
"默认"
,
comment
=
"
默认部门
"
)
dept2
.
save
()
IDC
(
id
=
1
,
name
=
"默认"
,
comment
=
"
DEFAULT
IDC"
)
.
save
()
BisGroup
(
id
=
1
,
name
=
"ALL"
,
dept
=
dept
,
comment
=
"
ALL USER GROUP
"
)
.
save
()
IDC
(
id
=
1
,
name
=
"默认"
,
comment
=
"
默认
IDC"
)
.
save
()
BisGroup
(
id
=
1
,
name
=
"ALL"
,
dept
=
dept
,
comment
=
"
所有主机组
"
)
.
save
()
User
(
id
=
5000
,
username
=
"admin"
,
password
=
md5_crypt
(
'admin'
),
name
=
'admin'
,
email
=
'admin@jumpserver.org'
,
role
=
'SU'
,
is_active
=
True
,
dept
=
dept
)
.
save
()
return
success
(
request
,
u'
安装
成功'
)
return
success
(
request
,
u'
Jumpserver初始化
成功'
)
def
download
(
request
):
...
...
templates/error.html
View file @
c1d8de45
...
...
@@ -25,7 +25,7 @@
<h3
id=
"jumpTo"
class=
"font-bold text-info"
></h3>
<div
class=
"error-desc"
>
The server encountered something unexpected that didn't allow it to complete the request. We apologize.
<br/>
You can go back to main page:
<br/><a
href=
"/"
class=
"btn btn-primary m-t"
>
Dashboard
</a>
You can go back to main page:
<br/><a
href=
"/"
class=
"btn btn-primary m-t"
>
首页
</a>
</div>
</div>
...
...
templates/jasset/group_add.html
View file @
c1d8de45
...
...
@@ -196,7 +196,8 @@
$
.
get
(
'/jasset/dept_host_ajax/'
,
{
'id'
:
dept_id
},
function
(
data
){
$
(
'#hosts'
).
html
(
data
)
$
(
'#assets'
).
html
(
data
)
$
(
'#assets_total'
).
html
(
data
)
})
}
...
...
templates/jasset/group_edit.html
View file @
c1d8de45
...
...
@@ -205,7 +205,7 @@
$
.
get
(
'/jasset/dept_host_ajax/'
,
{
'id'
:
dept_id
},
function
(
data
){
$
(
'#
hos
ts'
).
html
(
data
)
$
(
'#
asse
ts'
).
html
(
data
)
})
}
</script>
...
...
templates/jlog/log_online.html
View file @
c1d8de45
...
...
@@ -153,7 +153,8 @@
var
regx
=
/
\x
1B
\[([
0-9
]{1,3}((
;
[
0-9
]{1,3})
*
)?)?[
m|K
]
/g
;
// tag.append('
<
p
>
'+escapeString(obj.content.replace(regx,''))+'
<
/p>'
)
;
if
(
option
==
'new'
)
{
tag
.
append
(
'<p style="margin: 2px">'
+
escapeString
(
obj
.
content
)
+
'</p>'
);
// tag.append('
<
p
style
=
"margin: 2px"
>
' + escapeString(obj.content) + '
<
/p>'
)
;
tag
.
append
(
'<p>'
+
escapeString
(
obj
.
content
.
replace
(
regx
,
' '
))
+
'</p>'
);
}
else
if
(
option
==
'exist'
)
{
tag
.
append
(
'<pre>'
+
exsit_message
+
'</pre>'
);
}
...
...
@@ -208,7 +209,7 @@
$
.
ajax
({
type
:
"GET"
,
url
:
g_url
,
success
:
window
.
open
(
"/jlog/log_list/online/"
,
"_self"
)
success
:
window
.
open
(
"/jlog/log_list/online/"
,
"_self"
)
,
error
:
window
.
open
(
g_url
,
"_self"
)
});
...
...
templates/jperm/perm_detail.html
View file @
c1d8de45
...
...
@@ -89,7 +89,7 @@
<td>
{{ asset.ip }}
</td>
<td>
{{ asset.idc.name }}
</td>
<td>
{% for group in asset.bis_group.all
|filter_private
%}
{% for group in asset.bis_group.all %}
{{ group }}
{% endfor %}
</td>
...
...
templates/jperm/perm_list.html
View file @
c1d8de45
...
...
@@ -65,6 +65,7 @@
<td
class=
"text-center"
>
<a
href=
"/jasset/host_list/?gid={{ group.id }}"
>
{{ group.id | ugrp_perm_asset_count }}
</a>
</td>
<td
class=
"text-center"
>
{{ group.comment }}
</td>
<td
class=
"text-center"
>
<a
href=
"../perm_detail/?id={{ group.id }}"
class=
"btn btn-xs btn-primary"
>
详情
</a>
<a
href=
"../perm_edit/?id={{ group.id }}"
class=
"btn btn-xs btn-danger"
>
授权编辑
</a>
</td>
</tr>
...
...
templates/juser/dept_list.html
View file @
c1d8de45
...
...
@@ -67,13 +67,13 @@
<td
class=
"text-center"
>
{{ dept.name }}
</td>
<td
class=
"text-center"
>
<a
href=
"/juser/group_list/?did={{ dept.id }}"
>
{{ dept.id | dept_group_num }}
</a>
</td>
<td
class=
"text-center"
>
<a
href=
"/juser/user_list/?did={{ dept.id }}"
>
{{ dept.id | dept_user_num}}
</a>
</td>
<td
class=
"text-center"
>
{{ dept.id | dept_asset_num}}
</td>
<td
class=
"text-center"
>
<a
href=
"/jasset/host_list/?did={{ dept.id }}"
>
{{ dept.id | dept_asset_num}}
</a>
</td>
<td
class=
"text-center"
>
{{ dept.comment }}
</td>
<td
class=
"text-center"
>
{#
<a
href=
"../dept_detail/?id={{ dept.id }}"
class=
"btn btn-xs btn-primary"
>
详情
</a>
#}
{% ifequal session_role_id 2 %}
<a
href=
"../dept_edit/?id={{ dept.id }}"
class=
"btn btn-xs btn-info"
>
编辑
</a>
<a
href=
"../dept_del/?id={{ dept.id }}"
class=
"btn btn-xs btn-danger {% if dept.id < 3 %} disabled {% endif %}
}
"
>
删除
</a>
<a
href=
"../dept_del/?id={{ dept.id }}"
class=
"btn btn-xs btn-danger {% if dept.id < 3 %} disabled {% endif %} "
>
删除
</a>
{% else %}
<a
href=
"../dept_edit/?id={{ dept.id }}"
class=
"btn btn-xs btn-info disabled"
>
编辑
</a>
<a
href=
"../dept_del/?id={{ dept.id }}"
class=
"btn btn-xs btn-danger disabled"
>
删除
</a>
...
...
templates/juser/user_detail.html
View file @
c1d8de45
...
...
@@ -74,7 +74,7 @@
<table
class=
"table"
>
{% for group in user.group.all %}
<tr>
<td>
{{ group.name }}
</td>
<td>
<a
href=
"/jperm/perm_edit/?id={{ group.id }}"
>
{{ group.name }}
</a>
</td>
</tr>
{% endfor %}
</table>
...
...
@@ -152,7 +152,6 @@
</div>
</div>
<div
class=
"ibox-content"
>
<div
id=
"last"
>
<div
class=
"feed-activity-list"
>
{% for log in logs_last %}
...
...
@@ -168,19 +167,17 @@
</div>
{% endfor %}
{% if not logs_last %}
(无)
(
暂
无)
{% endif %}
</div>
{% if logs_num > 10 %}
<button
id=
"show"
class=
"btn btn-primary btn-block m-t"
><i
class=
"fa fa-arrow-down"
></i>
Show All
</button>
{% endif %}
</div>
<div
id=
"all"
style=
"display: none"
>
<div
class=
"feed-activity-list"
>
{% for log in logs_all %}
<div
class=
"feed-element"
>
<a
href=
"profile.html"
class=
"pull-left"
>
<img
alt=
"image"
class=
"img-circle"
src=
"/static/img/{{ session_role_id | to_avatar }}.png"
>
...
...
@@ -189,10 +186,8 @@
<small
class=
"pull-right"
>
{{ log.start_time|time_delta }}
</small>
<strong>
{{ log.user }}
</strong>
登录了
<span
class=
"text-navy"
>
{{ log.host }}.
</span><br>
<small
class=
"text-muted"
>
{{ log.start_time|date:"Y-m-d H:i:s" }}
</small>
</div>
</div>
{% endfor %}
</div>
...
...
templates/nav.html
View file @
c1d8de45
...
...
@@ -35,7 +35,7 @@
<a
href=
"/jperm/dept_perm_list/"
>
部门授权
</a>
</li>
<li
class=
"perm_list perm_edit "
>
<li
class=
"perm_list perm_edit
perm_detail
"
>
<a
href=
"/jperm/perm_list/"
>
小组授权
</a>
</li>
...
...
@@ -87,7 +87,7 @@
<li
id=
"jperm"
>
<a
href=
"#"
><i
class=
"fa fa-edit"
></i>
<span
class=
"nav-label"
>
授权管理
</span><span
class=
"fa arrow"
></span></a>
<ul
class=
"nav nav-second-level"
>
<li
class=
"perm_list perm_edit"
>
<li
class=
"perm_list perm_edit
perm_detail
"
>
<a
href=
"/jperm/perm_list/"
>
小组授权
</a>
</li>
...
...
templates/success.html
View file @
c1d8de45
...
...
@@ -25,7 +25,7 @@
<div
class=
"error-desc"
>
The server success response the request. Congratulations.
<br/>
You can go back to main page:
<br/><a
href=
"/"
class=
"btn btn-primary m-t"
>
仪表盘
</a>
You can go back to main page:
<br/><a
href=
"/"
class=
"btn btn-primary m-t"
>
首页
</a>
</div>
</div>
...
...
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