2016-11-24 10:22:36 +00:00
|
|
|
# ~*~ coding: utf-8 ~*~
|
|
|
|
from __future__ import unicode_literals
|
2022-07-05 11:52:00 +00:00
|
|
|
import os
|
2016-11-24 10:22:36 +00:00
|
|
|
|
2018-07-27 10:56:40 +00:00
|
|
|
from django.urls import path, include, re_path
|
2016-08-17 14:17:16 +00:00
|
|
|
from django.conf import settings
|
|
|
|
from django.conf.urls.static import static
|
2020-11-09 10:02:26 +00:00
|
|
|
from django.views.i18n import JavaScriptCatalog
|
2016-08-23 15:29:33 +00:00
|
|
|
|
2020-05-08 07:41:56 +00:00
|
|
|
from . import views, api
|
2018-11-23 02:25:35 +00:00
|
|
|
|
2019-03-11 02:06:45 +00:00
|
|
|
api_v1 = [
|
2020-05-08 07:41:56 +00:00
|
|
|
path('index/', api.IndexApi.as_view()),
|
2019-10-30 05:18:11 +00:00
|
|
|
path('users/', include('users.urls.api_urls', namespace='api-users')),
|
|
|
|
path('assets/', include('assets.urls.api_urls', namespace='api-assets')),
|
2023-01-16 11:02:09 +00:00
|
|
|
path('accounts/', include('accounts.urls', namespace='api-accounts')),
|
2019-10-30 05:18:11 +00:00
|
|
|
path('perms/', include('perms.urls.api_urls', namespace='api-perms')),
|
|
|
|
path('terminal/', include('terminal.urls.api_urls', namespace='api-terminal')),
|
|
|
|
path('ops/', include('ops.urls.api_urls', namespace='api-ops')),
|
|
|
|
path('audits/', include('audits.urls.api_urls', namespace='api-audits')),
|
|
|
|
path('orgs/', include('orgs.urls.api_urls', namespace='api-orgs')),
|
|
|
|
path('settings/', include('settings.urls.api_urls', namespace='api-settings')),
|
|
|
|
path('authentication/', include('authentication.urls.api_urls', namespace='api-auth')),
|
|
|
|
path('common/', include('common.urls.api_urls', namespace='api-common')),
|
2019-11-07 10:06:58 +00:00
|
|
|
path('tickets/', include('tickets.urls.api_urls', namespace='api-tickets')),
|
2021-03-11 12:17:44 +00:00
|
|
|
path('acls/', include('acls.urls.api_urls', namespace='api-acls')),
|
2021-06-11 09:11:29 +00:00
|
|
|
path('notifications/', include('notifications.urls.api_urls', namespace='api-notifications')),
|
2022-02-17 12:13:31 +00:00
|
|
|
path('rbac/', include('rbac.urls.api_urls', namespace='api-rbac')),
|
2021-03-24 11:01:35 +00:00
|
|
|
path('prometheus/metrics/', api.PrometheusMetricsApi.as_view()),
|
2018-11-23 02:25:35 +00:00
|
|
|
]
|
2016-08-23 15:29:33 +00:00
|
|
|
|
2020-06-03 02:38:44 +00:00
|
|
|
app_view_patterns = [
|
|
|
|
path('auth/', include('authentication.urls.view_urls'), name='auth'),
|
2020-06-04 07:10:02 +00:00
|
|
|
path('ops/', include('ops.urls.view_urls'), name='ops'),
|
2022-05-05 05:07:48 +00:00
|
|
|
path('tickets/', include('tickets.urls.view_urls'), name='tickets'),
|
2021-04-29 09:15:46 +00:00
|
|
|
path('common/', include('common.urls.view_urls'), name='common'),
|
2020-06-04 07:10:02 +00:00
|
|
|
re_path(r'flower/(?P<path>.*)', views.celery_flower_view, name='flower-view'),
|
2022-03-02 12:48:43 +00:00
|
|
|
path('download/', views.ResourceDownload.as_view(), name='download'),
|
|
|
|
path('i18n/<str:lang>/', views.I18NView.as_view(), name='i18n-switch'),
|
2020-06-03 02:38:44 +00:00
|
|
|
]
|
|
|
|
|
2018-08-03 02:25:41 +00:00
|
|
|
if settings.XPACK_ENABLED:
|
2019-07-03 10:03:01 +00:00
|
|
|
api_v1.append(
|
2019-08-21 12:27:21 +00:00
|
|
|
path('xpack/', include('xpack.urls.api_urls', namespace='api-xpack'))
|
2019-07-03 10:03:01 +00:00
|
|
|
)
|
2018-08-02 04:36:31 +00:00
|
|
|
|
2018-07-12 16:31:50 +00:00
|
|
|
urlpatterns = [
|
2019-09-19 13:21:05 +00:00
|
|
|
path('', views.IndexView.as_view(), name='index'),
|
2019-08-21 12:27:21 +00:00
|
|
|
path('api/v1/', include(api_v1)),
|
2019-09-19 13:21:05 +00:00
|
|
|
re_path('api/(?P<app>\w+)/(?P<version>v\d)/.*', views.redirect_format_api),
|
2021-04-13 08:21:51 +00:00
|
|
|
path('api/health/', api.HealthCheckView.as_view(), name="health"),
|
|
|
|
path('api/v1/health/', api.HealthCheckView.as_view(), name="health_v1"),
|
2017-12-18 10:38:30 +00:00
|
|
|
# External apps url
|
2020-05-27 10:02:18 +00:00
|
|
|
path('core/auth/captcha/', include('captcha.urls')),
|
|
|
|
path('core/', include(app_view_patterns)),
|
2020-12-08 06:26:18 +00:00
|
|
|
path('ui/', views.UIView.as_view()),
|
2016-08-08 16:43:11 +00:00
|
|
|
]
|
2019-03-11 02:06:45 +00:00
|
|
|
|
2020-12-14 03:25:34 +00:00
|
|
|
# 静态文件处理路由
|
2018-04-14 04:18:15 +00:00
|
|
|
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) \
|
2023-01-16 11:02:09 +00:00
|
|
|
+ static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
|
2020-11-09 10:02:26 +00:00
|
|
|
|
2020-12-14 03:25:34 +00:00
|
|
|
# js i18n 路由文件
|
|
|
|
urlpatterns += [
|
2020-11-17 08:15:43 +00:00
|
|
|
path('core/jsi18n/', JavaScriptCatalog.as_view(), name='javascript-catalog'),
|
|
|
|
]
|
2018-11-23 02:25:35 +00:00
|
|
|
|
2020-12-14 03:25:34 +00:00
|
|
|
# docs 路由
|
|
|
|
urlpatterns += [
|
|
|
|
re_path('^api/swagger(?P<format>\.json|\.yaml)$',
|
|
|
|
views.get_swagger_view().without_ui(cache_timeout=1), name='schema-json'),
|
|
|
|
re_path('api/docs/?', views.get_swagger_view().with_ui('swagger', cache_timeout=1), name="docs"),
|
|
|
|
re_path('api/redoc/?', views.get_swagger_view().with_ui('redoc', cache_timeout=1), name='redoc'),
|
|
|
|
]
|
2019-06-24 12:16:18 +00:00
|
|
|
|
2022-07-05 11:52:00 +00:00
|
|
|
if os.environ.get('DEBUG_TOOLBAR', False):
|
2022-06-29 06:48:54 +00:00
|
|
|
urlpatterns += [
|
|
|
|
path('__debug__/', include('debug_toolbar.urls')),
|
|
|
|
]
|
|
|
|
|
2020-12-14 03:25:34 +00:00
|
|
|
handler404 = 'jumpserver.views.handler404'
|
|
|
|
handler500 = 'jumpserver.views.handler500'
|