fix: 添加 api permission_classes

pull/9696/head
Aaron3S 2 years ago
parent ddcd09c6a6
commit d14010d4fa

@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
from orgs.mixins.api import OrgBulkModelViewSet
from rbac.permissions import RBACPermission
from ..models import AdHoc
from ..serializers import (
AdHocSerializer
@ -12,7 +13,7 @@ __all__ = [
class AdHocViewSet(OrgBulkModelViewSet):
serializer_class = AdHocSerializer
permission_classes = ()
permission_classes = (RBACPermission,)
search_fields = ('name', 'comment')
model = AdHoc

@ -17,6 +17,7 @@ from ops.variables import JMS_JOB_VARIABLE_HELP
from orgs.mixins.api import OrgBulkModelViewSet
from orgs.utils import tmp_to_org, get_current_org
from accounts.models import Account
from rbac.permissions import RBACPermission
def set_task_to_serializer_data(serializer, task):
@ -27,7 +28,7 @@ def set_task_to_serializer_data(serializer, task):
class JobViewSet(OrgBulkModelViewSet):
serializer_class = JobSerializer
permission_classes = ()
permission_classes = (RBACPermission,)
search_fields = ('name', 'comment')
model = Job
@ -69,7 +70,7 @@ class JobViewSet(OrgBulkModelViewSet):
class JobExecutionViewSet(OrgBulkModelViewSet):
serializer_class = JobExecutionSerializer
http_method_names = ('get', 'post', 'head', 'options',)
permission_classes = ()
permission_classes = (RBACPermission,)
model = JobExecution
search_fields = ('material',)

@ -8,6 +8,7 @@ from rest_framework import status
from common.exceptions import JMSException
from orgs.mixins.api import OrgBulkModelViewSet
from rbac.permissions import RBACPermission
from ..exception import PlaybookNoValidEntry
from ..models import Playbook
from ..serializers.playbook import PlaybookSerializer
@ -26,7 +27,7 @@ def unzip_playbook(src, dist):
class PlaybookViewSet(OrgBulkModelViewSet):
serializer_class = PlaybookSerializer
permission_classes = ()
permission_classes = (RBACPermission,)
model = Playbook
search_fields = ('name', 'comment')
@ -58,8 +59,13 @@ class PlaybookViewSet(OrgBulkModelViewSet):
class PlaybookFileBrowserAPIView(APIView):
rbac_perms = ()
permission_classes = ()
permission_classes = (RBACPermission,)
rbac_perms = {
'GET': 'ops.change_playbooks',
'POST': 'ops.change_playbooks',
'DELETE': 'ops.change_playbooks',
'PATCH': 'ops.change_playbooks',
}
protected_files = ['root', 'main.yml']
def get(self, request, **kwargs):

Loading…
Cancel
Save