diff --git a/apps/applications/api/remote_app.py b/apps/applications/api/remote_app.py index 79beef8fc..4bd9109fb 100644 --- a/apps/applications/api/remote_app.py +++ b/apps/applications/api/remote_app.py @@ -15,7 +15,7 @@ __all__ = [ class RemoteAppViewSet(OrgBulkModelViewSet): model = RemoteApp - filter_fields = ('name',) + filter_fields = ('name', 'type', 'comment') search_fields = filter_fields permission_classes = (IsOrgAdmin,) serializer_class = RemoteAppSerializer diff --git a/apps/authentication/urls/view_urls.py b/apps/authentication/urls/view_urls.py index bee5f8517..62283f1f5 100644 --- a/apps/authentication/urls/view_urls.py +++ b/apps/authentication/urls/view_urls.py @@ -18,4 +18,5 @@ urlpatterns = [ # openid path('cas/', include(('authentication.backends.cas.urls', 'authentication'), namespace='cas')), path('openid/', include(('jms_oidc_rp.urls', 'authentication'), namespace='openid')), + path('captcha/', include('captcha.urls')), ] diff --git a/apps/jumpserver/urls.py b/apps/jumpserver/urls.py index ade854397..a43a9ea6b 100644 --- a/apps/jumpserver/urls.py +++ b/apps/jumpserver/urls.py @@ -43,6 +43,11 @@ app_view_patterns = [ path('applications/', include('applications.urls.views_urls', namespace='applications')), path('tickets/', include('tickets.urls.views_urls', namespace='tickets')), re_path(r'flower/(?P.*)', views.celery_flower_view, name='flower-view'), + re_path('luna/.*', views.LunaView.as_view(), name='luna-view'), + re_path('koko/.*', views.KokoView.as_view(), name='koko-view'), + re_path('ws/.*', views.WsView.as_view(), name='ws-view'), + path('i18n//', views.I18NView.as_view(), name='i18n-switch'), + path('settings/', include('settings.urls.view_urls', namespace='settings')), ] @@ -59,32 +64,38 @@ js_i18n_patterns = i18n_patterns( ) +apps = [ + 'users', 'assets', 'perms', 'terminal', 'ops', 'audits', 'orgs', 'auth', + 'applications', 'tickets', 'settings', 'xpack' + 'flower', 'luna', 'koko', 'ws', 'i18n', 'jsi18n', 'docs', 'redocs', + 'zh-hans' +] + + urlpatterns = [ path('', views.IndexView.as_view(), name='index'), path('api/v1/', include(api_v1)), path('api/v2/', include(api_v2)), re_path('api/(?P\w+)/(?Pv\d)/.*', views.redirect_format_api), path('api/health/', views.HealthCheckView.as_view(), name="health"), - re_path('luna/.*', views.LunaView.as_view(), name='luna-view'), - re_path('koko/.*', views.KokoView.as_view(), name='koko-view'), - re_path('ws/.*', views.WsView.as_view(), name='ws-view'), - path('i18n//', views.I18NView.as_view(), name='i18n-switch'), - path('settings/', include('settings.urls.view_urls', namespace='settings')), - # External apps url - path('captcha/', include('captcha.urls')), + path('core/auth/captcha/', include('captcha.urls')), + path('core/', include(app_view_patterns)), ] -urlpatterns += app_view_patterns urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) \ + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) urlpatterns += js_i18n_patterns +# 兼容之前的 +old_app_pattern = '|'.join(apps) +urlpatterns += [re_path(old_app_pattern, views.redirect_old_apps_view)] + handler404 = 'jumpserver.views.handler404' handler500 = 'jumpserver.views.handler500' if settings.DEBUG: - urlpatterns += [ + app_view_patterns += [ re_path('^swagger(?P\.json|\.yaml)$', views.get_swagger_view().without_ui(cache_timeout=1), name='schema-json'), path('docs/', views.get_swagger_view().with_ui('swagger', cache_timeout=1), name="docs"), diff --git a/apps/jumpserver/views/other.py b/apps/jumpserver/views/other.py index a1db94e77..17a7dfd6c 100644 --- a/apps/jumpserver/views/other.py +++ b/apps/jumpserver/views/other.py @@ -3,7 +3,7 @@ import re import time -from django.http import HttpResponseRedirect, JsonResponse +from django.http import HttpResponseRedirect, JsonResponse, Http404 from django.conf import settings from django.views.generic import View from django.utils.translation import ugettext_lazy as _ @@ -16,7 +16,7 @@ from common.http import HttpResponseTemporaryRedirect __all__ = [ 'LunaView', 'I18NView', 'KokoView', 'WsView', 'HealthCheckView', - 'redirect_format_api' + 'redirect_format_api', 'redirect_old_apps_view' ] @@ -51,6 +51,14 @@ def redirect_format_api(request, *args, **kwargs): return JsonResponse({"msg": "Redirect url failed: {}".format(_path)}, status=404) +def redirect_old_apps_view(request, *args, **kwargs): + path = request.get_full_path() + if path.find('/core') != -1: + raise Http404() + new_path = '/core{}'.format(path) + return HttpResponseTemporaryRedirect(new_path) + + class HealthCheckView(APIView): permission_classes = () diff --git a/apps/perms/api/user_database_app_permission.py b/apps/perms/api/user_database_app_permission.py index 3a973b8c1..19885d2ef 100644 --- a/apps/perms/api/user_database_app_permission.py +++ b/apps/perms/api/user_database_app_permission.py @@ -26,8 +26,8 @@ __all__ = [ class UserGrantedDatabaseAppsApi(generics.ListAPIView): permission_classes = (IsOrgAdminOrAppUser,) serializer_class = DatabaseAppSerializer - filter_fields = ['id', 'name'] - search_fields = ['name'] + filter_fields = ['id', 'name', 'type', 'comment'] + search_fields = ['name', 'comment'] def get_object(self): user_id = self.kwargs.get('pk', '') diff --git a/apps/perms/api/user_remote_app_permission.py b/apps/perms/api/user_remote_app_permission.py index 51a9217ce..8dca299a3 100644 --- a/apps/perms/api/user_remote_app_permission.py +++ b/apps/perms/api/user_remote_app_permission.py @@ -26,8 +26,8 @@ __all__ = [ class UserGrantedRemoteAppsApi(generics.ListAPIView): permission_classes = (IsOrgAdminOrAppUser,) serializer_class = RemoteAppSerializer - filter_fields = ['name', 'id'] - search_fields = ['name'] + filter_fields = ['name', 'id', 'type', 'comment'] + search_fields = ['name', 'comment'] def get_object(self): user_id = self.kwargs.get('pk', '') diff --git a/apps/static/js/jumpserver.js b/apps/static/js/jumpserver.js index 9081d3a94..b930154ff 100644 --- a/apps/static/js/jumpserver.js +++ b/apps/static/js/jumpserver.js @@ -138,11 +138,11 @@ function setAjaxCSRFToken() { } function activeNav(prefix) { - var path = document.location.pathname; - if (prefix) { - path = path.replace(prefix, ''); - console.log(path); + if (!prefix) { + prefix = '/core' } + var path = document.location.pathname; + path = path.replace(prefix, ''); var urlArray = path.split("/"); var app = urlArray[1]; var resource = urlArray[2];