fix: 添加 api permission_classes

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

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

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

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

Loading…
Cancel
Save