This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
authentik/authentik/root/urls.py

56 lines
1.8 KiB
Python
Raw Normal View History

2020-12-05 21:08:42 +00:00
"""authentik URL Configuration"""
from django.conf import settings
from django.urls import include, path
from structlog.stdlib import get_logger
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 LiveView, MetricsView, ReadyView
LOGGER = get_logger()
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 = []
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
)
urlpatterns.append(_path)
LOGGER.debug(
"Mounted URLs",
2020-12-05 21:08:42 +00:00
app_name=_authentik_app.name,
2021-02-02 14:50:42 +00:00
app_mountpoint=mountpoint,
2020-08-19 08:32:44 +00:00
namespace=namespace,
)
urlpatterns += [
path("-/metrics/", MetricsView.as_view(), name="metrics"),
path("-/health/live/", LiveView.as_view(), name="health-live"),
path("-/health/ready/", ReadyView.as_view(), name="health-ready"),
]
if settings.DEBUG:
urlpatterns += [
path("debug/silk/", include("silk.urls", namespace="silk")),
]