2020-12-05 21:08:42 +00:00
|
|
|
"""authentik URL Configuration"""
|
2019-06-25 16:00:54 +00:00
|
|
|
from django.conf import settings
|
2020-11-23 19:50:19 +00:00
|
|
|
from django.conf.urls.static import static
|
2019-06-25 16:00:54 +00:00
|
|
|
from django.contrib import admin
|
|
|
|
from django.urls import include, path
|
|
|
|
from django.views.generic import RedirectView
|
2020-12-01 08:46:59 +00:00
|
|
|
from django.views.i18n import JavaScriptCatalog
|
2021-01-01 14:39:43 +00:00
|
|
|
from structlog.stdlib import get_logger
|
2019-06-25 16:00:54 +00:00
|
|
|
|
2020-12-05 21:08:42 +00:00
|
|
|
from authentik.core.views import error
|
|
|
|
from authentik.lib.utils.reflection import get_apps
|
|
|
|
from authentik.root.monitoring import MetricsView
|
2019-06-25 16:00:54 +00:00
|
|
|
|
2019-10-04 08:08:53 +00:00
|
|
|
LOGGER = get_logger()
|
2019-06-25 16:00:54 +00:00
|
|
|
admin.autodiscover()
|
2020-05-12 13:21:53 +00:00
|
|
|
admin.site.login = RedirectView.as_view(
|
2020-12-05 21:08:42 +00:00
|
|
|
pattern_name="authentik_flows:default-authentication"
|
2020-05-12 13:21:53 +00:00
|
|
|
)
|
2020-05-10 23:12:57 +00:00
|
|
|
admin.site.logout = RedirectView.as_view(
|
2020-12-05 21:08:42 +00:00
|
|
|
pattern_name="authentik_flows:default-invalidation"
|
2020-05-10 23:12:57 +00:00
|
|
|
)
|
2019-06-25 16:00:54 +00:00
|
|
|
|
|
|
|
handler400 = error.BadRequestView.as_view()
|
|
|
|
handler403 = error.ForbiddenView.as_view()
|
|
|
|
handler404 = error.NotFoundView.as_view()
|
|
|
|
handler500 = error.ServerErrorView.as_view()
|
|
|
|
|
2019-12-31 11:51:16 +00:00
|
|
|
urlpatterns = []
|
2019-06-25 16:00:54 +00:00
|
|
|
|
2020-12-05 21:08:42 +00:00
|
|
|
for _authentik_app in get_apps():
|
2020-08-19 08:32:44 +00:00
|
|
|
mountpoints = None
|
2020-12-05 21:08:42 +00:00
|
|
|
base_url_module = _authentik_app.name + ".urls"
|
|
|
|
if hasattr(_authentik_app, "mountpoint"):
|
|
|
|
mountpoint = getattr(_authentik_app, "mountpoint")
|
2020-08-19 08:32:44 +00:00
|
|
|
mountpoints = {base_url_module: mountpoint}
|
2020-12-05 21:08:42 +00:00
|
|
|
if hasattr(_authentik_app, "mountpoints"):
|
|
|
|
mountpoints = getattr(_authentik_app, "mountpoints")
|
2020-08-19 08:32:44 +00:00
|
|
|
if not mountpoints:
|
|
|
|
continue
|
|
|
|
for module, mountpoint in mountpoints.items():
|
2020-12-05 21:08:42 +00:00
|
|
|
namespace = _authentik_app.label + module.replace(base_url_module, "")
|
2019-12-31 11:51:16 +00:00
|
|
|
_path = path(
|
2020-09-30 17:34:22 +00:00
|
|
|
mountpoint,
|
|
|
|
include(
|
2020-12-05 21:08:42 +00:00
|
|
|
(module, _authentik_app.label),
|
2020-09-30 17:34:22 +00:00
|
|
|
namespace=namespace,
|
|
|
|
),
|
2019-12-31 11:51:16 +00:00
|
|
|
)
|
2019-06-25 16:00:54 +00:00
|
|
|
urlpatterns.append(_path)
|
2020-05-07 18:51:06 +00:00
|
|
|
LOGGER.debug(
|
|
|
|
"Mounted URLs",
|
2020-12-05 21:08:42 +00:00
|
|
|
app_name=_authentik_app.name,
|
2020-08-19 08:32:44 +00:00
|
|
|
mountpoint=mountpoint,
|
|
|
|
namespace=namespace,
|
2020-05-07 18:51:06 +00:00
|
|
|
)
|
2019-06-25 16:00:54 +00:00
|
|
|
|
|
|
|
urlpatterns += [
|
2019-12-31 11:51:16 +00:00
|
|
|
path("administration/django/", admin.site.urls),
|
2020-01-17 09:55:11 +00:00
|
|
|
path("metrics/", MetricsView.as_view(), name="metrics"),
|
2020-12-01 12:16:13 +00:00
|
|
|
path("-/jsi18n/", JavaScriptCatalog.as_view(), name="javascript-catalog"),
|
2019-06-25 16:00:54 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
if settings.DEBUG:
|
|
|
|
import debug_toolbar
|
2019-12-31 11:51:16 +00:00
|
|
|
|
2020-11-23 19:50:19 +00:00
|
|
|
urlpatterns = (
|
|
|
|
[
|
|
|
|
path("-/debug/", include(debug_toolbar.urls)),
|
|
|
|
]
|
2020-11-28 18:43:42 +00:00
|
|
|
+ static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
|
2020-11-24 10:50:27 +00:00
|
|
|
+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
2020-11-23 19:50:19 +00:00
|
|
|
+ urlpatterns
|
|
|
|
)
|