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
dependabot[bot] bc9e7e8b93
build(deps): bump structlog from 20.1.0 to 20.2.0 (#445)
* build(deps): bump structlog from 20.1.0 to 20.2.0

Bumps [structlog](https://github.com/hynek/structlog) from 20.1.0 to 20.2.0.
- [Release notes](https://github.com/hynek/structlog/releases)
- [Changelog](https://github.com/hynek/structlog/blob/master/CHANGELOG.rst)
- [Commits](https://github.com/hynek/structlog/compare/20.1.0...20.2.0)

Signed-off-by: dependabot[bot] <support@github.com>

* *: use structlog.stdlib instead of structlog for type-hints

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Jens Langhammer <jens.langhammer@beryju.org>
2021-01-01 15:39:43 +01:00

74 lines
2.3 KiB
Python

"""authentik URL Configuration"""
from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
from django.urls import include, path
from django.views.generic import RedirectView
from django.views.i18n import JavaScriptCatalog
from structlog.stdlib import get_logger
from authentik.core.views import error
from authentik.lib.utils.reflection import get_apps
from authentik.root.monitoring import MetricsView
LOGGER = get_logger()
admin.autodiscover()
admin.site.login = RedirectView.as_view(
pattern_name="authentik_flows:default-authentication"
)
admin.site.logout = RedirectView.as_view(
pattern_name="authentik_flows:default-invalidation"
)
handler400 = error.BadRequestView.as_view()
handler403 = error.ForbiddenView.as_view()
handler404 = error.NotFoundView.as_view()
handler500 = error.ServerErrorView.as_view()
urlpatterns = []
for _authentik_app in get_apps():
mountpoints = None
base_url_module = _authentik_app.name + ".urls"
if hasattr(_authentik_app, "mountpoint"):
mountpoint = getattr(_authentik_app, "mountpoint")
mountpoints = {base_url_module: mountpoint}
if hasattr(_authentik_app, "mountpoints"):
mountpoints = getattr(_authentik_app, "mountpoints")
if not mountpoints:
continue
for module, mountpoint in mountpoints.items():
namespace = _authentik_app.label + module.replace(base_url_module, "")
_path = path(
mountpoint,
include(
(module, _authentik_app.label),
namespace=namespace,
),
)
urlpatterns.append(_path)
LOGGER.debug(
"Mounted URLs",
app_name=_authentik_app.name,
mountpoint=mountpoint,
namespace=namespace,
)
urlpatterns += [
path("administration/django/", admin.site.urls),
path("metrics/", MetricsView.as_view(), name="metrics"),
path("-/jsi18n/", JavaScriptCatalog.as_view(), name="javascript-catalog"),
]
if settings.DEBUG:
import debug_toolbar
urlpatterns = (
[
path("-/debug/", include(debug_toolbar.urls)),
]
+ static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
+ urlpatterns
)