-
Notifications
You must be signed in to change notification settings - Fork 1
/
urls.py
109 lines (98 loc) · 6.07 KB
/
urls.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
from django.contrib import admin
from django.conf import settings
from django.conf.urls.static import static
from django.urls import include, path, re_path
from django.utils.translation import gettext_lazy as _
from django.views.generic import TemplateView
from django.views.generic.base import RedirectView
from drf_spectacular.views import SpectacularAPIView, SpectacularSwaggerView
from mozilla_django_oidc.urls import OIDCCallbackClass,OIDCAuthenticateClass
from mozilla_django_oidc.views import OIDCLogoutView
from rest_framework_simplejwt.views import (
TokenObtainPairView,
TokenRefreshView,
TokenVerifyView
)
from api.routers import GeoshopRouter
from api import views
import oidc
# Use ROOTURL from settings to prefix all urls
ROOTURL = getattr(settings, 'ROOTURL', '')
# Ensure ROOTURL is properly formatted
if ROOTURL.startswith('/'):
ROOTURL = ROOTURL[1:]
if not ROOTURL.endswith('/') and not ROOTURL == '':
ROOTURL += '/'
admin.site.site_header = _("GeoShop Administration")
admin.site.site_title = _("GeoShop Admin")
router = GeoshopRouter()
router.register(r'contact', views.ContactViewSet, basename='contact')
router.register(r'copyright', views.CopyrightViewSet)
router.register(r'document', views.DocumentViewSet)
router.register(r'dataformat', views.DataFormatViewSet)
router.register(r'identity', views.IdentityViewSet, basename='identity')
router.register(r'metadata', views.MetadataViewSet, basename='metadata')
router.register(r'order', views.OrderViewSet, basename='order')
router.register(r'orderitem', views.OrderItemViewSet, basename='orderitem')
router.register(r'ordertype', views.OrderTypeViewSet)
router.register(r'product', views.ProductViewSet, basename='product')
router.register(r'productformat', views.ProductFormatViewSet)
router.register(r'pricing', views.PricingViewSet)
router.register_additional_route_to_root(f'{ROOTURL}extract/order/', 'extract_order')
router.register_additional_route_to_root(f'{ROOTURL}extract/order/fake', 'extract_order_fake')
router.register_additional_route_to_root(f'{ROOTURL}extract/orderitem/', 'extract_orderitem')
router.register_additional_route_to_root(f'{ROOTURL}token', 'token_obtain_pair')
router.register_additional_route_to_root(f'{ROOTURL}token/refresh', 'token_refresh')
router.register_additional_route_to_root(f'{ROOTURL}token/verify', 'token_verify')
router.register_additional_route_to_root(f'{ROOTURL}auth/change', 'auth_change_user')
router.register_additional_route_to_root(f'{ROOTURL}auth/current', 'auth_current_user')
router.register_additional_route_to_root(f'{ROOTURL}auth/password', 'auth_password')
router.register_additional_route_to_root(f'{ROOTURL}auth/password/confirm', 'auth_password_confirm')
# Wire up our API using automatic URL routing.
# Additionally, we include login URLs for the browsable API.
urlpatterns = [
# this url is used to generate email content
#TODO FIXME: the favicon is not served correctly
path('favicon.ico', RedirectView.as_view(url='{}api/favicon.ico'.format(settings.STATIC_URL))),
re_path(rf'^{ROOTURL}auth/reset/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$',
TemplateView.as_view(),
name='password_reset_confirm'),
path(f'{ROOTURL}auth/change/', views.UserChangeView.as_view(), name='auth_change_user'),
path(f'{ROOTURL}auth/current/', views.CurrentUserView.as_view(), name='auth_current_user'),
path(f'{ROOTURL}download/<uuid:guid>', views.OrderByUUIDView.as_view(), name='order_uuid'),
path(f'{ROOTURL}download/<uuid:guid>/result', views.DownloadView.as_view(), name='download_by_uuid'),
path(f'{ROOTURL}auth/password/', views.PasswordResetView.as_view(),name='auth_password'),
path(f'{ROOTURL}auth/password/confirm', views.PasswordResetConfirmView.as_view(), name='auth_password_confirm'),
path(f'{ROOTURL}auth/verify-email/', views.VerifyEmailView.as_view(), name='auth_verify_email'),
re_path(rf'^{ROOTURL}auth/account-confirm-email/(?P<key>[-:\w]+)/$', TemplateView.as_view(),
name='account_confirm_email'),
path(f'{ROOTURL}extract/order/', views.ExtractOrderView.as_view(), name='extract_order'),
path(f'{ROOTURL}extract/orderitem/', views.ExtractOrderItemView.as_view(), name='extract_orderitem'),
re_path(rf'^{ROOTURL}extract/orderitem/(?P<pk>[0-9]+)$',
views.ExtractOrderItemView.as_view(), name='extract_orderitem'),
path(f'{ROOTURL}token/', TokenObtainPairView.as_view(), name='token_obtain_pair'),
path(f'{ROOTURL}token/refresh/', TokenRefreshView.as_view(), name='token_refresh'),
path(f'{ROOTURL}token/verify/', TokenVerifyView.as_view(), name='token_verify'),
path(f'{ROOTURL}session-auth/', include('rest_framework.urls', namespace='rest_framework')),
re_path(rf'^{ROOTURL}validate/orderitem/(?P<token>[a-zA-Z0-9_-]+)$',
views.OrderItemByTokenView.as_view(), name='orderitem_validate'),
path(f'{ROOTURL}admin/', admin.site.urls, name='admin'),
path(f'{ROOTURL}', include(router.urls)),
path(f'{ROOTURL}docs/schema', SpectacularAPIView.as_view(), name='schema'),
path(f'{ROOTURL}docs/', SpectacularSwaggerView.as_view(url_name='schema'), name='swagger-ui'),
path(f'{ROOTURL}health/', include('health_check.urls')),
] + static(settings.STATIC_URL,document_root=settings.STATIC_ROOT) + static(settings.MEDIA_URL,document_root=settings.MEDIA_ROOT)
# OIDC links if OIDC is enabled
if settings.FEATURE_FLAGS["oidc"]:
urlpatterns += [
path(f'{ROOTURL}oidc/token', oidc.FrontendAuthentication.as_view(), name='oidc_validate_token'),
path(f'{ROOTURL}oidc/callback', OIDCCallbackClass.as_view(), name='oidc_authentication_callback'),
path(f'{ROOTURL}oidc/authenticate/', OIDCAuthenticateClass.as_view(), name='oidc_authentication_init'),
path(f'{ROOTURL}oidc/logout', OIDCLogoutView.as_view(), name='oidc_logout'),
]
# Registration links if registration is enabled
if settings.FEATURE_FLAGS["registration"]:
router.register_additional_route_to_root(f'{ROOTURL}auth/register', 'auth_register')
urlpatterns += [
path(f'{ROOTURL}auth/register/', views.RegisterView.as_view(), name='auth_register'),
]