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
e43da3d6
Commit
e43da3d6
authored
5 years ago
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ipython
parent
b064be3e
master
auditor_jym
dev
dev_beta
dev_beta_db
gengmei
node_service
v52
wph
1.5.2
1.5.1
No related merge requests found
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
16 deletions
+18
-16
user_permission.py
apps/perms/api/user_permission.py
+11
-14
user_permission.py
apps/perms/serializers/user_permission.py
+7
-2
No files found.
apps/perms/api/user_permission.py
View file @
e43da3d6
...
@@ -8,7 +8,7 @@ from django.conf import settings
...
@@ -8,7 +8,7 @@ from django.conf import settings
from
django.shortcuts
import
get_object_or_404
from
django.shortcuts
import
get_object_or_404
from
rest_framework.views
import
APIView
,
Response
from
rest_framework.views
import
APIView
,
Response
from
rest_framework.generics
import
(
from
rest_framework.generics
import
(
ListAPIView
,
get_object_or_404
,
ListAPIView
,
get_object_or_404
,
GenericAPIView
,
RetrieveAPIView
)
)
from
rest_framework.pagination
import
LimitOffsetPagination
from
rest_framework.pagination
import
LimitOffsetPagination
...
@@ -433,13 +433,14 @@ class ValidateUserAssetPermissionApi(UserPermissionCacheMixin, APIView):
...
@@ -433,13 +433,14 @@ class ValidateUserAssetPermissionApi(UserPermissionCacheMixin, APIView):
return
Response
({
'msg'
:
True
},
status
=
200
)
return
Response
({
'msg'
:
True
},
status
=
200
)
class
GetUserAssetPermissionActionsApi
(
UserPermissionCacheMixin
,
APIView
):
class
GetUserAssetPermissionActionsApi
(
UserPermissionCacheMixin
,
Retrieve
APIView
):
permission_classes
=
(
IsOrgAdminOrAppUser
,)
permission_classes
=
(
IsOrgAdminOrAppUser
,)
serializers_class
=
serializers
.
ActionsSerializer
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
def
get
_object
(
self
):
user_id
=
request
.
query_params
.
get
(
'user_id'
,
''
)
user_id
=
self
.
request
.
query_params
.
get
(
'user_id'
,
''
)
asset_id
=
request
.
query_params
.
get
(
'asset_id'
,
''
)
asset_id
=
self
.
request
.
query_params
.
get
(
'asset_id'
,
''
)
system_id
=
request
.
query_params
.
get
(
'system_user_id'
,
''
)
system_id
=
self
.
request
.
query_params
.
get
(
'system_user_id'
,
''
)
user
=
get_object_or_404
(
User
,
id
=
user_id
)
user
=
get_object_or_404
(
User
,
id
=
user_id
)
asset
=
get_object_or_404
(
Asset
,
id
=
asset_id
)
asset
=
get_object_or_404
(
Asset
,
id
=
asset_id
)
...
@@ -447,12 +448,8 @@ class GetUserAssetPermissionActionsApi(UserPermissionCacheMixin, APIView):
...
@@ -447,12 +448,8 @@ class GetUserAssetPermissionActionsApi(UserPermissionCacheMixin, APIView):
util
=
AssetPermissionUtil
(
user
,
cache_policy
=
self
.
cache_policy
)
util
=
AssetPermissionUtil
(
user
,
cache_policy
=
self
.
cache_policy
)
granted_assets
=
util
.
get_assets
()
granted_assets
=
util
.
get_assets
()
granted_system_users
=
granted_assets
.
get
(
asset
,
[])
granted_system_users
=
granted_assets
.
get
(
asset
,
{})
_su
=
next
((
s
for
s
in
granted_system_users
if
s
.
id
==
su
.
id
),
None
)
if
not
_su
:
return
Response
({
'actions'
:
[]},
status
=
403
)
actions
=
[
action
.
name
for
action
in
getattr
(
_su
,
'actions'
,
[])]
return
Response
({
'actions'
:
actions
},
status
=
200
)
if
su
not
in
granted_system_users
:
return
{
"actions"
:
0
}
return
granted_system_users
[
su
]
This diff is collapsed.
Click to expand it.
apps/perms/serializers/user_permission.py
View file @
e43da3d6
...
@@ -11,6 +11,7 @@ from .asset_permission import ActionField
...
@@ -11,6 +11,7 @@ from .asset_permission import ActionField
__all__
=
[
__all__
=
[
'AssetPermissionNodeSerializer'
,
'GrantedNodeSerializer'
,
'AssetPermissionNodeSerializer'
,
'GrantedNodeSerializer'
,
'NodeGrantedSerializer'
,
'AssetGrantedSerializer'
,
'NodeGrantedSerializer'
,
'AssetGrantedSerializer'
,
'ActionsSerializer'
,
]
]
...
@@ -110,4 +111,8 @@ class GrantedNodeSerializer(serializers.ModelSerializer):
...
@@ -110,4 +111,8 @@ class GrantedNodeSerializer(serializers.ModelSerializer):
model
=
Node
model
=
Node
fields
=
[
fields
=
[
'id'
,
'name'
,
'key'
,
'value'
,
'id'
,
'name'
,
'key'
,
'value'
,
]
]
\ No newline at end of file
class
ActionsSerializer
(
serializers
.
Serializer
):
actions
=
ActionField
(
read_only
=
True
)
\ No newline at end of file
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