From 4068b5c76a09e8fe2588395a59e1096a29a39cee Mon Sep 17 00:00:00 2001 From: feng <1304903146@qq.com> Date: Wed, 20 Nov 2024 16:18:10 +0800 Subject: [PATCH] perf: Change secret ssh_key_change_strategy modify the default value --- apps/accounts/const/automation.py | 4 ++-- apps/accounts/migrations/0002_auto_20220616_0021.py | 4 ++-- apps/accounts/models/automations/base.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/accounts/const/automation.py b/apps/accounts/const/automation.py index c0419486d..d8388b6bc 100644 --- a/apps/accounts/const/automation.py +++ b/apps/accounts/const/automation.py @@ -49,9 +49,9 @@ class SecretStrategy(models.TextChoices): class SSHKeyStrategy(models.TextChoices): - add = 'add', _('Append SSH KEY') - set = 'set', _('Empty and append SSH KEY') set_jms = 'set_jms', _('Replace (Replace only keys pushed by JumpServer) ') + set = 'set', _('Empty and append SSH KEY') + add = 'add', _('Append SSH KEY') class TriggerChoice(models.TextChoices, TreeChoices): diff --git a/apps/accounts/migrations/0002_auto_20220616_0021.py b/apps/accounts/migrations/0002_auto_20220616_0021.py index 5ac195d63..8fe829dd6 100644 --- a/apps/accounts/migrations/0002_auto_20220616_0021.py +++ b/apps/accounts/migrations/0002_auto_20220616_0021.py @@ -50,7 +50,7 @@ class Migration(migrations.Migration): ('secret', common.db.fields.EncryptTextField(blank=True, null=True, verbose_name='Secret')), ('secret_strategy', models.CharField(choices=[('specific', 'Specific secret'), ('random', 'Random generate')], default='specific', max_length=16, verbose_name='Secret strategy')), ('password_rules', models.JSONField(default=dict, verbose_name='Password rules')), - ('ssh_key_change_strategy', models.CharField(choices=[('add', 'Append SSH KEY'), ('set', 'Empty and append SSH KEY'), ('set_jms', 'Replace (Replace only keys pushed by JumpServer) ')], default='add', max_length=16, verbose_name='SSH key change strategy')), + ('ssh_key_change_strategy', models.CharField(choices=[('set_jms', 'Replace (Replace only keys pushed by JumpServer) '), ('set', 'Empty and append SSH KEY'), ('add', 'Append SSH KEY')], default='set_jms', max_length=16, verbose_name='SSH key change strategy')), ], options={ 'verbose_name': 'Change secret automation', @@ -76,7 +76,7 @@ class Migration(migrations.Migration): ('secret', common.db.fields.EncryptTextField(blank=True, null=True, verbose_name='Secret')), ('secret_strategy', models.CharField(choices=[('specific', 'Specific secret'), ('random', 'Random generate')], default='specific', max_length=16, verbose_name='Secret strategy')), ('password_rules', models.JSONField(default=dict, verbose_name='Password rules')), - ('ssh_key_change_strategy', models.CharField(choices=[('add', 'Append SSH KEY'), ('set', 'Empty and append SSH KEY'), ('set_jms', 'Replace (Replace only keys pushed by JumpServer) ')], default='add', max_length=16, verbose_name='SSH key change strategy')), + ('ssh_key_change_strategy', models.CharField(choices=[('set_jms', 'Replace (Replace only keys pushed by JumpServer) '), ('set', 'Empty and append SSH KEY'), ('add', 'Append SSH KEY')], default='set_jms', max_length=16, verbose_name='SSH key change strategy')), ('triggers', models.JSONField(default=list, max_length=16, verbose_name='Triggers')), ('username', models.CharField(max_length=128, verbose_name='Username')), ('action', models.CharField(max_length=16, verbose_name='Action')), diff --git a/apps/accounts/models/automations/base.py b/apps/accounts/models/automations/base.py index 1adc84bfe..b001e8cc7 100644 --- a/apps/accounts/models/automations/base.py +++ b/apps/accounts/models/automations/base.py @@ -51,7 +51,7 @@ class AutomationExecution(AssetAutomationExecution): class ChangeSecretMixin(SecretWithRandomMixin): ssh_key_change_strategy = models.CharField( choices=SSHKeyStrategy.choices, max_length=16, - default=SSHKeyStrategy.add, verbose_name=_('SSH key change strategy') + default=SSHKeyStrategy.set_jms, verbose_name=_('SSH key change strategy') ) get_all_assets: callable # get all assets