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
e65cad50
Commit
e65cad50
authored
9 years ago
by
ibuler
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' of git.coding.net:jumpserver/jumpserver into dev
parents
affd9aad
b0f2b346
master
auditor_jym
audits
dev
dev_beta
dev_beta_db
gengmei
lagacy-0.4.0
node_service
password
rbac
restrict_access
test
v52
wph
1.5.2
1.5.1
1.5.0
1.4.10
1.4.9
1.4.8
1.4.7
1.4.6
1.4.5
1.4.4
1.4.3
1.4.2
1.4.1
1.4.0
1.3.3
1.3.2
1.3.1
1.3.0
1.2.1
1.2.0
1.1.1
1.1.0
1.0.0
0.3.3
0.3.2
0.3.2-rc2
0.3.1
0.3.0-beta
v1.4.10
v1.4.7
v1.4.4
No related merge requests found
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
92 additions
and
57 deletions
+92
-57
perm_api.py
jperm/perm_api.py
+10
-10
views.py
jperm/views.py
+11
-6
jumpserver.conf
jumpserver.conf
+1
-1
perm_role_detail.html
templates/jperm/perm_role_detail.html
+35
-17
perm_rule_detail.html
templates/jperm/perm_rule_detail.html
+34
-21
perm_rule_list.html
templates/jperm/perm_rule_list.html
+1
-2
No files found.
jperm/perm_api.py
View file @
e65cad50
...
...
@@ -259,23 +259,23 @@ def get_role_info(role_id, type="all"):
asset_groups_obj
.
append
(
asset_group
)
if
type
==
"all"
:
return
{
"rules"
:
rule_push_obj
,
"users"
:
users_obj
,
"user_groups"
:
user_groups_obj
,
"assets"
:
assets_obj
,
"asset_groups"
:
asset_groups_obj
,
return
{
"rules"
:
set
(
rule_push_obj
)
,
"users"
:
set
(
users_obj
)
,
"user_groups"
:
set
(
user_groups_obj
)
,
"assets"
:
set
(
assets_obj
)
,
"asset_groups"
:
set
(
asset_groups_obj
)
,
}
elif
type
==
"rule"
:
return
rule_push_obj
return
set
(
rule_push_obj
)
elif
type
==
"user"
:
return
users_obj
return
set
(
users_obj
)
elif
type
==
"user_group"
:
return
user_groups_obj
return
set
(
user_groups_obj
)
elif
type
==
"asset"
:
return
assets_obj
return
set
(
assets_obj
)
elif
type
==
"asset_group"
:
return
asset_groups_obj
return
set
(
asset_groups_obj
)
else
:
return
u"不支持的查询"
...
...
This diff is collapsed.
Click to expand it.
jperm/views.py
View file @
e65cad50
...
...
@@ -23,6 +23,7 @@ logger = set_log(LOG_LEVEL, filename='jumpserver_perm.log')
def
perm_rule_list
(
request
):
"""
list rule page
授权规则列表
"""
# 渲染数据
header_title
,
path1
,
path2
=
"授权规则"
,
"规则管理"
,
"查看规则"
...
...
@@ -46,6 +47,7 @@ def perm_rule_list(request):
def
perm_rule_detail
(
request
):
"""
rule detail page
授权详情
"""
# 渲染数据
header_title
,
path1
,
path2
=
"授权规则"
,
"规则管理"
,
"规则详情"
...
...
@@ -54,14 +56,18 @@ def perm_rule_detail(request):
rule_id
=
request
.
GET
.
get
(
"id"
)
rule_obj
=
PermRule
.
objects
.
get
(
id
=
rule_id
)
user_obj
=
rule_obj
.
user
.
all
()
user_group_obj
=
rule_obj
.
user_group
.
all
()
asset_obj
=
rule_obj
.
asset
.
all
()
asset_group_obj
=
rule_obj
.
asset_group
.
all
()
roles_name
=
[
role
.
name
for
role
in
rule_obj
.
role
.
all
()]
# 渲染数据
roles_name
=
','
.
join
(
roles_name
)
rule
=
rule_obj
users
=
user_obj
user_groups
=
user_group_obj
assets
=
asset_obj
asset_groups
=
asset_group_obj
return
my_render
(
'jperm/perm_rule_detail.html'
,
locals
(),
request
)
...
...
@@ -69,6 +75,7 @@ def perm_rule_detail(request):
def
perm_rule_add
(
request
):
"""
add rule page
添加授权
"""
# 渲染数据
header_title
,
path1
,
path2
=
"授权规则"
,
"规则管理"
,
"添加规则"
...
...
@@ -116,8 +123,8 @@ def perm_rule_add(request):
need_push_asset
=
set
()
for
role
in
roles_obj
:
asset_no_push
=
get_role_push_host
(
role
=
role
)[
0
]
# 获取某角色已经推送的资产
need_push_asset
.
update
(
set
(
calc_assets
)
-
set
(
asset_no_push
))
asset_no_push
=
get_role_push_host
(
role
=
role
)[
1
]
# 获取某角色已经推送的资产
need_push_asset
.
update
(
set
(
calc_assets
)
&
set
(
asset_no_push
))
if
need_push_asset
:
raise
ServerError
(
u'没有推送角色
%
s 的主机
%
s'
%
(
role
.
name
,
','
.
join
([
asset
.
hostname
for
asset
in
need_push_asset
])))
...
...
@@ -183,15 +190,13 @@ def perm_rule_edit(request):
# 获取需要授权的用户列表
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
(
id
=
role_id
)
for
role_id
in
roles_select
]
need_push_asset
=
set
()
for
role
in
roles_obj
:
asset_no_push
=
get_role_push_host
(
role
=
role
)[
0
]
# 获取某角色已经推送的资产
need_push_asset
.
update
(
set
(
calc_assets
)
-
set
(
asset_no_push
))
asset_no_push
=
get_role_push_host
(
role
=
role
)[
1
]
# 获取某角色已经推送的资产
need_push_asset
.
update
(
set
(
calc_assets
)
&
set
(
asset_no_push
))
if
need_push_asset
:
raise
ServerError
(
u'没有推送角色
%
s 的主机
%
s'
%
(
role
.
name
,
','
.
join
([
asset
.
hostname
for
asset
in
need_push_asset
])))
...
...
This diff is collapsed.
Click to expand it.
jumpserver.conf
View file @
e65cad50
...
...
@@ -13,7 +13,7 @@ password = mysql234
database
=
jumpserver
[
websocket
]
web_socket_host
=
j
:
3000
web_socket_host
=
127
.
0
.
0
.
1
:
3000
[
mail
]
mail_enable
=
1
...
...
This diff is collapsed.
Click to expand it.
templates/jperm/perm_role_detail.html
View file @
e65cad50
...
...
@@ -41,7 +41,7 @@
{% for rule in rules %}
<tr
class=
"gradeX"
>
<td
class=
"text-center"
>
{{ rule.date_added | date:"Y-m-d H:i:s"}}
</td>
<td
class=
"text-center"
>
{{ rule.name }}
</td>
<td
class=
"text-center"
>
<a
href=
"/jperm/perm_rule_detail/?id={{ rule.id }}"
>
{{ rule.name }}
</a>
</td>
</tr>
{% endfor %}
</tbody>
...
...
@@ -54,7 +54,7 @@
<div
class=
"col-sm-4"
>
<div
class=
"ibox float-e-margins"
>
<div
class=
"ibox-title"
>
<span
class=
"label label-primary"
><b>
{{ role.name }} -
授权用户/用户组
</b></span>
<span
class=
"label label-primary"
><b>
授权用户/用户组
</b></span>
<div
class=
"ibox-tools"
>
<a
class=
"collapse-link"
>
<i
class=
"fa fa-chevron-up"
></i>
...
...
@@ -74,25 +74,39 @@
</div>
</div>
<div
class=
"ibox-content"
>
<div>
<div
class=
"text-left"
>
<div
class=
"text-center"
style=
"float: left;"
>
<table
class=
"table table-striped"
id=
"ugedit"
>
<thead>
<tr>
<th
class=
"text-center"
>
用户
</th>
<th
class=
"text-center"
>
用户组
</th>
</tr>
</thead>
<tbody>
{% for user in users %}
<tr
class=
"gradeX"
>
<td
class=
"text-center"
>
{{ user.name }}
</td>
<td
class=
"text-center"
>
{{ user | user_which_groups:"group" }}
</td>
<td
class=
"text-center"
>
<a
href=
"/juser/user_detail/?id={{ user.id }}"
>
{{ user.name }}
</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<div
class=
"text-center"
style=
"float: right;"
>
<table
class=
"table table-striped"
id=
"ugedit"
>
<thead>
<tr>
<th
class=
"text-center"
>
用户组
</th>
</tr>
</thead>
<tbody>
{% for group in user_groups %}
<tr
class=
"gradeX"
>
<td
class=
"text-center"
>
<a
href=
"/juser/user_list/?gid={{ group.id }}"
>
{{ group.name }}
</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
...
...
@@ -100,7 +114,7 @@
<div
class=
"col-sm-4"
>
<div
class=
"ibox float-e-margins"
>
<div
class=
"ibox-title"
>
<span
class=
"label label-primary"
><b>
{{ role.name }} -
授权主机/主机组
</b></span>
<span
class=
"label label-primary"
><b>
授权主机/主机组
</b></span>
<div
class=
"ibox-tools"
>
<a
class=
"collapse-link"
>
<i
class=
"fa fa-chevron-up"
></i>
...
...
@@ -120,25 +134,29 @@
</div>
</div>
<div
class=
"ibox-content"
>
<div>
<div
class=
"text-left"
>
<div
class=
"text-center"
style=
"float:left;"
>
<table
class=
"table table-striped"
id=
"agedit"
>
<thead>
<tr>
<th
class=
"text-center"
>
主机
</th>
<th
class=
"text-center"
>
主机组
</th>
</tr>
</thead>
<tbody>
{% for asset in assets %}
<tr
class=
"gradeX"
>
<td
class=
"text-center"
>
{{ asset.ip }}
</td>
<td
class=
"text-center"
>
{{ asset | asset_which_groups:"group" }}
</td>
<td
class=
"text-center"
>
<a
href=
"/jasset/asset_detail/?id={{ asset.id }}"
>
{{ asset.ip }}
</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<div
class=
"text-center"
style=
"float:right;"
>
<table
class=
"table table-striped"
id=
"agedit"
>
<tr>
<th
class=
"text-center"
>
主机组
</th>
</tr>
{% for group in asset_groups %}
<tr
class=
"gradeX"
>
<td
class=
"text-center"
>
<a
href=
"/jasset/asset_list/?group_id={{ group.id }}"
>
{{ group.name }}
</a>
</td>
</tr>
{% endfor %}
</table>
</div>
</div>
</div>
...
...
This diff is collapsed.
Click to expand it.
templates/jperm/perm_rule_detail.html
View file @
e65cad50
...
...
@@ -83,32 +83,43 @@
</div>
</div>
<div
class=
"ibox-content"
>
<div>
<div
class=
"text-left"
>
<div
class=
"text-center"
style=
"float: left;"
>
<table
class=
"table table-striped"
id=
"ugedit"
>
<thead>
<tr>
<th
class=
"text-center"
>
用户
</th>
<th
class=
"text-center"
>
用户组
</th>
</tr>
</thead>
<tbody>
<tr
class=
"gradeX"
>
{% for user in users %}
<td
class=
"text-center"
>
{{ user.name }}
</td>
{% endfor %}
{% for group in user_groups %}
<td
class=
"text-center"
>
{{ group.name }}
</td>
<tr
class=
"gradeX"
>
<td
class=
"text-center"
>
<a
href=
"/juser/user_detail/?id={{ user.id }}"
>
{{ user.name }}
</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<div
class=
"text-center"
style=
"float: right;"
>
<table
class=
"table table-striped"
id=
"ugedit"
>
<thead>
<tr>
<th
class=
"text-center"
>
用户组
</th>
</tr>
</thead>
<tbody>
{% for group in user_groups %}
<tr
class=
"gradeX"
>
<td
class=
"text-center"
>
<a
href=
"/juser/user_list/?gid={{ group.id }}"
>
{{ group.name }}
</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<div
class=
"col-sm-4"
>
<div
class=
"ibox float-e-margins"
>
<div
class=
"ibox-title"
>
...
...
@@ -132,25 +143,28 @@
</div>
</div>
<div
class=
"ibox-content"
>
<div>
<div
class=
"text-left"
>
<div
class=
"text-center"
style=
"float:left;"
>
<table
class=
"table table-striped"
id=
"agedit"
>
<thead>
<tr>
<th
class=
"text-center"
>
主机
</th>
<th
class=
"text-center"
>
主机组
</th>
</tr>
</thead>
<tbody>
<tr
class=
"gradeX"
>
{% for asset in assets %}
<td
class=
"text-center"
>
{{ asset.ip }}
</td>
<tr
class=
"gradeX"
>
<td
class=
"text-center"
>
<a
href=
"/jasset/asset_detail/?id={{ asset.id }}"
>
{{ asset.ip }}
</a>
</td>
</tr>
{% endfor %}
</table>
</div>
<div
class=
"text-center"
style=
"float:right;"
>
<table
class=
"table table-striped"
id=
"agedit"
>
<tr>
<th
class=
"text-center"
>
主机组
</th>
</tr>
{% for group in asset_groups %}
<td
class=
"text-center"
>
{{ group.name }}
</td
>
{% endfor %}
<tr
class=
"gradeX"
>
<td
class=
"text-center"
>
<a
href=
"/jasset/asset_list/?group_id={{ group.id }}"
>
{{ group.name }}
</a>
</td>
</tr>
</tbody>
{% endfor %}
</table>
</div>
</div>
...
...
@@ -158,7 +172,6 @@
</div>
</div>
</div>
</div>
<script>
$
(
document
).
ready
(
function
(){
...
...
This diff is collapsed.
Click to expand it.
templates/jperm/perm_rule_list.html
View file @
e65cad50
...
...
@@ -62,7 +62,7 @@
<tbody
id=
"edittbody"
>
{% for rule in rules %}
<tr
class=
"gradeX"
id=
{{
rule
.
id
}}
>
<td
class=
"text-center"
>
{{ rule.name }}
</td>
<td
class=
"text-center"
>
<a
href=
"/jperm/perm_rule_detail/?id={{ rule.id }}"
>
{{ rule.name }}
</a>
</td>
<td
class=
"text-center"
>
{{ rule | rule_member_count:"user" }}
</td>
...
...
@@ -79,7 +79,6 @@
{{ rule | rule_member_count:"role" }}
</td>
<td
class=
"text-center"
>
<a
href=
"/jperm/perm_rule_detail/?id={{ rule.id }}"
class=
"btn btn-xs btn-primary"
>
详情
</a>
<a
href=
"/jperm/perm_rule_edit/?id={{ rule.id }}"
class=
"btn btn-xs btn-info"
>
编辑
</a>
<button
onclick=
"remove_rule({{ rule.id }})"
class=
"btn btn-xs btn-danger"
>
删除
</button>
</td>
...
...
This diff is collapsed.
Click to expand it.
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