perf: 连接时支持连接参数

pull/10629/head
ibuler 2023-06-05 17:27:44 +08:00
parent a341b55f43
commit c6f92a462f
4 changed files with 23 additions and 2 deletions

View File

@ -0,0 +1,18 @@
# Generated by Django 3.2.17 on 2023-06-05 07:28
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('authentication', '0019_connectiontoken_is_reusable'),
]
operations = [
migrations.AddField(
model_name='connectiontoken',
name='connect_options',
field=models.JSONField(default=dict, verbose_name='Connect options'),
),
]

View File

@ -38,6 +38,7 @@ class ConnectionToken(JMSOrgBaseModel):
input_secret = EncryptTextField(max_length=64, default='', blank=True, verbose_name=_("Input secret"))
protocol = models.CharField(max_length=16, default=Protocol.ssh, verbose_name=_("Protocol"))
connect_method = models.CharField(max_length=32, verbose_name=_("Connect method"))
connect_options = models.JSONField(default=dict, verbose_name=_("Connect options"))
user_display = models.CharField(max_length=128, default='', verbose_name=_("User display"))
asset_display = models.CharField(max_length=128, default='', verbose_name=_("Asset display"))
is_reusable = models.BooleanField(default=False, verbose_name=_("Reusable"))

View File

@ -134,6 +134,7 @@ class ConnectionTokenSecretSerializer(OrgResourceModelSerializerMixin):
command_filter_acls = _ConnectionTokenCommandFilterACLSerializer(read_only=True, many=True)
expire_now = serializers.BooleanField(label=_('Expired now'), write_only=True, default=True)
connect_method = _ConnectTokenConnectMethodSerializer(read_only=True, source='connect_method_object')
connect_options = serializers.JSONField(read_only=True)
actions = ActionChoicesField()
expire_at = serializers.IntegerField()
@ -144,6 +145,7 @@ class ConnectionTokenSecretSerializer(OrgResourceModelSerializerMixin):
'platform', 'command_filter_acls', 'protocol',
'domain', 'gateway', 'actions', 'expire_at',
'from_ticket', 'expire_now', 'connect_method',
'connect_options',
]
extra_kwargs = {
'value': {'read_only': True},

View File

@ -26,8 +26,8 @@ class ConnectionTokenSerializer(OrgResourceModelSerializerMixin):
model = ConnectionToken
fields_mini = ['id', 'value']
fields_small = fields_mini + [
'user', 'asset', 'account', 'input_username',
'input_secret', 'connect_method', 'protocol', 'actions',
'user', 'asset', 'account', 'input_username', 'input_secret',
'connect_method', 'connect_options', 'protocol', 'actions',
'is_active', 'is_reusable', 'from_ticket', 'from_ticket_info',
'date_expired', 'date_created', 'date_updated', 'created_by',
'updated_by', 'org_id', 'org_name',