mirror of https://github.com/jumpserver/jumpserver
fix: 授权 API 顺序整理
parent
ca6b8ee960
commit
da772b572a
|
@ -40,8 +40,7 @@ class AssetPermissionUserRelationViewSet(RelationMixin):
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
queryset = super().get_queryset()
|
queryset = super().get_queryset()
|
||||||
queryset = queryset \
|
queryset = queryset.annotate(user_display=F('user__name'))
|
||||||
.annotate(user_display=F('user__name'))
|
|
||||||
return queryset
|
return queryset
|
||||||
|
|
||||||
|
|
||||||
|
@ -69,8 +68,7 @@ class AssetPermissionUserGroupRelationViewSet(RelationMixin):
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
queryset = super().get_queryset()
|
queryset = super().get_queryset()
|
||||||
queryset = queryset \
|
queryset = queryset.annotate(usergroup_display=F('usergroup__name'))
|
||||||
.annotate(usergroup_display=F('usergroup__name'))
|
|
||||||
return queryset
|
return queryset
|
||||||
|
|
||||||
|
|
||||||
|
@ -84,8 +82,7 @@ class AssetPermissionAssetRelationViewSet(RelationMixin):
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
queryset = super().get_queryset()
|
queryset = super().get_queryset()
|
||||||
queryset = queryset \
|
queryset = queryset.annotate(asset_display=F('asset__name'))
|
||||||
.annotate(asset_display=F('asset__name'))
|
|
||||||
return queryset
|
return queryset
|
||||||
|
|
||||||
|
|
||||||
|
@ -111,7 +108,6 @@ class AssetPermissionNodeRelationViewSet(RelationMixin):
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
queryset = super().get_queryset()
|
queryset = super().get_queryset()
|
||||||
queryset = queryset \
|
queryset = queryset.annotate(node_key=F('node__key'))
|
||||||
.annotate(node_key=F('node__key'))
|
|
||||||
return queryset
|
return queryset
|
||||||
|
|
||||||
|
|
|
@ -32,15 +32,15 @@ class UserDirectGrantedAssetsQuerysetMixin:
|
||||||
class UserAllGrantedAssetsQuerysetMixin:
|
class UserAllGrantedAssetsQuerysetMixin:
|
||||||
only_fields = serializers.AssetGrantedSerializer.Meta.only_fields
|
only_fields = serializers.AssetGrantedSerializer.Meta.only_fields
|
||||||
pagination_class = AllGrantedAssetPagination
|
pagination_class = AllGrantedAssetPagination
|
||||||
user: User
|
|
||||||
ordering_fields = ("hostname", "ip", "port", "cpu_cores")
|
ordering_fields = ("hostname", "ip", "port", "cpu_cores")
|
||||||
ordering = ('hostname', )
|
ordering = ('hostname', )
|
||||||
|
|
||||||
|
user: User
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
if getattr(self, 'swagger_fake_view', False):
|
if getattr(self, 'swagger_fake_view', False):
|
||||||
return Asset.objects.none()
|
return Asset.objects.none()
|
||||||
queryset = UserGrantedAssetsQueryUtils(self.user) \
|
queryset = UserGrantedAssetsQueryUtils(self.user).get_all_granted_assets()
|
||||||
.get_all_granted_assets()
|
|
||||||
queryset = queryset.prefetch_related('platform').only(*self.only_fields)
|
queryset = queryset.prefetch_related('platform').only(*self.only_fields)
|
||||||
return queryset
|
return queryset
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ from rest_framework_bulk.routes import BulkRouter
|
||||||
|
|
||||||
from .. import api
|
from .. import api
|
||||||
|
|
||||||
|
# v3 Done
|
||||||
router = BulkRouter()
|
router = BulkRouter()
|
||||||
router.register('asset-permissions', api.AssetPermissionViewSet, 'asset-permission')
|
router.register('asset-permissions', api.AssetPermissionViewSet, 'asset-permission')
|
||||||
router.register('asset-permissions-users-relations', api.AssetPermissionUserRelationViewSet, 'asset-permissions-users-relation')
|
router.register('asset-permissions-users-relations', api.AssetPermissionUserRelationViewSet, 'asset-permissions-users-relation')
|
||||||
|
@ -86,6 +87,8 @@ user_group_permission_urlpatterns = [
|
||||||
]
|
]
|
||||||
|
|
||||||
permission_urlpatterns = [
|
permission_urlpatterns = [
|
||||||
|
# Todo: 获取规则中授权的所有账号列表
|
||||||
|
#
|
||||||
# 授权规则中授权的资产
|
# 授权规则中授权的资产
|
||||||
path('<uuid:pk>/assets/all/', api.AssetPermissionAllAssetListApi.as_view(), name='asset-permission-all-assets'),
|
path('<uuid:pk>/assets/all/', api.AssetPermissionAllAssetListApi.as_view(), name='asset-permission-all-assets'),
|
||||||
path('<uuid:pk>/users/all/', api.AssetPermissionAllUserListApi.as_view(), name='asset-permission-all-users'),
|
path('<uuid:pk>/users/all/', api.AssetPermissionAllUserListApi.as_view(), name='asset-permission-all-users'),
|
||||||
|
|
Loading…
Reference in New Issue