Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
gjl2004yn
jumpserver
提交
3e86c074
J
jumpserver
项目概览
gjl2004yn
/
jumpserver
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
jumpserver
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3e86c074
编写于
6月 12, 2019
作者:
baltery
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Update] 修改授权节点显示
上级
44d33f70
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
83 addition
and
48 deletion
+83
-48
apps/assets/models/node.py
apps/assets/models/node.py
+1
-1
apps/locale/zh/LC_MESSAGES/django.mo
apps/locale/zh/LC_MESSAGES/django.mo
+0
-0
apps/locale/zh/LC_MESSAGES/django.po
apps/locale/zh/LC_MESSAGES/django.po
+27
-26
apps/perms/api/user_group_permission.py
apps/perms/api/user_group_permission.py
+5
-2
apps/perms/api/user_permission.py
apps/perms/api/user_permission.py
+10
-4
apps/perms/const.py
apps/perms/const.py
+2
-0
apps/perms/utils/asset_permission.py
apps/perms/utils/asset_permission.py
+38
-15
未找到文件。
apps/assets/models/node.py
浏览文件 @
3e86c074
...
...
@@ -37,7 +37,7 @@ class Node(OrgModelMixin):
def
__eq__
(
self
,
other
):
if
not
other
:
return
False
return
self
.
key
==
other
.
key
return
self
.
id
==
other
.
id
def
__gt__
(
self
,
other
):
if
self
.
is_root
()
and
not
other
.
is_root
():
...
...
apps/locale/zh/LC_MESSAGES/django.mo
浏览文件 @
3e86c074
无法预览此类型文件
apps/locale/zh/LC_MESSAGES/django.po
浏览文件 @
3e86c074
...
...
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Jumpserver 0.3.3\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-06-1
1 11:3
9+0800\n"
"POT-Creation-Date: 2019-06-1
2 16:5
9+0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: ibuler <ibuler@qq.com>\n"
"Language-Team: Jumpserver team<ibuler@qq.com>\n"
...
...
@@ -110,7 +110,7 @@ msgstr "资产"
#: applications/templates/applications/remote_app_detail.html:61
#: applications/templates/applications/remote_app_list.html:23
#: applications/templates/applications/user_remote_app_list.html:19
#: assets/models/user.py:247 assets/templates/assets/user_asset_list.html:1
68
#: assets/models/user.py:247 assets/templates/assets/user_asset_list.html:1
72
#: audits/models.py:20 audits/templates/audits/ftp_log_list.html:49
#: audits/templates/audits/ftp_log_list.html:72
#: perms/forms/asset_permission.py:52 perms/models/asset_permission.py:39
...
...
@@ -271,7 +271,7 @@ msgstr "创建日期"
#: assets/templates/assets/domain_list.html:28
#: assets/templates/assets/system_user_detail.html:104
#: assets/templates/assets/system_user_list.html:59
#: assets/templates/assets/user_asset_list.html:17
1
ops/models/adhoc.py:43
#: assets/templates/assets/user_asset_list.html:17
5
ops/models/adhoc.py:43
#: orgs/models.py:17 perms/models/asset_permission.py:64
#: perms/models/base.py:43
#: perms/templates/perms/asset_permission_detail.html:102
...
...
@@ -563,8 +563,8 @@ msgstr "连接"
#: assets/views/admin_user.py:29 assets/views/admin_user.py:47
#: assets/views/admin_user.py:63 assets/views/admin_user.py:78
#: assets/views/admin_user.py:102 assets/views/asset.py:53
#: assets/views/asset.py:69 assets/views/asset.py:10
6 assets/views/asset.py:147
#: assets/views/asset.py:16
4 assets/views/asset.py:188
#: assets/views/asset.py:69 assets/views/asset.py:10
7 assets/views/asset.py:148
#: assets/views/asset.py:16
5 assets/views/asset.py:189
#: assets/views/cmd_filter.py:30 assets/views/cmd_filter.py:46
#: assets/views/cmd_filter.py:62 assets/views/cmd_filter.py:78
#: assets/views/cmd_filter.py:97 assets/views/cmd_filter.py:130
...
...
@@ -643,7 +643,7 @@ msgstr "标签"
#: assets/forms/asset.py:37 assets/forms/asset.py:73 assets/models/asset.py:79
#: assets/models/domain.py:26 assets/models/domain.py:52
#: assets/templates/assets/asset_detail.html:84
#: assets/templates/assets/user_asset_list.html:1
69
#: assets/templates/assets/user_asset_list.html:1
73
#: xpack/plugins/orgs/templates/orgs/org_list.html:17
msgid "Domain"
msgstr "网域"
...
...
@@ -807,7 +807,7 @@ msgstr "使用逗号分隔多个命令,如: /bin/whoami,/sbin/ifconfig"
#: assets/templates/assets/domain_gateway_list.html:68
#: assets/templates/assets/system_user_asset.html:51
#: assets/templates/assets/user_asset_list.html:45
#: assets/templates/assets/user_asset_list.html:16
3
#: assets/templates/assets/user_asset_list.html:16
7
#: audits/templates/audits/login_log_list.html:54
#: perms/templates/perms/asset_permission_asset.html:55 settings/forms.py:133
#: users/templates/users/user_granted_asset.html:45
...
...
@@ -824,7 +824,7 @@ msgstr "IP"
#: assets/templates/assets/asset_list.html:104
#: assets/templates/assets/system_user_asset.html:50
#: assets/templates/assets/user_asset_list.html:44
#: assets/templates/assets/user_asset_list.html:16
2
#: assets/templates/assets/user_asset_list.html:16
6
#: perms/templates/perms/asset_permission_asset.html:54
#: perms/templates/perms/asset_permission_list.html:77 settings/forms.py:132
#: users/templates/users/user_granted_asset.html:44
...
...
@@ -838,7 +838,7 @@ msgstr "主机名"
#: assets/templates/assets/domain_gateway_list.html:70
#: assets/templates/assets/system_user_detail.html:70
#: assets/templates/assets/system_user_list.html:53
#: assets/templates/assets/user_asset_list.html:16
5
#: assets/templates/assets/user_asset_list.html:16
9
#: terminal/templates/terminal/session_list.html:75
msgid "Protocol"
msgstr "协议"
...
...
@@ -848,20 +848,20 @@ msgstr "协议"
#: assets/templates/assets/asset_detail.html:72
#: assets/templates/assets/domain_gateway_list.html:69
#: assets/templates/assets/system_user_asset.html:52
#: assets/templates/assets/user_asset_list.html:16
4
#: assets/templates/assets/user_asset_list.html:16
8
#: settings/templates/settings/replay_storage_create.html:59
msgid "Port"
msgstr "端口"
#: assets/models/asset.py:78 assets/templates/assets/asset_detail.html:108
#: assets/templates/assets/user_asset_list.html:1
66
#: assets/templates/assets/user_asset_list.html:1
70
msgid "Platform"
msgstr "系统平台"
#: assets/models/asset.py:81 assets/models/cmd_filter.py:21
#: assets/models/domain.py:54 assets/models/label.py:22
#: assets/templates/assets/asset_detail.html:116
#: assets/templates/assets/user_asset_list.html:17
0
#: assets/templates/assets/user_asset_list.html:17
4
msgid "Is active"
msgstr "激活"
...
...
@@ -915,7 +915,7 @@ msgid "Disk info"
msgstr "硬盘信息"
#: assets/models/asset.py:103 assets/templates/assets/asset_detail.html:112
#: assets/templates/assets/user_asset_list.html:1
67
#: assets/templates/assets/user_asset_list.html:1
71
msgid "OS"
msgstr "操作系统"
...
...
@@ -1015,6 +1015,7 @@ msgid "Operator"
msgstr "运营商"
#: assets/models/cluster.py:36 assets/models/group.py:34
#: perms/utils/asset_permission.py:63
msgid "Default"
msgstr "默认"
...
...
@@ -1160,7 +1161,7 @@ msgstr "分类"
msgid "Key"
msgstr "键"
#: assets/models/node.py:13
3
#: assets/models/node.py:13
9
msgid "New node"
msgstr "新节点"
...
...
@@ -1475,7 +1476,7 @@ msgstr "更新系统用户"
#: assets/templates/assets/_user_asset_detail_modal.html:11
#: assets/templates/assets/asset_asset_user_list.html:13
#: assets/templates/assets/asset_detail.html:20 assets/views/asset.py:1
89
#: assets/templates/assets/asset_detail.html:20 assets/views/asset.py:1
90
msgid "Asset detail"
msgstr "资产详情"
...
...
@@ -1695,7 +1696,7 @@ msgstr ""
"左侧是资产树,右击可以新建、删除、更改树节点,授权资产也是以节点方式组织的,"
"右侧是属于该节点下的资产"
#: assets/templates/assets/asset_list.html:69 assets/views/asset.py:10
7
#: assets/templates/assets/asset_list.html:69 assets/views/asset.py:10
8
msgid "Create asset"
msgstr "创建资产"
...
...
@@ -2042,19 +2043,19 @@ msgstr "管理用户详情"
msgid "My assets"
msgstr "我的资产"
#: assets/views/asset.py:12
1
#: assets/views/asset.py:12
2
msgid "Bulk update asset success"
msgstr "批量更新资产成功"
#: assets/views/asset.py:14
8
#: assets/views/asset.py:14
9
msgid "Bulk update asset"
msgstr "批量更新资产"
#: assets/views/asset.py:16
5
#: assets/views/asset.py:16
6
msgid "Update asset"
msgstr "更新资产"
#: assets/views/asset.py:30
6
#: assets/views/asset.py:30
7
msgid "already exists"
msgstr "已经存在"
...
...
@@ -2961,7 +2962,7 @@ msgstr "执行历史"
msgid "Command execution list"
msgstr "命令执行列表"
#: ops/views/command.py:69 templates/_nav_user.html:2
1
#: ops/views/command.py:69 templates/_nav_user.html:2
2
msgid "Command execution"
msgstr "命令执行"
...
...
@@ -3778,7 +3779,7 @@ msgstr "文档"
msgid "Commercial support"
msgstr "商业支持"
#: templates/_header_bar.html:89 templates/_nav_user.html:2
6
users/forms.py:138
#: templates/_header_bar.html:89 templates/_nav_user.html:2
8
users/forms.py:138
#: users/templates/users/_user.html:43
#: users/templates/users/first_login.html:39
#: users/templates/users/user_password_update.html:40
...
...
@@ -3913,11 +3914,11 @@ msgstr "历史会话"
msgid "Commands"
msgstr "命令记录"
#: templates/_nav.html:63 templates/_nav_user.html:3
1
#: templates/_nav.html:63 templates/_nav_user.html:3
3
msgid "Web terminal"
msgstr "Web终端"
#: templates/_nav.html:68 templates/_nav_user.html:3
6
#: templates/_nav.html:68 templates/_nav_user.html:3
8
msgid "File manager"
msgstr "文件管理"
...
...
@@ -4331,11 +4332,11 @@ msgid ""
"You should use your ssh client tools connect terminal: {} <br /> <br />{}"
msgstr "你可以使用ssh客户端工具连接终端"
#: users/api/user.py:7
5 users/api/user.py:86 users/api/user.py:112
#: users/api/user.py:7
8 users/api/user.py:89 users/api/user.py:115
msgid "You do not have permission."
msgstr "你没有权限"
#: users/api/user.py:21
6
#: users/api/user.py:21
9
msgid "Could not reset self otp, use profile reset instead"
msgstr "不能再该页面重置MFA, 请去个人信息页面重置"
...
...
apps/perms/api/user_group_permission.py
浏览文件 @
3e86c074
...
...
@@ -17,7 +17,7 @@ from ..hands import (
AssetGrantedSerializer
,
UserGroup
,
Node
,
NodeSerializer
,
RemoteAppSerializer
,
)
from
..
import
serializers
from
..
import
serializers
,
const
__all__
=
[
...
...
@@ -134,8 +134,11 @@ class UserGroupGrantedNodeAssetsApi(ListAPIView):
node_id
=
self
.
kwargs
.
get
(
'node_id'
)
user_group
=
get_object_or_404
(
UserGroup
,
id
=
user_group_id
)
node
=
get_object_or_404
(
Node
,
id
=
node_id
)
util
=
AssetPermissionUtil
(
user_group
)
if
str
(
node_id
)
==
const
.
UNGROUPED_NODE_ID
:
node
=
util
.
tree
.
ungrouped_node
else
:
node
=
get_object_or_404
(
Node
,
id
=
node_id
)
nodes
=
util
.
get_nodes_with_assets
()
assets
=
nodes
.
get
(
node
,
[])
for
asset
,
system_users
in
assets
.
items
():
...
...
apps/perms/api/user_permission.py
浏览文件 @
3e86c074
...
...
@@ -24,7 +24,7 @@ from ..hands import (
User
,
Asset
,
Node
,
SystemUser
,
RemoteApp
,
AssetGrantedSerializer
,
NodeSerializer
,
RemoteAppSerializer
,
)
from
..
import
serializers
from
..
import
serializers
,
const
from
..mixins
import
AssetsFilterMixin
,
RemoteAppFilterMixin
from
..models
import
Action
...
...
@@ -300,9 +300,15 @@ class UserGrantedNodeAssetsApi(UserPermissionCacheMixin, AssetsFilterMixin, List
user
=
self
.
get_object
()
node_id
=
self
.
kwargs
.
get
(
'node_id'
)
util
=
AssetPermissionUtil
(
user
,
cache_policy
=
self
.
cache_policy
)
node
=
get_object_or_404
(
Node
,
id
=
node_id
)
nodes
=
util
.
get_nodes_with_assets
()
assets
=
nodes
.
get
(
node
,
[])
if
str
(
node_id
)
==
const
.
UNGROUPED_NODE_ID
:
node
=
util
.
tree
.
ungrouped_node
else
:
node
=
get_object_or_404
(
Node
,
id
=
node_id
)
if
node
==
util
.
tree
.
root_node
:
assets
=
util
.
get_assets
()
else
:
nodes
=
util
.
get_nodes_with_assets
()
assets
=
nodes
.
get
(
node
,
[])
for
asset
,
system_users
in
assets
.
items
():
asset
.
system_users_granted
=
system_users
...
...
apps/perms/const.py
浏览文件 @
3e86c074
...
...
@@ -20,3 +20,5 @@ PERMS_ACTION_NAME_CHOICES = (
(
PERMS_ACTION_NAME_UPLOAD_FILE
,
_
(
'Upload file'
)),
(
PERMS_ACTION_NAME_DOWNLOAD_FILE
,
_
(
'Download file'
)),
)
UNGROUPED_NODE_ID
=
"00000000-0000-0000-0000-000000000000"
apps/perms/utils/asset_permission.py
浏览文件 @
3e86c074
...
...
@@ -9,11 +9,13 @@ from django.utils import timezone
from
django.db.models
import
Q
from
django.core.cache
import
cache
from
django.conf
import
settings
from
django.utils.translation
import
ugettext
as
_
from
common.utils
import
get_logger
from
common.tree
import
TreeNode
from
perms.models
import
AssetPermission
,
Action
from
perms.hands
import
Node
from
..
import
const
from
..models
import
AssetPermission
,
Action
from
..hands
import
Node
logger
=
get_logger
(
__file__
)
...
...
@@ -34,24 +36,43 @@ class GenerateTree:
"""
self
.
__all_nodes
=
list
(
Node
.
objects
.
all
())
self
.
nodes
=
defaultdict
(
dict
)
self
.
direct_nodes
=
[]
self
.
_root_node
=
None
self
.
_ungroup_node
=
None
@
property
def
root_node
(
self
):
if
self
.
_root_node
:
return
self
.
_root_node
all_nodes
=
self
.
nodes
.
keys
()
# 如果没有授权节点,就放到默认的根节点下
if
not
all_nodes
:
root_node
=
Node
.
root
()
self
.
add_node
(
root_node
)
else
:
root_node
=
max
(
all_nodes
)
self
.
_root_node
=
root_node
return
root_node
@
property
def
ungrouped_node
(
self
):
if
self
.
_ungroup_node
:
return
self
.
_ungroup_node
node_id
=
const
.
UNGROUPED_NODE_ID
node_key
=
self
.
root_node
.
get_next_child_key
()
node_value
=
_
(
"Default"
)
node
=
Node
(
id
=
node_id
,
key
=
node_key
,
value
=
node_value
)
self
.
add_node
(
node
)
self
.
_ungroup_node
=
node
return
node
def
add_asset
(
self
,
asset
,
system_users
):
nodes
=
asset
.
nodes
.
all
()
in_nodes
=
False
for
node
in
nodes
:
if
node
not
in
self
.
nodes
:
continue
in_nodes
=
set
(
self
.
direct_nodes
)
&
set
(
nodes
)
for
node
in
in_nodes
:
self
.
nodes
[
node
][
asset
].
update
(
system_users
)
in_nodes
=
True
if
not
in_nodes
:
all_nodes
=
self
.
nodes
.
keys
()
# 如果没有授权节点,就放到默认的根节点下
if
not
all_nodes
:
root_node
=
Node
.
root
()
self
.
add_node
(
root_node
)
else
:
root_node
=
max
(
all_nodes
)
self
.
nodes
[
root_node
][
asset
].
update
(
system_users
)
self
.
nodes
[
self
.
ungrouped_node
][
asset
].
update
(
system_users
)
def
get_nodes
(
self
):
for
node
in
self
.
nodes
:
...
...
@@ -80,6 +101,8 @@ class GenerateTree:
for
node
in
nodes
:
self
.
add_node
(
node
)
self
.
add_nodes
(
node
.
get_all_children
(
with_self
=
False
))
# 如果是直接授权的节点,则放到direct_nodes中
self
.
direct_nodes
.
append
(
node
)
def
get_user_permissions
(
user
,
include_group
=
True
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录