From 2366f02d10fd48b974e9ff2145f14ce5a81e8872 Mon Sep 17 00:00:00 2001 From: "Jiangjie.Bai" Date: Mon, 6 Jun 2022 18:04:11 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=20razor=20=E5=B9=B6=E6=9B=BF=E6=8D=A2=20XRDP?= =?UTF-8?q?=5FENABLED?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/jumpserver/conf.py | 3 +-- apps/jumpserver/settings/custom.py | 2 +- .../migrations/0006_remove_setting_enabled.py | 23 +++++++++++++++++++ apps/settings/serializers/public.py | 2 +- apps/settings/serializers/terminal.py | 2 +- apps/terminal/const.py | 1 + .../migrations/0048_endpoint_endpointrule.py | 6 ++--- .../migrations/0050_auto_20220606_1745.py | 18 +++++++++++++++ 8 files changed, 49 insertions(+), 8 deletions(-) create mode 100644 apps/settings/migrations/0006_remove_setting_enabled.py create mode 100644 apps/terminal/migrations/0050_auto_20220606_1745.py diff --git a/apps/jumpserver/conf.py b/apps/jumpserver/conf.py index 93aa46806..df8b5f287 100644 --- a/apps/jumpserver/conf.py +++ b/apps/jumpserver/conf.py @@ -324,8 +324,7 @@ class Config(dict): # 保留(Luna还在用) 'TERMINAL_MAGNUS_ENABLED': True, 'TERMINAL_KOKO_SSH_ENABLED': True, - # 保留(Luna还在用) - 'XRDP_ENABLED': True, + 'TERMINAL_RAZOR_ENABLED': True, # 安全配置 'SECURITY_MFA_AUTH': 0, # 0 不开启 1 全局开启 2 管理员开启 diff --git a/apps/jumpserver/settings/custom.py b/apps/jumpserver/settings/custom.py index b2768f2d8..9f645617b 100644 --- a/apps/jumpserver/settings/custom.py +++ b/apps/jumpserver/settings/custom.py @@ -139,7 +139,7 @@ LOGIN_REDIRECT_MSG_ENABLED = CONFIG.LOGIN_REDIRECT_MSG_ENABLED CLOUD_SYNC_TASK_EXECUTION_KEEP_DAYS = CONFIG.CLOUD_SYNC_TASK_EXECUTION_KEEP_DAYS -XRDP_ENABLED = CONFIG.XRDP_ENABLED +TERMINAL_RAZOR_ENABLED = CONFIG.TERMINAL_RAZOR_ENABLED TERMINAL_MAGNUS_ENABLED = CONFIG.TERMINAL_MAGNUS_ENABLED TERMINAL_KOKO_SSH_ENABLED = CONFIG.TERMINAL_KOKO_SSH_ENABLED diff --git a/apps/settings/migrations/0006_remove_setting_enabled.py b/apps/settings/migrations/0006_remove_setting_enabled.py new file mode 100644 index 000000000..0982bc0f2 --- /dev/null +++ b/apps/settings/migrations/0006_remove_setting_enabled.py @@ -0,0 +1,23 @@ +# Generated by Django 3.1.14 on 2022-06-06 09:45 + +from django.db import migrations + + +def migrate_terminal_razor_enabled(apps, schema_editor): + setting_model = apps.get_model("settings", "Setting") + s = setting_model.objects.filter(name='XRDP_ENABLED').first() + if not s: + return + s.name = 'TERMINAL_RAZOR_ENABLED' + s.save() + + +class Migration(migrations.Migration): + + dependencies = [ + ('settings', '0005_auto_20220310_0616'), + ] + + operations = [ + migrations.RunPython(migrate_terminal_razor_enabled), + ] diff --git a/apps/settings/serializers/public.py b/apps/settings/serializers/public.py index 22fe55142..7e9f46b7d 100644 --- a/apps/settings/serializers/public.py +++ b/apps/settings/serializers/public.py @@ -35,7 +35,7 @@ class PrivateSettingSerializer(PublicSettingSerializer): AUTH_FEISHU = serializers.BooleanField() AUTH_TEMP_TOKEN = serializers.BooleanField() - XRDP_ENABLED = serializers.BooleanField() + TERMINAL_RAZOR_ENABLED = serializers.BooleanField() TERMINAL_MAGNUS_ENABLED = serializers.BooleanField() TERMINAL_KOKO_SSH_ENABLED = serializers.BooleanField() diff --git a/apps/settings/serializers/terminal.py b/apps/settings/serializers/terminal.py index f6799eca1..1b70fadf3 100644 --- a/apps/settings/serializers/terminal.py +++ b/apps/settings/serializers/terminal.py @@ -34,5 +34,5 @@ class TerminalSettingSerializer(serializers.Serializer): "if you cannot log in to the device through Telnet, set this parameter") ) TERMINAL_MAGNUS_ENABLED = serializers.BooleanField(label=_("Enable database proxy")) - XRDP_ENABLED = serializers.BooleanField(label=_("Enable XRDP")) + TERMINAL_RAZOR_ENABLED = serializers.BooleanField(label=_("Enable Razor")) TERMINAL_KOKO_SSH_ENABLED = serializers.BooleanField(label=_("Enable SSH Client")) diff --git a/apps/terminal/const.py b/apps/terminal/const.py index 931a3e887..7289f3180 100644 --- a/apps/terminal/const.py +++ b/apps/terminal/const.py @@ -49,6 +49,7 @@ class TerminalTypeChoices(TextChoices): core = 'core', 'Core' celery = 'celery', 'Celery' magnus = 'magnus', 'Magnus' + razor = 'razor', 'Razor' @classmethod def types(cls): diff --git a/apps/terminal/migrations/0048_endpoint_endpointrule.py b/apps/terminal/migrations/0048_endpoint_endpointrule.py index ccdd59564..1ea7c3d03 100644 --- a/apps/terminal/migrations/0048_endpoint_endpointrule.py +++ b/apps/terminal/migrations/0048_endpoint_endpointrule.py @@ -21,7 +21,7 @@ def migrate_endpoints(apps, schema_editor): } Endpoint.objects.create(**default_data) - if not settings.XRDP_ENABLED: + if not settings.TERMINAL_RAZOR_ENABLED: return # migrate xrdp xrdp_addr = settings.TERMINAL_RDP_ADDR @@ -41,7 +41,7 @@ def migrate_endpoints(apps, schema_editor): else: rdp_port = 3389 xrdp_data = { - 'name': 'XRDP', + 'name': 'Razor', 'host': host, 'https_port': 0, 'http_port': 0, @@ -56,7 +56,7 @@ def migrate_endpoints(apps, schema_editor): EndpointRule = apps.get_model("terminal", "EndpointRule") xrdp_rule_data = { - 'name': 'XRDP', + 'name': 'Razor', 'ip_group': ['*'], 'priority': 20, 'endpoint': xrdp_endpoint, diff --git a/apps/terminal/migrations/0050_auto_20220606_1745.py b/apps/terminal/migrations/0050_auto_20220606_1745.py new file mode 100644 index 000000000..88e7cc138 --- /dev/null +++ b/apps/terminal/migrations/0050_auto_20220606_1745.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.14 on 2022-06-06 09:45 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('terminal', '0049_endpoint_redis_port'), + ] + + operations = [ + migrations.AlterField( + model_name='terminal', + name='type', + field=models.CharField(choices=[('koko', 'KoKo'), ('guacamole', 'Guacamole'), ('omnidb', 'OmniDB'), ('xrdp', 'Xrdp'), ('lion', 'Lion'), ('core', 'Core'), ('celery', 'Celery'), ('magnus', 'Magnus'), ('razor', 'Razor')], default='koko', max_length=64, verbose_name='type'), + ), + ]