mirror of https://github.com/jumpserver/jumpserver
fix: 修复 在AWS公有云环境中,rds等资产的域名解析长度超过JumpServer资产限制的128字节导致连接失败问题 (#11188)
Co-authored-by: feng <1304903146@qq.com>pull/11190/head
parent
4dc6bd3660
commit
8cfec07faa
|
@ -2,6 +2,7 @@ from django.utils.translation import gettext_lazy as _
|
|||
from rest_framework import serializers
|
||||
|
||||
from common.serializers.fields import LabeledChoiceField
|
||||
from common.utils import pretty_string
|
||||
from orgs.mixins.serializers import BulkOrgResourceModelSerializer
|
||||
from .terminal import TerminalSmallSerializer
|
||||
from ..const import SessionType
|
||||
|
@ -22,6 +23,7 @@ class SessionSerializer(BulkOrgResourceModelSerializer):
|
|||
can_replay = serializers.BooleanField(read_only=True, label=_("Can replay"))
|
||||
can_join = serializers.BooleanField(read_only=True, label=_("Can join"))
|
||||
can_terminate = serializers.BooleanField(read_only=True, label=_("Can terminate"))
|
||||
asset = serializers.CharField(label=_("Asset"), style={'base_template': 'textarea.html'})
|
||||
|
||||
class Meta:
|
||||
model = Session
|
||||
|
@ -50,6 +52,11 @@ class SessionSerializer(BulkOrgResourceModelSerializer):
|
|||
'terminal_display': {'label': _('Terminal display')},
|
||||
}
|
||||
|
||||
def validate_asset(self, value):
|
||||
max_length = self.Meta.model.asset.field.max_length
|
||||
value = pretty_string(value, max_length=max_length)
|
||||
return value
|
||||
|
||||
|
||||
class SessionDisplaySerializer(SessionSerializer):
|
||||
command_amount = serializers.IntegerField(read_only=True, label=_('Command amount'))
|
||||
|
|
Loading…
Reference in New Issue