pull/4049/head
Bai 2020-05-28 15:03:07 +08:00
commit 25c3691f6b
7 changed files with 40 additions and 20 deletions

View File

@ -15,7 +15,7 @@ __all__ = [
class RemoteAppViewSet(OrgBulkModelViewSet): class RemoteAppViewSet(OrgBulkModelViewSet):
model = RemoteApp model = RemoteApp
filter_fields = ('name',) filter_fields = ('name', 'type', 'comment')
search_fields = filter_fields search_fields = filter_fields
permission_classes = (IsOrgAdmin,) permission_classes = (IsOrgAdmin,)
serializer_class = RemoteAppSerializer serializer_class = RemoteAppSerializer

View File

@ -18,4 +18,5 @@ urlpatterns = [
# openid # openid
path('cas/', include(('authentication.backends.cas.urls', 'authentication'), namespace='cas')), path('cas/', include(('authentication.backends.cas.urls', 'authentication'), namespace='cas')),
path('openid/', include(('jms_oidc_rp.urls', 'authentication'), namespace='openid')), path('openid/', include(('jms_oidc_rp.urls', 'authentication'), namespace='openid')),
path('captcha/', include('captcha.urls')),
] ]

View File

@ -43,6 +43,11 @@ app_view_patterns = [
path('applications/', include('applications.urls.views_urls', namespace='applications')), path('applications/', include('applications.urls.views_urls', namespace='applications')),
path('tickets/', include('tickets.urls.views_urls', namespace='tickets')), path('tickets/', include('tickets.urls.views_urls', namespace='tickets')),
re_path(r'flower/(?P<path>.*)', views.celery_flower_view, name='flower-view'), re_path(r'flower/(?P<path>.*)', 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/<str:lang>/', 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 = [ urlpatterns = [
path('', views.IndexView.as_view(), name='index'), path('', views.IndexView.as_view(), name='index'),
path('api/v1/', include(api_v1)), path('api/v1/', include(api_v1)),
path('api/v2/', include(api_v2)), path('api/v2/', include(api_v2)),
re_path('api/(?P<app>\w+)/(?P<version>v\d)/.*', views.redirect_format_api), re_path('api/(?P<app>\w+)/(?P<version>v\d)/.*', views.redirect_format_api),
path('api/health/', views.HealthCheckView.as_view(), name="health"), 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/<str:lang>/', views.I18NView.as_view(), name='i18n-switch'),
path('settings/', include('settings.urls.view_urls', namespace='settings')),
# External apps url # 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) \ urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) \
+ static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
urlpatterns += js_i18n_patterns urlpatterns += js_i18n_patterns
# 兼容之前的
old_app_pattern = '|'.join(apps)
urlpatterns += [re_path(old_app_pattern, views.redirect_old_apps_view)]
handler404 = 'jumpserver.views.handler404' handler404 = 'jumpserver.views.handler404'
handler500 = 'jumpserver.views.handler500' handler500 = 'jumpserver.views.handler500'
if settings.DEBUG: if settings.DEBUG:
urlpatterns += [ app_view_patterns += [
re_path('^swagger(?P<format>\.json|\.yaml)$', re_path('^swagger(?P<format>\.json|\.yaml)$',
views.get_swagger_view().without_ui(cache_timeout=1), name='schema-json'), 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"), path('docs/', views.get_swagger_view().with_ui('swagger', cache_timeout=1), name="docs"),

View File

@ -3,7 +3,7 @@
import re import re
import time import time
from django.http import HttpResponseRedirect, JsonResponse from django.http import HttpResponseRedirect, JsonResponse, Http404
from django.conf import settings from django.conf import settings
from django.views.generic import View from django.views.generic import View
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
@ -16,7 +16,7 @@ from common.http import HttpResponseTemporaryRedirect
__all__ = [ __all__ = [
'LunaView', 'I18NView', 'KokoView', 'WsView', 'HealthCheckView', '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) 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): class HealthCheckView(APIView):
permission_classes = () permission_classes = ()

View File

@ -26,8 +26,8 @@ __all__ = [
class UserGrantedDatabaseAppsApi(generics.ListAPIView): class UserGrantedDatabaseAppsApi(generics.ListAPIView):
permission_classes = (IsOrgAdminOrAppUser,) permission_classes = (IsOrgAdminOrAppUser,)
serializer_class = DatabaseAppSerializer serializer_class = DatabaseAppSerializer
filter_fields = ['id', 'name'] filter_fields = ['id', 'name', 'type', 'comment']
search_fields = ['name'] search_fields = ['name', 'comment']
def get_object(self): def get_object(self):
user_id = self.kwargs.get('pk', '') user_id = self.kwargs.get('pk', '')

View File

@ -26,8 +26,8 @@ __all__ = [
class UserGrantedRemoteAppsApi(generics.ListAPIView): class UserGrantedRemoteAppsApi(generics.ListAPIView):
permission_classes = (IsOrgAdminOrAppUser,) permission_classes = (IsOrgAdminOrAppUser,)
serializer_class = RemoteAppSerializer serializer_class = RemoteAppSerializer
filter_fields = ['name', 'id'] filter_fields = ['name', 'id', 'type', 'comment']
search_fields = ['name'] search_fields = ['name', 'comment']
def get_object(self): def get_object(self):
user_id = self.kwargs.get('pk', '') user_id = self.kwargs.get('pk', '')

View File

@ -138,11 +138,11 @@ function setAjaxCSRFToken() {
} }
function activeNav(prefix) { function activeNav(prefix) {
var path = document.location.pathname; if (!prefix) {
if (prefix) { prefix = '/core'
path = path.replace(prefix, '');
console.log(path);
} }
var path = document.location.pathname;
path = path.replace(prefix, '');
var urlArray = path.split("/"); var urlArray = path.split("/");
var app = urlArray[1]; var app = urlArray[1];
var resource = urlArray[2]; var resource = urlArray[2];