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
e14bbb26
Unverified
Commit
e14bbb26
authored
Aug 08, 2019
by
老广
Committed by
GitHub
Aug 08, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3093 from jumpserver/allow_show_all_nodes
[Update] 控制是否显示未分组节点
parents
c3a206b2
6b56c43a
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
23 additions
and
1 deletion
+23
-1
utils.py
apps/authentication/utils.py
+1
-1
conf.py
apps/jumpserver/conf.py
+1
-0
settings.py
apps/jumpserver/settings.py
+2
-0
asset_permission.py
apps/perms/utils/asset_permission.py
+15
-0
config_example.yml
config_example.yml
+4
-0
No files found.
apps/authentication/utils.py
View file @
e14bbb26
...
...
@@ -7,7 +7,7 @@ from common.utils import get_ip_city, validate_ip
def
write_login_log
(
*
args
,
**
kwargs
):
from
audits.models
import
UserLoginLog
default_city
=
_
(
"Unknown"
)
ip
=
kwargs
.
get
(
'ip'
,
''
)
ip
=
kwargs
.
get
(
'ip'
)
or
''
if
not
(
ip
and
validate_ip
(
ip
)):
ip
=
ip
[:
15
]
city
=
default_city
...
...
apps/jumpserver/conf.py
View file @
e14bbb26
...
...
@@ -379,6 +379,7 @@ defaults = {
'ASSETS_PERM_CACHE_TIME'
:
3600
*
24
,
'SECURITY_MFA_VERIFY_TTL'
:
3600
,
'ASSETS_PERM_CACHE_ENABLE'
:
False
,
'PERM_SINGLE_ASSET_TO_UNGROUP_NODE'
:
False
,
}
...
...
apps/jumpserver/settings.py
View file @
e14bbb26
...
...
@@ -615,3 +615,5 @@ ASSETS_PERM_CACHE_TIME = CONFIG.ASSETS_PERM_CACHE_TIME
# Asset user auth external backend, default AuthBook backend
BACKEND_ASSET_USER_AUTH_VAULT
=
False
PERM_SINGLE_ASSET_TO_UNGROUP_NODE
=
CONFIG
.
PERM_SINGLE_ASSET_TO_UNGROUP_NODE
apps/perms/utils/asset_permission.py
View file @
e14bbb26
...
...
@@ -180,6 +180,19 @@ class GenerateTree:
assets
.
append
({
"id"
:
asset_id
,
"system_users"
:
system_users
})
return
assets
def
set_ungrouped_assets_nodes_if_need
(
self
):
if
settings
.
PERM_SINGLE_ASSET_TO_UNGROUP_NODE
:
return
ungrouped_assets_ids
=
self
.
nodes
[
self
.
ungrouped_key
][
"assets"
]
for
asset_id
in
ungrouped_assets_ids
:
in_nodes
=
self
.
all_assets_nodes_keys
.
get
(
asset_id
,
[])
for
node_key
in
in_nodes
:
parents_keys
=
self
.
node_util
.
get_nodes_parents_keys_by_key
(
node_key
,
with_self
=
False
)
for
parent_key
in
parents_keys
:
n
=
self
.
nodes
[
parent_key
]
self
.
nodes
[
node_key
][
"assets"
]
.
add
(
asset_id
)
self
.
nodes
.
pop
(
self
.
ungrouped_key
,
None
)
@timeit
def
get_nodes_with_assets
(
self
):
"""
...
...
@@ -198,6 +211,7 @@ class GenerateTree:
"""
if
self
.
_nodes_with_assets
:
return
self
.
_nodes_with_assets
self
.
set_ungrouped_assets_nodes_if_need
()
util
=
PermAssetsAmountUtil
()
nodes_with_assets_amount
=
util
.
compute_nodes_assets_amount
(
self
.
nodes
)
nodes
=
[]
...
...
@@ -219,6 +233,7 @@ class GenerateTree:
return
nodes
def
get_nodes
(
self
):
self
.
set_ungrouped_assets_nodes_if_need
()
nodes
=
list
(
self
.
nodes
.
keys
())
if
not
nodes
:
nodes
.
append
(
const
.
EMPTY_NODE_KEY
)
...
...
config_example.yml
View file @
e14bbb26
...
...
@@ -76,3 +76,7 @@ REDIS_PORT: 6379
# OTP/MFA 配置
# OTP_VALID_WINDOW: 0
# OTP_ISSUER_NAME: Jumpserver
# Perm show single asset to ungrouped node
# 是否把未授权节点资产放入到 未分组 节点中
# PERM_SINGLE_ASSET_TO_UNGROUP_NODE: false
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