mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-08-31 15:11:27 +00:00
perf: 去掉 v2 的api
This commit is contained in:
@@ -5,18 +5,22 @@ import uuid
|
||||
|
||||
from django.core.cache import cache
|
||||
from django.shortcuts import get_object_or_404
|
||||
from rest_framework import viewsets
|
||||
from rest_framework import viewsets, generics
|
||||
from rest_framework.views import APIView, Response
|
||||
from rest_framework import status
|
||||
from django.conf import settings
|
||||
|
||||
|
||||
from common.drf.api import JMSBulkModelViewSet
|
||||
from common.utils import get_object_or_none
|
||||
from common.permissions import IsAppUser, IsOrgAdminOrAppUser, IsSuperUser
|
||||
from common.permissions import IsAppUser, IsOrgAdminOrAppUser, IsSuperUser, WithBootstrapToken
|
||||
from ..models import Terminal, Status, Session
|
||||
from .. import serializers
|
||||
from .. import exceptions
|
||||
|
||||
__all__ = [
|
||||
'TerminalViewSet', 'StatusViewSet', 'TerminalConfig',
|
||||
'TerminalRegistrationApi',
|
||||
]
|
||||
logger = logging.getLogger(__file__)
|
||||
|
||||
@@ -112,4 +116,16 @@ class TerminalConfig(APIView):
|
||||
|
||||
def get(self, request):
|
||||
config = request.user.terminal.config
|
||||
return Response(config, status=200)
|
||||
return Response(config, status=200)
|
||||
|
||||
|
||||
class TerminalRegistrationApi(generics.CreateAPIView):
|
||||
serializer_class = serializers.TerminalRegistrationSerializer
|
||||
permission_classes = [WithBootstrapToken]
|
||||
http_method_names = ['post']
|
||||
|
||||
def create(self, request, *args, **kwargs):
|
||||
if not settings.SECURITY_SERVICE_ACCOUNT_REGISTRATION:
|
||||
data = {"error": "service account registration disabled"}
|
||||
return Response(data=data, status=status.HTTP_400_BAD_REQUEST)
|
||||
return super().create(request, *args, **kwargs)
|
||||
|
Reference in New Issue
Block a user