mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-12-22 12:02:34 +00:00
Compare commits
21 Commits
dev-fce
...
v3.10.10-l
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1518f792d6 | ||
|
|
67277dd622 | ||
|
|
82e7f020ea | ||
|
|
f20b9e01ab | ||
|
|
8cf8a3701b | ||
|
|
7ba24293d1 | ||
|
|
f10114c9ed | ||
|
|
cf31cbfb07 | ||
|
|
0edad24d5d | ||
|
|
1f1c1a9157 | ||
|
|
6c9d271ae1 | ||
|
|
6ff852e225 | ||
|
|
baa75dc735 | ||
|
|
8a9f0436b8 | ||
|
|
a9620a3cbe | ||
|
|
769e7dc8a0 | ||
|
|
2a70449411 | ||
|
|
8df720f19e | ||
|
|
dabbb45f6e | ||
|
|
ce24c1c3fd | ||
|
|
3c54c82ce9 |
@@ -1,26 +1,24 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from django.conf import settings
|
|
||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
|
from django.conf import settings
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from django_filters import rest_framework as filters
|
|
||||||
from rest_framework import generics
|
from rest_framework import generics
|
||||||
from rest_framework import status
|
from rest_framework import status
|
||||||
from rest_framework.views import APIView, Response
|
from rest_framework.views import APIView, Response
|
||||||
|
from django_filters import rest_framework as filters
|
||||||
|
|
||||||
from common.api import JMSBulkModelViewSet
|
|
||||||
from common.drf.filters import BaseFilterSet
|
from common.drf.filters import BaseFilterSet
|
||||||
|
from common.api import JMSBulkModelViewSet
|
||||||
from common.exceptions import JMSException
|
from common.exceptions import JMSException
|
||||||
from common.permissions import WithBootstrapToken, IsServiceAccount
|
from common.permissions import WithBootstrapToken
|
||||||
from jumpserver.conf import ConfigCrypto
|
|
||||||
from terminal import serializers
|
from terminal import serializers
|
||||||
from terminal.models import Terminal
|
from terminal.models import Terminal
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'TerminalViewSet', 'TerminalConfig',
|
'TerminalViewSet', 'TerminalConfig',
|
||||||
'TerminalRegistrationApi', 'EncryptedTerminalConfig'
|
'TerminalRegistrationApi',
|
||||||
]
|
]
|
||||||
logger = logging.getLogger(__file__)
|
logger = logging.getLogger(__file__)
|
||||||
|
|
||||||
@@ -91,17 +89,3 @@ class TerminalRegistrationApi(generics.CreateAPIView):
|
|||||||
return Response(data=data, status=status.HTTP_400_BAD_REQUEST)
|
return Response(data=data, status=status.HTTP_400_BAD_REQUEST)
|
||||||
return super().create(request, *args, **kwargs)
|
return super().create(request, *args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
class EncryptedTerminalConfig(generics.CreateAPIView):
|
|
||||||
serializer_class = serializers.EncryptedConfigSerializer
|
|
||||||
permission_classes = [IsServiceAccount]
|
|
||||||
http_method_names = ['post']
|
|
||||||
|
|
||||||
def post(self, request, *args, **kwargs):
|
|
||||||
serializer = self.serializer_class(data=request.data)
|
|
||||||
serializer.is_valid(raise_exception=True)
|
|
||||||
encrypt_key = serializer.validated_data['secret_encrypt_key']
|
|
||||||
encrypted_value = serializer.validated_data['encrypted_value']
|
|
||||||
config_crypto = ConfigCrypto(encrypt_key)
|
|
||||||
value = config_crypto.decrypt(encrypted_value)
|
|
||||||
return Response(data={'value': value}, status=200)
|
|
||||||
|
|||||||
@@ -253,9 +253,8 @@ class ConnectMethodUtil:
|
|||||||
def _filter_disable_protocols_connect_methods(cls, methods):
|
def _filter_disable_protocols_connect_methods(cls, methods):
|
||||||
# 过滤一些特殊的协议方式
|
# 过滤一些特殊的协议方式
|
||||||
if not getattr(settings, 'TERMINAL_KOKO_SSH_ENABLED'):
|
if not getattr(settings, 'TERMINAL_KOKO_SSH_ENABLED'):
|
||||||
disable_ssh_client_protocols = [Protocol.ssh, Protocol.sftp, Protocol.telnet]
|
protocol = Protocol.ssh
|
||||||
for protocol in disable_ssh_client_protocols:
|
methods[protocol] = [m for m in methods[protocol] if m['type'] != 'native']
|
||||||
methods[protocol] = [m for m in methods[protocol] if m['type'] != 'native']
|
|
||||||
return methods
|
return methods
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|||||||
@@ -147,8 +147,3 @@ class ConnectMethodSerializer(serializers.Serializer):
|
|||||||
type = serializers.CharField(max_length=128)
|
type = serializers.CharField(max_length=128)
|
||||||
endpoint_protocol = serializers.CharField(max_length=128)
|
endpoint_protocol = serializers.CharField(max_length=128)
|
||||||
component = serializers.CharField(max_length=128)
|
component = serializers.CharField(max_length=128)
|
||||||
|
|
||||||
|
|
||||||
class EncryptedConfigSerializer(serializers.Serializer):
|
|
||||||
secret_encrypt_key = serializers.CharField(max_length=128)
|
|
||||||
encrypted_value = serializers.CharField(max_length=128)
|
|
||||||
|
|||||||
@@ -54,7 +54,6 @@ urlpatterns = [
|
|||||||
# components
|
# components
|
||||||
path('components/metrics/', api.ComponentsMetricsAPIView.as_view(), name='components-metrics'),
|
path('components/metrics/', api.ComponentsMetricsAPIView.as_view(), name='components-metrics'),
|
||||||
path('components/connect-methods/', api.ConnectMethodListApi.as_view(), name='connect-methods'),
|
path('components/connect-methods/', api.ConnectMethodListApi.as_view(), name='connect-methods'),
|
||||||
path('encrypted-config/', api.EncryptedTerminalConfig.as_view(), name='encrypted-terminal-config'),
|
|
||||||
]
|
]
|
||||||
|
|
||||||
urlpatterns += router.urls
|
urlpatterns += router.urls
|
||||||
|
|||||||
Reference in New Issue
Block a user