Merge pull request #8610 from jumpserver/dev

v2.24.0-rc3
pull/8658/head
Jiangjie.Bai 2022-07-18 12:02:23 +08:00 committed by GitHub
commit 4d7f8ffc71
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 17 additions and 6 deletions

View File

@ -43,7 +43,7 @@ __all__ = [
class NodeViewSet(SuggestionMixin, OrgBulkModelViewSet): class NodeViewSet(SuggestionMixin, OrgBulkModelViewSet):
model = Node model = Node
filterset_fields = ('value', 'key', 'id') filterset_fields = ('value', 'key', 'id')
search_fields = ('value',) search_fields = ('full_value',)
serializer_class = serializers.NodeSerializer serializer_class = serializers.NodeSerializer
rbac_perms = { rbac_perms = {
'match': 'assets.match_node', 'match': 'assets.match_node',

View File

@ -91,6 +91,11 @@ class ConnectionTokenMixin:
"config": rdp_config "config": rdp_config
} }
def get_host(self, endpoint):
if not endpoint.host:
return self.request.get_host()
return endpoint.host
def get_rdp_file_info(self, token: ConnectionToken): def get_rdp_file_info(self, token: ConnectionToken):
rdp_options = { rdp_options = {
'full address:s': '', 'full address:s': '',
@ -140,7 +145,9 @@ class ConnectionTokenMixin:
endpoint = self.get_smart_endpoint( endpoint = self.get_smart_endpoint(
protocol='rdp', asset=token.asset, application=token.application protocol='rdp', asset=token.asset, application=token.application
) )
rdp_options['full address:s'] = f'{endpoint.host}:{endpoint.rdp_port}' # TODO 暂时获取一下host后续优化
host = self.get_host(endpoint)
rdp_options['full address:s'] = f'{host}:{endpoint.rdp_port}'
# 设置用户名 # 设置用户名
rdp_options['username:s'] = '{}|{}'.format(token.user.username, str(token.id)) rdp_options['username:s'] = '{}|{}'.format(token.user.username, str(token.id))
@ -192,8 +199,10 @@ class ConnectionTokenMixin:
endpoint = self.get_smart_endpoint( endpoint = self.get_smart_endpoint(
protocol='ssh', asset=token.asset, application=token.application protocol='ssh', asset=token.asset, application=token.application
) )
# TODO 暂时获取一下host后续优化
host = self.get_host(endpoint)
data = { data = {
'ip': endpoint.host, 'ip': host,
'port': str(endpoint.ssh_port), 'port': str(endpoint.ssh_port),
'username': 'JMS-{}'.format(str(token.id)), 'username': 'JMS-{}'.format(str(token.id)),
'password': token.secret 'password': token.secret

View File

@ -4959,7 +4959,7 @@ msgstr "リンク期限切れ"
#: terminal/models/sharing.py:68 #: terminal/models/sharing.py:68
msgid "User not allowed to join" msgid "User not allowed to join"
msgstr "IPは許可されていません" msgstr "ユーザーはセッションに参加できません"
#: terminal/models/sharing.py:85 terminal/serializers/sharing.py:59 #: terminal/models/sharing.py:85 terminal/serializers/sharing.py:59
msgid "Joiner" msgid "Joiner"

View File

@ -4883,7 +4883,7 @@ msgstr "链接过期"
#: terminal/models/sharing.py:68 #: terminal/models/sharing.py:68
msgid "User not allowed to join" msgid "User not allowed to join"
msgstr "来源 IP 不被允许登录" msgstr "该用户无权加入会话"
#: terminal/models/sharing.py:85 terminal/serializers/sharing.py:59 #: terminal/models/sharing.py:85 terminal/serializers/sharing.py:59
msgid "Joiner" msgid "Joiner"

View File

@ -43,6 +43,8 @@ class SessionSharing(CommonModelMixin, OrgModelMixin):
return 'Creator: {}'.format(self.creator) return 'Creator: {}'.format(self.creator)
def users_display(self): def users_display(self):
if not self.users:
return []
with tmp_to_root_org(): with tmp_to_root_org():
user_ids = self.users.split(',') user_ids = self.users.split(',')
users = User.objects.filter(id__in=user_ids) users = User.objects.filter(id__in=user_ids)

View File

@ -62,7 +62,7 @@ jsonfield2==4.0.0.post0
geoip2==4.5.0 geoip2==4.5.0
ipip-ipdb==1.6.1 ipip-ipdb==1.6.1
# Django environment # Django environment
Django==3.2.14 Django==3.2.13
django-bootstrap3==14.2.0 django-bootstrap3==14.2.0
django-filter==2.4.0 django-filter==2.4.0
django-formtools==2.2 django-formtools==2.2