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
4e85dd1d
Commit
4e85dd1d
authored
Aug 09, 2019
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 默认使用page
parent
2d3a37b4
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
11 additions
and
59 deletions
+11
-59
remote_app.py
apps/applications/api/remote_app.py
+0
-2
admin_user.py
apps/assets/api/admin_user.py
+2
-9
asset.py
apps/assets/api/asset.py
+0
-2
asset_user.py
apps/assets/api/asset_user.py
+3
-2
cmd_filter.py
apps/assets/api/cmd_filter.py
+0
-3
domain.py
apps/assets/api/domain.py
+1
-5
label.py
apps/assets/api/label.py
+0
-2
system_user.py
apps/assets/api/system_user.py
+0
-3
access_key.py
apps/authentication/api/access_key.py
+0
-2
api.py
apps/orgs/mixins/api.py
+3
-0
asset_permission.py
apps/perms/api/asset_permission.py
+0
-3
remote_app_permission.py
apps/perms/api/remote_app_permission.py
+0
-4
user_permission.py
apps/perms/api/user_permission.py
+1
-7
user_remote_app_permission.py
apps/perms/api/user_remote_app_permission.py
+0
-2
api.py
apps/settings/api.py
+0
-2
command.py
apps/terminal/api/command.py
+0
-2
session.py
apps/terminal/api/session.py
+0
-2
group.py
apps/users/api/group.py
+0
-2
user.py
apps/users/api/user.py
+1
-5
No files found.
apps/applications/api/remote_app.py
View file @
4e85dd1d
...
@@ -3,7 +3,6 @@
...
@@ -3,7 +3,6 @@
from
rest_framework
import
generics
from
rest_framework
import
generics
from
rest_framework.pagination
import
LimitOffsetPagination
from
rest_framework_bulk
import
BulkModelViewSet
from
rest_framework_bulk
import
BulkModelViewSet
from
..hands
import
IsOrgAdmin
,
IsAppUser
from
..hands
import
IsOrgAdmin
,
IsAppUser
...
@@ -22,7 +21,6 @@ class RemoteAppViewSet(BulkModelViewSet):
...
@@ -22,7 +21,6 @@ class RemoteAppViewSet(BulkModelViewSet):
permission_classes
=
(
IsOrgAdmin
,)
permission_classes
=
(
IsOrgAdmin
,)
queryset
=
RemoteApp
.
objects
.
all
()
queryset
=
RemoteApp
.
objects
.
all
()
serializer_class
=
RemoteAppSerializer
serializer_class
=
RemoteAppSerializer
pagination_class
=
LimitOffsetPagination
class
RemoteAppConnectionInfoApi
(
generics
.
RetrieveAPIView
):
class
RemoteAppConnectionInfoApi
(
generics
.
RetrieveAPIView
):
...
...
apps/assets/api/admin_user.py
View file @
4e85dd1d
...
@@ -17,8 +17,7 @@ from django.db import transaction
...
@@ -17,8 +17,7 @@ from django.db import transaction
from
django.shortcuts
import
get_object_or_404
from
django.shortcuts
import
get_object_or_404
from
rest_framework
import
generics
from
rest_framework
import
generics
from
rest_framework.response
import
Response
from
rest_framework.response
import
Response
from
rest_framework_bulk
import
BulkModelViewSet
from
orgs.mixins
import
OrgBulkModelViewSet
from
rest_framework.pagination
import
LimitOffsetPagination
from
common.mixins
import
IDInCacheFilterMixin
from
common.mixins
import
IDInCacheFilterMixin
from
common.utils
import
get_logger
from
common.utils
import
get_logger
...
@@ -36,7 +35,7 @@ __all__ = [
...
@@ -36,7 +35,7 @@ __all__ = [
]
]
class
AdminUserViewSet
(
IDInCacheFilterMixin
,
BulkModelViewSet
):
class
AdminUserViewSet
(
Org
BulkModelViewSet
):
"""
"""
Admin user api set, for add,delete,update,list,retrieve resource
Admin user api set, for add,delete,update,list,retrieve resource
"""
"""
...
@@ -46,11 +45,6 @@ class AdminUserViewSet(IDInCacheFilterMixin, BulkModelViewSet):
...
@@ -46,11 +45,6 @@ class AdminUserViewSet(IDInCacheFilterMixin, BulkModelViewSet):
queryset
=
AdminUser
.
objects
.
all
()
queryset
=
AdminUser
.
objects
.
all
()
serializer_class
=
serializers
.
AdminUserSerializer
serializer_class
=
serializers
.
AdminUserSerializer
permission_classes
=
(
IsOrgAdmin
,)
permission_classes
=
(
IsOrgAdmin
,)
pagination_class
=
LimitOffsetPagination
def
get_queryset
(
self
):
queryset
=
super
()
.
get_queryset
()
.
all
()
return
queryset
class
AdminUserAuthApi
(
generics
.
UpdateAPIView
):
class
AdminUserAuthApi
(
generics
.
UpdateAPIView
):
...
@@ -98,7 +92,6 @@ class AdminUserTestConnectiveApi(generics.RetrieveAPIView):
...
@@ -98,7 +92,6 @@ class AdminUserTestConnectiveApi(generics.RetrieveAPIView):
class
AdminUserAssetsListView
(
generics
.
ListAPIView
):
class
AdminUserAssetsListView
(
generics
.
ListAPIView
):
permission_classes
=
(
IsOrgAdmin
,)
permission_classes
=
(
IsOrgAdmin
,)
serializer_class
=
serializers
.
AssetSimpleSerializer
serializer_class
=
serializers
.
AssetSimpleSerializer
pagination_class
=
LimitOffsetPagination
filter_fields
=
(
"hostname"
,
"ip"
)
filter_fields
=
(
"hostname"
,
"ip"
)
http_method_names
=
[
'get'
]
http_method_names
=
[
'get'
]
search_fields
=
filter_fields
search_fields
=
filter_fields
...
...
apps/assets/api/asset.py
View file @
4e85dd1d
...
@@ -5,7 +5,6 @@ import random
...
@@ -5,7 +5,6 @@ import random
from
rest_framework
import
generics
from
rest_framework
import
generics
from
rest_framework.response
import
Response
from
rest_framework.response
import
Response
from
rest_framework.pagination
import
LimitOffsetPagination
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.shortcuts
import
get_object_or_404
from
django.shortcuts
import
get_object_or_404
from
django.db.models
import
Q
from
django.db.models
import
Q
...
@@ -37,7 +36,6 @@ class AssetViewSet(LabelFilter, OrgBulkModelViewSet):
...
@@ -37,7 +36,6 @@ class AssetViewSet(LabelFilter, OrgBulkModelViewSet):
ordering_fields
=
(
"hostname"
,
"ip"
,
"port"
,
"cpu_cores"
)
ordering_fields
=
(
"hostname"
,
"ip"
,
"port"
,
"cpu_cores"
)
queryset
=
Asset
.
objects
.
all
()
queryset
=
Asset
.
objects
.
all
()
serializer_class
=
serializers
.
AssetSerializer
serializer_class
=
serializers
.
AssetSerializer
pagination_class
=
LimitOffsetPagination
permission_classes
=
(
IsOrgAdminOrAppUser
,)
permission_classes
=
(
IsOrgAdminOrAppUser
,)
success_message
=
_
(
"
%(hostname)
s was
%(action)
s successfully"
)
success_message
=
_
(
"
%(hostname)
s was
%(action)
s successfully"
)
...
...
apps/assets/api/asset_user.py
View file @
4e85dd1d
...
@@ -3,7 +3,6 @@
...
@@ -3,7 +3,6 @@
from
rest_framework.response
import
Response
from
rest_framework.response
import
Response
from
rest_framework
import
generics
from
rest_framework
import
generics
from
rest_framework.pagination
import
LimitOffsetPagination
from
rest_framework
import
filters
from
rest_framework
import
filters
from
rest_framework_bulk
import
BulkModelViewSet
from
rest_framework_bulk
import
BulkModelViewSet
from
django.shortcuts
import
get_object_or_404
from
django.shortcuts
import
get_object_or_404
...
@@ -54,7 +53,6 @@ class AssetUserSearchBackend(filters.BaseFilterBackend):
...
@@ -54,7 +53,6 @@ class AssetUserSearchBackend(filters.BaseFilterBackend):
class
AssetUserViewSet
(
IDInCacheFilterMixin
,
BulkModelViewSet
):
class
AssetUserViewSet
(
IDInCacheFilterMixin
,
BulkModelViewSet
):
pagination_class
=
LimitOffsetPagination
serializer_class
=
serializers
.
AssetUserSerializer
serializer_class
=
serializers
.
AssetUserSerializer
permission_classes
=
[
IsOrgAdminOrAppUser
]
permission_classes
=
[
IsOrgAdminOrAppUser
]
http_method_names
=
[
'get'
,
'post'
]
http_method_names
=
[
'get'
,
'post'
]
...
@@ -68,6 +66,9 @@ class AssetUserViewSet(IDInCacheFilterMixin, BulkModelViewSet):
...
@@ -68,6 +66,9 @@ class AssetUserViewSet(IDInCacheFilterMixin, BulkModelViewSet):
AssetUserFilterBackend
,
AssetUserSearchBackend
,
AssetUserFilterBackend
,
AssetUserSearchBackend
,
)
)
def
allow_bulk_destroy
(
self
,
qs
,
filtered
):
return
False
def
get_queryset
(
self
):
def
get_queryset
(
self
):
# 尽可能先返回更少的数据
# 尽可能先返回更少的数据
username
=
self
.
request
.
GET
.
get
(
'username'
)
username
=
self
.
request
.
GET
.
get
(
'username'
)
...
...
apps/assets/api/cmd_filter.py
View file @
4e85dd1d
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
#
#
from
rest_framework_bulk
import
BulkModelViewSet
from
rest_framework_bulk
import
BulkModelViewSet
from
rest_framework.pagination
import
LimitOffsetPagination
from
django.shortcuts
import
get_object_or_404
from
django.shortcuts
import
get_object_or_404
from
..hands
import
IsOrgAdmin
from
..hands
import
IsOrgAdmin
...
@@ -19,7 +18,6 @@ class CommandFilterViewSet(BulkModelViewSet):
...
@@ -19,7 +18,6 @@ class CommandFilterViewSet(BulkModelViewSet):
permission_classes
=
(
IsOrgAdmin
,)
permission_classes
=
(
IsOrgAdmin
,)
queryset
=
CommandFilter
.
objects
.
all
()
queryset
=
CommandFilter
.
objects
.
all
()
serializer_class
=
serializers
.
CommandFilterSerializer
serializer_class
=
serializers
.
CommandFilterSerializer
pagination_class
=
LimitOffsetPagination
class
CommandFilterRuleViewSet
(
BulkModelViewSet
):
class
CommandFilterRuleViewSet
(
BulkModelViewSet
):
...
@@ -27,7 +25,6 @@ class CommandFilterRuleViewSet(BulkModelViewSet):
...
@@ -27,7 +25,6 @@ class CommandFilterRuleViewSet(BulkModelViewSet):
search_fields
=
filter_fields
search_fields
=
filter_fields
permission_classes
=
(
IsOrgAdmin
,)
permission_classes
=
(
IsOrgAdmin
,)
serializer_class
=
serializers
.
CommandFilterRuleSerializer
serializer_class
=
serializers
.
CommandFilterRuleSerializer
pagination_class
=
LimitOffsetPagination
def
get_queryset
(
self
):
def
get_queryset
(
self
):
fpk
=
self
.
kwargs
.
get
(
'filter_pk'
)
fpk
=
self
.
kwargs
.
get
(
'filter_pk'
)
...
...
apps/assets/api/domain.py
View file @
4e85dd1d
...
@@ -2,12 +2,10 @@
...
@@ -2,12 +2,10 @@
from
rest_framework_bulk
import
BulkModelViewSet
from
rest_framework_bulk
import
BulkModelViewSet
from
rest_framework.views
import
APIView
,
Response
from
rest_framework.views
import
APIView
,
Response
from
rest_framework.pagination
import
LimitOffsetPagination
from
django.views.generic.detail
import
SingleObjectMixin
from
django.views.generic.detail
import
SingleObjectMixin
from
common.utils
import
get_logger
from
common.utils
import
get_logger
from
common.permissions
import
IsOrgAdmin
,
Is
AppUser
,
Is
OrgAdminOrAppUser
from
common.permissions
import
IsOrgAdmin
,
IsOrgAdminOrAppUser
from
..models
import
Domain
,
Gateway
from
..models
import
Domain
,
Gateway
from
..
import
serializers
from
..
import
serializers
...
@@ -20,7 +18,6 @@ class DomainViewSet(BulkModelViewSet):
...
@@ -20,7 +18,6 @@ class DomainViewSet(BulkModelViewSet):
queryset
=
Domain
.
objects
.
all
()
queryset
=
Domain
.
objects
.
all
()
permission_classes
=
(
IsOrgAdmin
,)
permission_classes
=
(
IsOrgAdmin
,)
serializer_class
=
serializers
.
DomainSerializer
serializer_class
=
serializers
.
DomainSerializer
pagination_class
=
LimitOffsetPagination
def
get_queryset
(
self
):
def
get_queryset
(
self
):
queryset
=
super
()
.
get_queryset
()
.
all
()
queryset
=
super
()
.
get_queryset
()
.
all
()
...
@@ -43,7 +40,6 @@ class GatewayViewSet(BulkModelViewSet):
...
@@ -43,7 +40,6 @@ class GatewayViewSet(BulkModelViewSet):
queryset
=
Gateway
.
objects
.
all
()
queryset
=
Gateway
.
objects
.
all
()
permission_classes
=
(
IsOrgAdmin
,)
permission_classes
=
(
IsOrgAdmin
,)
serializer_class
=
serializers
.
GatewaySerializer
serializer_class
=
serializers
.
GatewaySerializer
pagination_class
=
LimitOffsetPagination
class
GatewayTestConnectionApi
(
SingleObjectMixin
,
APIView
):
class
GatewayTestConnectionApi
(
SingleObjectMixin
,
APIView
):
...
...
apps/assets/api/label.py
View file @
4e85dd1d
...
@@ -13,7 +13,6 @@
...
@@ -13,7 +13,6 @@
# See the License for the specific language governing permissions and
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
from
rest_framework.pagination
import
LimitOffsetPagination
from
django.db.models
import
Count
from
django.db.models
import
Count
from
common.utils
import
get_logger
from
common.utils
import
get_logger
...
@@ -32,7 +31,6 @@ class LabelViewSet(OrgBulkModelViewSet):
...
@@ -32,7 +31,6 @@ class LabelViewSet(OrgBulkModelViewSet):
search_fields
=
filter_fields
search_fields
=
filter_fields
permission_classes
=
(
IsOrgAdmin
,)
permission_classes
=
(
IsOrgAdmin
,)
serializer_class
=
serializers
.
LabelSerializer
serializer_class
=
serializers
.
LabelSerializer
pagination_class
=
LimitOffsetPagination
def
list
(
self
,
request
,
*
args
,
**
kwargs
):
def
list
(
self
,
request
,
*
args
,
**
kwargs
):
if
request
.
query_params
.
get
(
"distinct"
):
if
request
.
query_params
.
get
(
"distinct"
):
...
...
apps/assets/api/system_user.py
View file @
4e85dd1d
...
@@ -16,7 +16,6 @@
...
@@ -16,7 +16,6 @@
from
django.shortcuts
import
get_object_or_404
from
django.shortcuts
import
get_object_or_404
from
rest_framework
import
generics
from
rest_framework
import
generics
from
rest_framework.response
import
Response
from
rest_framework.response
import
Response
from
rest_framework.pagination
import
LimitOffsetPagination
from
common.utils
import
get_logger
from
common.utils
import
get_logger
from
common.permissions
import
IsOrgAdmin
,
IsOrgAdminOrAppUser
from
common.permissions
import
IsOrgAdmin
,
IsOrgAdminOrAppUser
...
@@ -49,7 +48,6 @@ class SystemUserViewSet(OrgBulkModelViewSet):
...
@@ -49,7 +48,6 @@ class SystemUserViewSet(OrgBulkModelViewSet):
queryset
=
SystemUser
.
objects
.
all
()
queryset
=
SystemUser
.
objects
.
all
()
serializer_class
=
serializers
.
SystemUserSerializer
serializer_class
=
serializers
.
SystemUserSerializer
permission_classes
=
(
IsOrgAdminOrAppUser
,)
permission_classes
=
(
IsOrgAdminOrAppUser
,)
pagination_class
=
LimitOffsetPagination
def
get_queryset
(
self
):
def
get_queryset
(
self
):
queryset
=
super
()
.
get_queryset
()
.
all
()
queryset
=
super
()
.
get_queryset
()
.
all
()
...
@@ -120,7 +118,6 @@ class SystemUserTestConnectiveApi(generics.RetrieveAPIView):
...
@@ -120,7 +118,6 @@ class SystemUserTestConnectiveApi(generics.RetrieveAPIView):
class
SystemUserAssetsListView
(
generics
.
ListAPIView
):
class
SystemUserAssetsListView
(
generics
.
ListAPIView
):
permission_classes
=
(
IsOrgAdmin
,)
permission_classes
=
(
IsOrgAdmin
,)
serializer_class
=
serializers
.
AssetSimpleSerializer
serializer_class
=
serializers
.
AssetSimpleSerializer
pagination_class
=
LimitOffsetPagination
filter_fields
=
(
"hostname"
,
"ip"
)
filter_fields
=
(
"hostname"
,
"ip"
)
http_method_names
=
[
'get'
]
http_method_names
=
[
'get'
]
search_fields
=
filter_fields
search_fields
=
filter_fields
...
...
apps/authentication/api/access_key.py
View file @
4e85dd1d
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
#
#
from
rest_framework.viewsets
import
ModelViewSet
from
rest_framework.viewsets
import
ModelViewSet
from
rest_framework.pagination
import
LimitOffsetPagination
from
common.permissions
import
IsValidUser
from
common.permissions
import
IsValidUser
from
..
import
serializers
from
..
import
serializers
...
@@ -11,7 +10,6 @@ from .. import serializers
...
@@ -11,7 +10,6 @@ from .. import serializers
class
AccessKeyViewSet
(
ModelViewSet
):
class
AccessKeyViewSet
(
ModelViewSet
):
permission_classes
=
(
IsValidUser
,)
permission_classes
=
(
IsValidUser
,)
serializer_class
=
serializers
.
AccessKeySerializer
serializer_class
=
serializers
.
AccessKeySerializer
pagination_class
=
LimitOffsetPagination
search_fields
=
[
'^id'
,
'^secret'
]
search_fields
=
[
'^id'
,
'^secret'
]
def
get_queryset
(
self
):
def
get_queryset
(
self
):
...
...
apps/orgs/mixins/api.py
View file @
4e85dd1d
...
@@ -34,6 +34,9 @@ class OrgBulkModelViewSet(IDInCacheFilterMixin, BulkModelViewSet):
...
@@ -34,6 +34,9 @@ class OrgBulkModelViewSet(IDInCacheFilterMixin, BulkModelViewSet):
queryset
=
self
.
serializer_class
.
setup_eager_loading
(
queryset
)
queryset
=
self
.
serializer_class
.
setup_eager_loading
(
queryset
)
return
queryset
return
queryset
def
allow_bulk_destroy
(
self
,
qs
,
filtered
):
return
False
class
OrgMembershipModelViewSetMixin
:
class
OrgMembershipModelViewSetMixin
:
org
=
None
org
=
None
...
...
apps/perms/api/asset_permission.py
View file @
4e85dd1d
...
@@ -7,7 +7,6 @@ from rest_framework.views import Response
...
@@ -7,7 +7,6 @@ from rest_framework.views import Response
from
django.shortcuts
import
get_object_or_404
from
django.shortcuts
import
get_object_or_404
from
rest_framework.generics
import
RetrieveUpdateAPIView
,
ListAPIView
from
rest_framework.generics
import
RetrieveUpdateAPIView
,
ListAPIView
from
rest_framework
import
viewsets
from
rest_framework
import
viewsets
from
rest_framework.pagination
import
LimitOffsetPagination
from
common.permissions
import
IsOrgAdmin
from
common.permissions
import
IsOrgAdmin
from
common.utils
import
get_object_or_none
from
common.utils
import
get_object_or_none
...
@@ -31,7 +30,6 @@ class AssetPermissionViewSet(viewsets.ModelViewSet):
...
@@ -31,7 +30,6 @@ class AssetPermissionViewSet(viewsets.ModelViewSet):
"""
"""
queryset
=
AssetPermission
.
objects
.
all
()
queryset
=
AssetPermission
.
objects
.
all
()
serializer_class
=
serializers
.
AssetPermissionCreateUpdateSerializer
serializer_class
=
serializers
.
AssetPermissionCreateUpdateSerializer
pagination_class
=
LimitOffsetPagination
filter_fields
=
[
'name'
]
filter_fields
=
[
'name'
]
permission_classes
=
(
IsOrgAdmin
,)
permission_classes
=
(
IsOrgAdmin
,)
...
@@ -247,7 +245,6 @@ class AssetPermissionAddAssetApi(RetrieveUpdateAPIView):
...
@@ -247,7 +245,6 @@ class AssetPermissionAddAssetApi(RetrieveUpdateAPIView):
class
AssetPermissionAssetsApi
(
ListAPIView
):
class
AssetPermissionAssetsApi
(
ListAPIView
):
permission_classes
=
(
IsOrgAdmin
,)
permission_classes
=
(
IsOrgAdmin
,)
pagination_class
=
LimitOffsetPagination
serializer_class
=
serializers
.
AssetPermissionAssetsSerializer
serializer_class
=
serializers
.
AssetPermissionAssetsSerializer
filter_fields
=
(
"hostname"
,
"ip"
)
filter_fields
=
(
"hostname"
,
"ip"
)
search_fields
=
filter_fields
search_fields
=
filter_fields
...
...
apps/perms/api/remote_app_permission.py
View file @
4e85dd1d
# coding: utf-8
# coding: utf-8
#
#
from
rest_framework
import
viewsets
,
generics
from
rest_framework
import
viewsets
,
generics
from
rest_framework.pagination
import
LimitOffsetPagination
from
rest_framework.views
import
Response
from
rest_framework.views
import
Response
from
common.permissions
import
IsOrgAdmin
from
common.permissions
import
IsOrgAdmin
from
..models
import
RemoteAppPermission
from
..models
import
RemoteAppPermission
from
..serializers
import
(
from
..serializers
import
(
RemoteAppPermissionSerializer
,
RemoteAppPermissionSerializer
,
...
@@ -28,7 +25,6 @@ class RemoteAppPermissionViewSet(viewsets.ModelViewSet):
...
@@ -28,7 +25,6 @@ class RemoteAppPermissionViewSet(viewsets.ModelViewSet):
search_fields
=
filter_fields
search_fields
=
filter_fields
queryset
=
RemoteAppPermission
.
objects
.
all
()
queryset
=
RemoteAppPermission
.
objects
.
all
()
serializer_class
=
RemoteAppPermissionSerializer
serializer_class
=
RemoteAppPermissionSerializer
pagination_class
=
LimitOffsetPagination
permission_classes
=
(
IsOrgAdmin
,)
permission_classes
=
(
IsOrgAdmin
,)
...
...
apps/perms/api/user_permission.py
View file @
4e85dd1d
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
#
#
import
uuid
import
uuid
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
,
RetrieveAPIView
ListAPIView
,
get_object_or_404
,
RetrieveAPIView
)
)
from
rest_framework.pagination
import
LimitOffsetPagination
from
common.permissions
import
IsValidUser
,
IsOrgAdminOrAppUser
,
IsOrgAdmin
from
common.permissions
import
IsValidUser
,
IsOrgAdminOrAppUser
,
IsOrgAdmin
from
common.tree
import
TreeNodeSerializer
from
common.tree
import
TreeNodeSerializer
...
@@ -40,7 +39,6 @@ class UserGrantedAssetsApi(UserPermissionCacheMixin, GrantAssetsMixin, ListAPIVi
...
@@ -40,7 +39,6 @@ class UserGrantedAssetsApi(UserPermissionCacheMixin, GrantAssetsMixin, ListAPIVi
用户授权的所有资产
用户授权的所有资产
"""
"""
permission_classes
=
(
IsOrgAdminOrAppUser
,)
permission_classes
=
(
IsOrgAdminOrAppUser
,)
pagination_class
=
LimitOffsetPagination
def
get_object
(
self
):
def
get_object
(
self
):
user_id
=
self
.
kwargs
.
get
(
'pk'
,
''
)
user_id
=
self
.
kwargs
.
get
(
'pk'
,
''
)
...
@@ -67,7 +65,6 @@ class UserGrantedNodeAssetsApi(UserPermissionCacheMixin, GrantAssetsMixin, ListA
...
@@ -67,7 +65,6 @@ class UserGrantedNodeAssetsApi(UserPermissionCacheMixin, GrantAssetsMixin, ListA
查询用户授权的节点下的资产的api, 与上面api不同的是,只返回某个节点下的资产
查询用户授权的节点下的资产的api, 与上面api不同的是,只返回某个节点下的资产
"""
"""
permission_classes
=
(
IsOrgAdminOrAppUser
,)
permission_classes
=
(
IsOrgAdminOrAppUser
,)
pagination_class
=
LimitOffsetPagination
def
get_object
(
self
):
def
get_object
(
self
):
user_id
=
self
.
kwargs
.
get
(
'pk'
,
''
)
user_id
=
self
.
kwargs
.
get
(
'pk'
,
''
)
...
@@ -121,7 +118,6 @@ class UserGrantedNodesApi(UserPermissionCacheMixin, NodesWithUngroupMixin, ListA
...
@@ -121,7 +118,6 @@ class UserGrantedNodesApi(UserPermissionCacheMixin, NodesWithUngroupMixin, ListA
"""
"""
permission_classes
=
(
IsOrgAdminOrAppUser
,)
permission_classes
=
(
IsOrgAdminOrAppUser
,)
serializer_class
=
NodeSerializer
serializer_class
=
NodeSerializer
pagination_class
=
LimitOffsetPagination
only_fields
=
NodeSerializer
.
Meta
.
only_fields
only_fields
=
NodeSerializer
.
Meta
.
only_fields
def
get_object
(
self
):
def
get_object
(
self
):
...
@@ -187,8 +183,6 @@ class UserGrantedNodesWithAssetsApi(UserPermissionCacheMixin, NodesWithUngroupMi
...
@@ -187,8 +183,6 @@ class UserGrantedNodesWithAssetsApi(UserPermissionCacheMixin, NodesWithUngroupMi
"""
"""
permission_classes
=
(
IsOrgAdminOrAppUser
,)
permission_classes
=
(
IsOrgAdminOrAppUser
,)
serializer_class
=
serializers
.
NodeGrantedSerializer
serializer_class
=
serializers
.
NodeGrantedSerializer
pagination_class
=
LimitOffsetPagination
nodes_only_fields
=
serializers
.
NodeGrantedSerializer
.
Meta
.
only_fields
nodes_only_fields
=
serializers
.
NodeGrantedSerializer
.
Meta
.
only_fields
assets_only_fields
=
serializers
.
NodeGrantedSerializer
.
assets_only_fields
assets_only_fields
=
serializers
.
NodeGrantedSerializer
.
assets_only_fields
system_users_only_fields
=
serializers
.
NodeGrantedSerializer
.
system_users_only_fields
system_users_only_fields
=
serializers
.
NodeGrantedSerializer
.
system_users_only_fields
...
...
apps/perms/api/user_remote_app_permission.py
View file @
4e85dd1d
...
@@ -5,7 +5,6 @@ from rest_framework.views import APIView, Response
...
@@ -5,7 +5,6 @@ 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
,
)
)
from
rest_framework.pagination
import
LimitOffsetPagination
from
common.permissions
import
IsValidUser
,
IsOrgAdminOrAppUser
from
common.permissions
import
IsValidUser
,
IsOrgAdminOrAppUser
from
common.tree
import
TreeNodeSerializer
from
common.tree
import
TreeNodeSerializer
...
@@ -26,7 +25,6 @@ __all__ = [
...
@@ -26,7 +25,6 @@ __all__ = [
class
UserGrantedRemoteAppsApi
(
RemoteAppFilterMixin
,
ListAPIView
):
class
UserGrantedRemoteAppsApi
(
RemoteAppFilterMixin
,
ListAPIView
):
permission_classes
=
(
IsOrgAdminOrAppUser
,)
permission_classes
=
(
IsOrgAdminOrAppUser
,)
serializer_class
=
RemoteAppSerializer
serializer_class
=
RemoteAppSerializer
pagination_class
=
LimitOffsetPagination
def
get_object
(
self
):
def
get_object
(
self
):
user_id
=
self
.
kwargs
.
get
(
'pk'
,
''
)
user_id
=
self
.
kwargs
.
get
(
'pk'
,
''
)
...
...
apps/settings/api.py
View file @
4e85dd1d
...
@@ -7,7 +7,6 @@ import jms_storage
...
@@ -7,7 +7,6 @@ import jms_storage
from
rest_framework
import
generics
from
rest_framework
import
generics
from
rest_framework.views
import
Response
,
APIView
from
rest_framework.views
import
Response
,
APIView
from
rest_framework.pagination
import
LimitOffsetPagination
from
django.conf
import
settings
from
django.conf
import
settings
from
django.core.mail
import
send_mail
from
django.core.mail
import
send_mail
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.utils.translation
import
ugettext_lazy
as
_
...
@@ -94,7 +93,6 @@ class LDAPTestingAPI(APIView):
...
@@ -94,7 +93,6 @@ class LDAPTestingAPI(APIView):
class
LDAPUserListApi
(
generics
.
ListAPIView
):
class
LDAPUserListApi
(
generics
.
ListAPIView
):
pagination_class
=
LimitOffsetPagination
permission_classes
=
(
IsOrgAdmin
,)
permission_classes
=
(
IsOrgAdmin
,)
serializer_class
=
LDAPUserSerializer
serializer_class
=
LDAPUserSerializer
...
...
apps/terminal/api/command.py
View file @
4e85dd1d
...
@@ -3,7 +3,6 @@
...
@@ -3,7 +3,6 @@
import
time
import
time
from
django.utils
import
timezone
from
django.utils
import
timezone
from
django.shortcuts
import
HttpResponse
from
django.shortcuts
import
HttpResponse
from
rest_framework.pagination
import
LimitOffsetPagination
from
rest_framework
import
viewsets
from
rest_framework
import
viewsets
from
rest_framework
import
generics
from
rest_framework
import
generics
from
rest_framework.response
import
Response
from
rest_framework.response
import
Response
...
@@ -23,7 +22,6 @@ __all__ = ['CommandViewSet', 'CommandExportApi']
...
@@ -23,7 +22,6 @@ __all__ = ['CommandViewSet', 'CommandExportApi']
class
CommandQueryMixin
:
class
CommandQueryMixin
:
command_store
=
get_command_storage
()
command_store
=
get_command_storage
()
pagination_class
=
LimitOffsetPagination
permission_classes
=
[
IsOrgAdminOrAppUser
|
IsAuditor
]
permission_classes
=
[
IsOrgAdminOrAppUser
|
IsAuditor
]
filter_fields
=
[
filter_fields
=
[
"asset"
,
"system_user"
,
"user"
,
"session"
,
"asset"
,
"system_user"
,
"user"
,
"session"
,
...
...
apps/terminal/api/session.py
View file @
4e85dd1d
...
@@ -6,7 +6,6 @@ from django.shortcuts import get_object_or_404
...
@@ -6,7 +6,6 @@ from django.shortcuts import get_object_or_404
from
django.core.files.storage
import
default_storage
from
django.core.files.storage
import
default_storage
from
django.http
import
HttpResponseNotFound
from
django.http
import
HttpResponseNotFound
from
django.conf
import
settings
from
django.conf
import
settings
from
rest_framework.pagination
import
LimitOffsetPagination
from
rest_framework
import
viewsets
from
rest_framework
import
viewsets
from
rest_framework.response
import
Response
from
rest_framework.response
import
Response
from
rest_framework.generics
import
GenericAPIView
from
rest_framework.generics
import
GenericAPIView
...
@@ -28,7 +27,6 @@ logger = get_logger(__name__)
...
@@ -28,7 +27,6 @@ logger = get_logger(__name__)
class
SessionViewSet
(
OrgBulkModelViewSet
):
class
SessionViewSet
(
OrgBulkModelViewSet
):
queryset
=
Session
.
objects
.
all
()
queryset
=
Session
.
objects
.
all
()
serializer_class
=
serializers
.
SessionSerializer
serializer_class
=
serializers
.
SessionSerializer
pagination_class
=
LimitOffsetPagination
permission_classes
=
(
IsOrgAdminOrAppUser
|
IsAuditor
,
)
permission_classes
=
(
IsOrgAdminOrAppUser
|
IsAuditor
,
)
filter_fields
=
[
filter_fields
=
[
"user"
,
"asset"
,
"system_user"
,
"remote_addr"
,
"user"
,
"asset"
,
"system_user"
,
"remote_addr"
,
...
...
apps/users/api/group.py
View file @
4e85dd1d
...
@@ -3,7 +3,6 @@
...
@@ -3,7 +3,6 @@
from
rest_framework
import
generics
from
rest_framework
import
generics
from
rest_framework_bulk
import
BulkModelViewSet
from
rest_framework_bulk
import
BulkModelViewSet
from
rest_framework.pagination
import
LimitOffsetPagination
from
..serializers
import
(
from
..serializers
import
(
UserGroupSerializer
,
UserGroupSerializer
,
...
@@ -24,7 +23,6 @@ class UserGroupViewSet(IDInCacheFilterMixin, BulkModelViewSet):
...
@@ -24,7 +23,6 @@ class UserGroupViewSet(IDInCacheFilterMixin, BulkModelViewSet):
queryset
=
UserGroup
.
objects
.
all
()
queryset
=
UserGroup
.
objects
.
all
()
serializer_class
=
UserGroupSerializer
serializer_class
=
UserGroupSerializer
permission_classes
=
(
IsOrgAdmin
,)
permission_classes
=
(
IsOrgAdmin
,)
pagination_class
=
LimitOffsetPagination
def
get_serializer_class
(
self
):
def
get_serializer_class
(
self
):
if
self
.
action
in
(
"list"
,
'retrieve'
)
and
\
if
self
.
action
in
(
"list"
,
'retrieve'
)
and
\
...
...
apps/users/api/user.py
View file @
4e85dd1d
...
@@ -10,7 +10,6 @@ from rest_framework import generics
...
@@ -10,7 +10,6 @@ from rest_framework import generics
from
rest_framework.response
import
Response
from
rest_framework.response
import
Response
from
rest_framework.permissions
import
IsAuthenticated
from
rest_framework.permissions
import
IsAuthenticated
from
rest_framework_bulk
import
BulkModelViewSet
from
rest_framework_bulk
import
BulkModelViewSet
from
rest_framework.pagination
import
LimitOffsetPagination
from
common.permissions
import
(
from
common.permissions
import
(
IsOrgAdmin
,
IsCurrentUserOrReadOnly
,
IsOrgAdminOrAppUser
,
IsOrgAdmin
,
IsCurrentUserOrReadOnly
,
IsOrgAdminOrAppUser
,
...
@@ -38,7 +37,6 @@ class UserViewSet(IDInCacheFilterMixin, BulkModelViewSet):
...
@@ -38,7 +37,6 @@ class UserViewSet(IDInCacheFilterMixin, BulkModelViewSet):
queryset
=
User
.
objects
.
exclude
(
role
=
User
.
ROLE_APP
)
queryset
=
User
.
objects
.
exclude
(
role
=
User
.
ROLE_APP
)
serializer_class
=
serializers
.
UserSerializer
serializer_class
=
serializers
.
UserSerializer
permission_classes
=
(
IsOrgAdmin
,
CanUpdateDeleteSuperUser
)
permission_classes
=
(
IsOrgAdmin
,
CanUpdateDeleteSuperUser
)
pagination_class
=
LimitOffsetPagination
def
send_created_signal
(
self
,
users
):
def
send_created_signal
(
self
,
users
):
if
not
isinstance
(
users
,
list
):
if
not
isinstance
(
users
,
list
):
...
@@ -82,9 +80,7 @@ class UserViewSet(IDInCacheFilterMixin, BulkModelViewSet):
...
@@ -82,9 +80,7 @@ class UserViewSet(IDInCacheFilterMixin, BulkModelViewSet):
return
False
return
False
def
allow_bulk_destroy
(
self
,
qs
,
filtered
):
def
allow_bulk_destroy
(
self
,
qs
,
filtered
):
if
self
.
_bulk_deny_permission
(
filtered
):
return
False
return
False
return
qs
.
count
()
!=
filtered
.
count
()
def
bulk_update
(
self
,
request
,
*
args
,
**
kwargs
):
def
bulk_update
(
self
,
request
,
*
args
,
**
kwargs
):
"""
"""
...
...
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