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
844f9bf4
Unverified
Commit
844f9bf4
authored
Jun 20, 2019
by
BaiJiangJie
Committed by
GitHub
Jun 20, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2815 from jumpserver/master_bugfix
[Bugfix] 修复普通用户被授权的RemoteApp列表加载为空的bug
parents
41a5a691
c17d95da
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
13 deletions
+24
-13
user_group_permission.py
apps/perms/api/user_group_permission.py
+0
-7
user_permission.py
apps/perms/api/user_permission.py
+7
-4
mixins.py
apps/perms/mixins.py
+16
-1
api.py
apps/settings/api.py
+1
-1
No files found.
apps/perms/api/user_group_permission.py
View file @
844f9bf4
...
@@ -93,19 +93,12 @@ class UserGroupGrantedNodesWithAssetsAsTreeApi(ListAPIView):
...
@@ -93,19 +93,12 @@ class UserGroupGrantedNodesWithAssetsAsTreeApi(ListAPIView):
show_assets
=
True
show_assets
=
True
system_user_id
=
None
system_user_id
=
None
def
change_org_if_need
(
self
):
if
self
.
request
.
user
.
is_superuser
or
\
self
.
request
.
user
.
is_app
or
\
self
.
kwargs
.
get
(
'pk'
)
is
None
:
set_to_root_org
()
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
self
.
show_assets
=
request
.
query_params
.
get
(
'show_assets'
,
'1'
)
==
'1'
self
.
show_assets
=
request
.
query_params
.
get
(
'show_assets'
,
'1'
)
==
'1'
self
.
system_user_id
=
request
.
query_params
.
get
(
'system_user'
)
self
.
system_user_id
=
request
.
query_params
.
get
(
'system_user'
)
return
super
()
.
get
(
request
,
*
args
,
**
kwargs
)
return
super
()
.
get
(
request
,
*
args
,
**
kwargs
)
def
get_queryset
(
self
):
def
get_queryset
(
self
):
self
.
change_org_if_need
()
user_group_id
=
self
.
kwargs
.
get
(
'pk'
,
''
)
user_group_id
=
self
.
kwargs
.
get
(
'pk'
,
''
)
queryset
=
[]
queryset
=
[]
group
=
get_object_or_404
(
UserGroup
,
id
=
user_group_id
)
group
=
get_object_or_404
(
UserGroup
,
id
=
user_group_id
)
...
...
apps/perms/api/user_permission.py
View file @
844f9bf4
...
@@ -25,7 +25,9 @@ from ..hands import (
...
@@ -25,7 +25,9 @@ from ..hands import (
NodeSerializer
,
RemoteAppSerializer
,
NodeSerializer
,
RemoteAppSerializer
,
)
)
from
..
import
serializers
,
const
from
..
import
serializers
,
const
from
..mixins
import
AssetsFilterMixin
,
RemoteAppFilterMixin
from
..mixins
import
(
AssetsFilterMixin
,
RemoteAppFilterMixin
,
ChangeOrgIfNeedMixin
)
from
..models
import
Action
from
..models
import
Action
logger
=
get_logger
(
__name__
)
logger
=
get_logger
(
__name__
)
...
@@ -460,7 +462,7 @@ class GetUserAssetPermissionActionsApi(UserPermissionCacheMixin, APIView):
...
@@ -460,7 +462,7 @@ class GetUserAssetPermissionActionsApi(UserPermissionCacheMixin, APIView):
# RemoteApp permission
# RemoteApp permission
class
UserGrantedRemoteAppsApi
(
RemoteAppFilterMixin
,
ListAPIView
):
class
UserGrantedRemoteAppsApi
(
ChangeOrgIfNeedMixin
,
RemoteAppFilterMixin
,
ListAPIView
):
permission_classes
=
(
IsOrgAdminOrAppUser
,)
permission_classes
=
(
IsOrgAdminOrAppUser
,)
serializer_class
=
RemoteAppSerializer
serializer_class
=
RemoteAppSerializer
pagination_class
=
LimitOffsetPagination
pagination_class
=
LimitOffsetPagination
...
@@ -485,7 +487,7 @@ class UserGrantedRemoteAppsApi(RemoteAppFilterMixin, ListAPIView):
...
@@ -485,7 +487,7 @@ class UserGrantedRemoteAppsApi(RemoteAppFilterMixin, ListAPIView):
return
super
()
.
get_permissions
()
return
super
()
.
get_permissions
()
class
UserGrantedRemoteAppsAsTreeApi
(
ListAPIView
):
class
UserGrantedRemoteAppsAsTreeApi
(
ChangeOrgIfNeedMixin
,
ListAPIView
):
serializer_class
=
TreeNodeSerializer
serializer_class
=
TreeNodeSerializer
permission_classes
=
(
IsOrgAdminOrAppUser
,)
permission_classes
=
(
IsOrgAdminOrAppUser
,)
...
@@ -517,10 +519,11 @@ class UserGrantedRemoteAppsAsTreeApi(ListAPIView):
...
@@ -517,10 +519,11 @@ class UserGrantedRemoteAppsAsTreeApi(ListAPIView):
return
super
()
.
get_permissions
()
return
super
()
.
get_permissions
()
class
ValidateUserRemoteAppPermissionApi
(
APIView
):
class
ValidateUserRemoteAppPermissionApi
(
ChangeOrgIfNeedMixin
,
APIView
):
permission_classes
=
(
IsOrgAdminOrAppUser
,)
permission_classes
=
(
IsOrgAdminOrAppUser
,)
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
self
.
change_org_if_need
(
request
,
kwargs
)
user_id
=
request
.
query_params
.
get
(
'user_id'
,
''
)
user_id
=
request
.
query_params
.
get
(
'user_id'
,
''
)
remote_app_id
=
request
.
query_params
.
get
(
'remote_app_id'
,
''
)
remote_app_id
=
request
.
query_params
.
get
(
'remote_app_id'
,
''
)
user
=
get_object_or_404
(
User
,
id
=
user_id
)
user
=
get_object_or_404
(
User
,
id
=
user_id
)
...
...
apps/perms/mixins.py
View file @
844f9bf4
# ~*~ coding: utf-8 ~*~
# ~*~ coding: utf-8 ~*~
#
#
from
orgs.utils
import
set_to_root_org
__all__
=
[
__all__
=
[
'AssetsFilterMixin'
,
'RemoteAppFilterMixin'
,
'AssetsFilterMixin'
,
'RemoteAppFilterMixin'
,
'ChangeOrgIfNeedMixin'
,
]
]
...
@@ -100,3 +101,17 @@ class RemoteAppFilterMixin(object):
...
@@ -100,3 +101,17 @@ class RemoteAppFilterMixin(object):
queryset
,
key
=
lambda
x
:
getattr
(
x
,
order_by
),
reverse
=
reverse
queryset
,
key
=
lambda
x
:
getattr
(
x
,
order_by
),
reverse
=
reverse
)
)
return
queryset
return
queryset
class
ChangeOrgIfNeedMixin
(
object
):
@staticmethod
def
change_org_if_need
(
request
,
kwargs
):
if
request
.
user
.
is_authenticated
and
request
.
user
.
is_superuser
\
or
request
.
user
.
is_app
\
or
kwargs
.
get
(
'pk'
)
is
None
:
set_to_root_org
()
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
self
.
change_org_if_need
(
request
,
kwargs
)
return
super
()
.
get
(
request
,
*
args
,
**
kwargs
)
apps/settings/api.py
View file @
844f9bf4
...
@@ -39,7 +39,7 @@ class MailTestingAPI(APIView):
...
@@ -39,7 +39,7 @@ class MailTestingAPI(APIView):
subject
=
"Test"
subject
=
"Test"
message
=
"Test smtp setting"
message
=
"Test smtp setting"
email_from
=
email_from
or
email_host_user
email_from
=
email_from
or
email_host_user
send_mail
(
subject
,
message
,
email_from
,
[
email_
host_user
])
send_mail
(
subject
,
message
,
email_from
,
[
email_
from
])
except
Exception
as
e
:
except
Exception
as
e
:
return
Response
({
"error"
:
str
(
e
)},
status
=
401
)
return
Response
({
"error"
:
str
(
e
)},
status
=
401
)
...
...
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