diff --git a/apps/jumpserver/settings.py b/apps/jumpserver/settings.py index 0afcd4e72..b75b73ec9 100644 --- a/apps/jumpserver/settings.py +++ b/apps/jumpserver/settings.py @@ -329,6 +329,9 @@ AUTH_LDAP_GROUP_SEARCH_FILTER = CONFIG.AUTH_LDAP_GROUP_SEARCH_FILTER AUTH_LDAP_GROUP_SEARCH = LDAPSearch( AUTH_LDAP_GROUP_SEARCH_OU, ldap.SCOPE_SUBTREE, AUTH_LDAP_GROUP_SEARCH_FILTER ) +AUTH_LDAP_CONNECTION_OPTIONS = { + ldap.TIMEOUT: 5 +} AUTH_LDAP_ALWAYS_UPDATE_USER = True AUTH_LDAP_BACKEND = 'django_auth_ldap.backend.LDAPBackend' diff --git a/apps/terminal/api.py b/apps/terminal/api.py index a964e9729..eb4b6400a 100644 --- a/apps/terminal/api.py +++ b/apps/terminal/api.py @@ -304,40 +304,24 @@ class SessionReplayViewSet(viewsets.ViewSet): return HttpResponseNotFound() -class SessionReplayV2ViewSet(viewsets.ViewSet): +class SessionReplayV2ViewSet(SessionReplayViewSet): serializer_class = ReplaySerializer permission_classes = (IsSuperUserOrAppUser,) session = None - def gen_session_path(self): - date = self.session.date_start.strftime('%Y-%m-%d') - replay = { - "id": self.session.id, - # "width": 100, - # "heith": 100 - } - if self.session.protocol == "ssh": - replay['type'] = "json" - replay['path'] = os.path.join(date, str(self.session.id) + '.gz') - return replay - elif self.session.protocol == "rdp": - replay['type'] = "mp4" - replay['path'] = os.path.join(date, str(self.session.id) + '.mp4') - return replay - else: - return replay - def retrieve(self, request, *args, **kwargs): session_id = kwargs.get('pk') self.session = get_object_or_404(Session, id=session_id) - replay = self.gen_session_path() + path = self.gen_session_path() + data = { + 'type': 'guacamole' if self.session.protocol == 'rdp' else 'json', + 'src': '', + } - if replay.get("path", "") == "": - return HttpResponseNotFound() - - if default_storage.exists(replay["path"]): - replay["src"] = default_storage.url(replay["path"]) - return Response(replay) + if default_storage.exists(path): + url = default_storage.url(path) + data['src'] = url + return Response(data) else: configs = settings.TERMINAL_REPLAY_STORAGE.items() if not configs: @@ -345,13 +329,15 @@ class SessionReplayV2ViewSet(viewsets.ViewSet): for name, config in configs: client = jms_storage.init(config) + date = self.session.date_start.strftime('%Y-%m-%d') + file_path = os.path.join(date, str(self.session.id) + '.replay.gz') + target_path = default_storage.base_location + '/' + path - target_path = default_storage.base_location + '/' + replay["path"] - - if client and client.has_file(replay["path"]) and \ - client.download_file(replay["path"], target_path): - replay["src"] = default_storage.url(replay["path"]) - return Response(replay) + if client and client.has_file(file_path) and \ + client.download_file(file_path, target_path): + url = default_storage.url(path) + data['src'] = url + return Response(data) return HttpResponseNotFound() diff --git a/apps/terminal/views/session.py b/apps/terminal/views/session.py index 24e323647..3b66baff7 100644 --- a/apps/terminal/views/session.py +++ b/apps/terminal/views/session.py @@ -47,8 +47,7 @@ class SessionListView(AdminUserRequiredMixin, DatetimeSearchMixin, ListView): filter_kwargs['system_user'] = self.system_user if filter_kwargs: self.queryset = self.queryset.filter(**filter_kwargs) - # Todo: 暂时隐藏rdp - return self.queryset.filter(protocol='ssh') + return self.queryset def get_context_data(self, **kwargs): context = {