mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-07-06 19:38:54 +00:00
perf(assets/terminal): 资产系统用户和Session会话添加协议选项: mysql/oracle/postgresql
This commit is contained in:
parent
a3507975fb
commit
8fa15b3378
18
apps/assets/migrations/0059_auto_20201027_1905.py
Normal file
18
apps/assets/migrations/0059_auto_20201027_1905.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 2.2.13 on 2020-10-27 11:05
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('assets', '0058_auto_20201023_1115'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='systemuser',
|
||||||
|
name='protocol',
|
||||||
|
field=models.CharField(choices=[('ssh', 'ssh'), ('rdp', 'rdp'), ('telnet', 'telnet'), ('vnc', 'vnc'), ('mysql', 'mysql'), ('oracle', 'oracle'), ('mariadb', 'mariadb'), ('postgresql', 'postgresql'), ('k8s', 'k8s')], default='ssh', max_length=16, verbose_name='Protocol'),
|
||||||
|
),
|
||||||
|
]
|
@ -72,6 +72,9 @@ class SystemUser(BaseUser):
|
|||||||
PROTOCOL_TELNET = 'telnet'
|
PROTOCOL_TELNET = 'telnet'
|
||||||
PROTOCOL_VNC = 'vnc'
|
PROTOCOL_VNC = 'vnc'
|
||||||
PROTOCOL_MYSQL = 'mysql'
|
PROTOCOL_MYSQL = 'mysql'
|
||||||
|
PROTOCOL_ORACLE = 'oracle'
|
||||||
|
PROTOCOL_MARIADB = 'mariadb'
|
||||||
|
PROTOCOL_POSTGRESQL = 'postgresql'
|
||||||
PROTOCOL_K8S = 'k8s'
|
PROTOCOL_K8S = 'k8s'
|
||||||
PROTOCOL_CHOICES = (
|
PROTOCOL_CHOICES = (
|
||||||
(PROTOCOL_SSH, 'ssh'),
|
(PROTOCOL_SSH, 'ssh'),
|
||||||
@ -79,6 +82,9 @@ class SystemUser(BaseUser):
|
|||||||
(PROTOCOL_TELNET, 'telnet'),
|
(PROTOCOL_TELNET, 'telnet'),
|
||||||
(PROTOCOL_VNC, 'vnc'),
|
(PROTOCOL_VNC, 'vnc'),
|
||||||
(PROTOCOL_MYSQL, 'mysql'),
|
(PROTOCOL_MYSQL, 'mysql'),
|
||||||
|
(PROTOCOL_ORACLE, 'oracle'),
|
||||||
|
(PROTOCOL_MARIADB, 'mariadb'),
|
||||||
|
(PROTOCOL_POSTGRESQL, 'postgresql'),
|
||||||
(PROTOCOL_K8S, 'k8s'),
|
(PROTOCOL_K8S, 'k8s'),
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -127,6 +133,24 @@ class SystemUser(BaseUser):
|
|||||||
def login_mode_display(self):
|
def login_mode_display(self):
|
||||||
return self.get_login_mode_display()
|
return self.get_login_mode_display()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def db_application_protocols(self):
|
||||||
|
return [
|
||||||
|
self.PROTOCOL_MYSQL, self.PROTOCOL_ORACLE, self.PROTOCOL_MARIADB,
|
||||||
|
self.PROTOCOL_POSTGRESQL
|
||||||
|
]
|
||||||
|
|
||||||
|
@property
|
||||||
|
def k8s_application_protocols(self):
|
||||||
|
return [self.PROTOCOL_K8S]
|
||||||
|
|
||||||
|
@property
|
||||||
|
def application_category_protocols(self):
|
||||||
|
protocols = []
|
||||||
|
protocols.extend(self.db_application_protocols)
|
||||||
|
protocols.extend(self.k8s_application_protocols)
|
||||||
|
return protocols
|
||||||
|
|
||||||
def is_need_push(self):
|
def is_need_push(self):
|
||||||
if self.auto_push and self.protocol in [self.PROTOCOL_SSH, self.PROTOCOL_RDP]:
|
if self.auto_push and self.protocol in [self.PROTOCOL_SSH, self.PROTOCOL_RDP]:
|
||||||
return True
|
return True
|
||||||
@ -139,11 +163,11 @@ class SystemUser(BaseUser):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def is_need_test_asset_connective(self):
|
def is_need_test_asset_connective(self):
|
||||||
return self.protocol not in [self.PROTOCOL_MYSQL]
|
return self.protocol not in self.application_category_protocols
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def can_perm_to_asset(self):
|
def can_perm_to_asset(self):
|
||||||
return self.protocol not in [self.PROTOCOL_MYSQL]
|
return self.protocol not in self.application_category_protocols
|
||||||
|
|
||||||
def _merge_auth(self, other):
|
def _merge_auth(self, other):
|
||||||
super()._merge_auth(other)
|
super()._merge_auth(other)
|
||||||
|
@ -60,7 +60,7 @@ class AssetPermissionForm(OrgModelForm):
|
|||||||
# 过滤系统用户
|
# 过滤系统用户
|
||||||
system_users_field = self.fields.get('system_users')
|
system_users_field = self.fields.get('system_users')
|
||||||
system_users_field.queryset = SystemUser.objects.exclude(
|
system_users_field.queryset = SystemUser.objects.exclude(
|
||||||
protocol=SystemUser.PROTOCOL_MYSQL
|
protocol__in=SystemUser.application_category_protocols
|
||||||
)
|
)
|
||||||
|
|
||||||
def set_nodes_initial(self, nodes):
|
def set_nodes_initial(self, nodes):
|
||||||
|
@ -25,7 +25,7 @@ class DatabaseAppPermissionCreateUpdateForm(OrgModelForm):
|
|||||||
# 过滤系统用户
|
# 过滤系统用户
|
||||||
system_users_field = self.fields.get('system_users')
|
system_users_field = self.fields.get('system_users')
|
||||||
system_users_field.queryset = SystemUser.objects.filter(
|
system_users_field.queryset = SystemUser.objects.filter(
|
||||||
protocol=SystemUser.PROTOCOL_MYSQL
|
protocol__in=SystemUser.application_category_protocols
|
||||||
)
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
18
apps/terminal/migrations/0026_auto_20201027_1905.py
Normal file
18
apps/terminal/migrations/0026_auto_20201027_1905.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 2.2.13 on 2020-10-27 11:05
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('terminal', '0025_auto_20200810_1735'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='session',
|
||||||
|
name='protocol',
|
||||||
|
field=models.CharField(choices=[('ssh', 'ssh'), ('rdp', 'rdp'), ('vnc', 'vnc'), ('telnet', 'telnet'), ('mysql', 'mysql'), ('oracle', 'oracle'), ('mariadb', 'mariadb'), ('postgresql', 'postgresql'), ('k8s', 'kubernetes')], db_index=True, default='ssh', max_length=16),
|
||||||
|
),
|
||||||
|
]
|
@ -180,6 +180,9 @@ class Session(OrgModelMixin):
|
|||||||
VNC = 'vnc', 'vnc'
|
VNC = 'vnc', 'vnc'
|
||||||
TELNET = 'telnet', 'telnet'
|
TELNET = 'telnet', 'telnet'
|
||||||
MYSQL = 'mysql', 'mysql'
|
MYSQL = 'mysql', 'mysql'
|
||||||
|
ORACLE = 'oracle', 'oracle'
|
||||||
|
MARIADB = 'mariadb', 'mariadb'
|
||||||
|
POSTGRESQL = 'postgresql', 'postgresql'
|
||||||
K8S = 'k8s', 'kubernetes'
|
K8S = 'k8s', 'kubernetes'
|
||||||
|
|
||||||
id = models.UUIDField(default=uuid.uuid4, primary_key=True)
|
id = models.UUIDField(default=uuid.uuid4, primary_key=True)
|
||||||
@ -196,7 +199,7 @@ class Session(OrgModelMixin):
|
|||||||
has_replay = models.BooleanField(default=False, verbose_name=_("Replay"))
|
has_replay = models.BooleanField(default=False, verbose_name=_("Replay"))
|
||||||
has_command = models.BooleanField(default=False, verbose_name=_("Command"))
|
has_command = models.BooleanField(default=False, verbose_name=_("Command"))
|
||||||
terminal = models.ForeignKey(Terminal, null=True, on_delete=models.SET_NULL)
|
terminal = models.ForeignKey(Terminal, null=True, on_delete=models.SET_NULL)
|
||||||
protocol = models.CharField(choices=PROTOCOL.choices, default='ssh', max_length=8, db_index=True)
|
protocol = models.CharField(choices=PROTOCOL.choices, default='ssh', max_length=16, db_index=True)
|
||||||
date_start = models.DateTimeField(verbose_name=_("Date start"), db_index=True, default=timezone.now)
|
date_start = models.DateTimeField(verbose_name=_("Date start"), db_index=True, default=timezone.now)
|
||||||
date_end = models.DateTimeField(verbose_name=_("Date end"), null=True)
|
date_end = models.DateTimeField(verbose_name=_("Date end"), null=True)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user