authentik.root.urls
authentik URL Configuration
1"""authentik URL Configuration""" 2 3from importlib import import_module 4 5from django.urls import include, path 6from django.views import View 7from structlog.stdlib import get_logger 8 9from authentik.core.views import error 10from authentik.lib.config import CONFIG 11from authentik.lib.utils.reflection import get_apps 12from authentik.lib.utils.urls import sort_hot 13from authentik.root.monitoring import MetricsView, ReadyView 14 15LOGGER = get_logger() 16 17handler400 = error.BadRequestView.as_view() 18handler403 = error.ForbiddenView.as_view() 19handler404 = error.NotFoundView.as_view() 20handler500 = error.ServerErrorView.as_view() 21 22_urlpatterns = [] 23 24for _authentik_app in get_apps(): 25 mountpoints = None 26 base_url_module = _authentik_app.name + ".urls" 27 if hasattr(_authentik_app, "mountpoint"): 28 mountpoint = _authentik_app.mountpoint 29 mountpoints = {base_url_module: mountpoint} 30 if hasattr(_authentik_app, "mountpoints"): 31 mountpoints = _authentik_app.mountpoints 32 if not mountpoints: 33 continue 34 for module, mountpoint in mountpoints.items(): 35 namespace = _authentik_app.label + module.replace(base_url_module, "") 36 _path = path( 37 mountpoint, 38 include( 39 (sort_hot(import_module(module).urlpatterns), _authentik_app.label), 40 namespace=namespace, 41 ), 42 ) 43 _urlpatterns.append(_path) 44 LOGGER.debug( 45 "Mounted URLs", 46 app_name=_authentik_app.name, 47 app_mountpoint=mountpoint, 48 namespace=namespace, 49 ) 50 51urlpatterns = [ 52 path(CONFIG.get("web.path", "/")[1:], include(sort_hot(_urlpatterns))), 53 path("-/metrics/", MetricsView.as_view(), name="metrics"), 54 # Stub view, this is handled by `LivenessMiddleware`, this path is merely here 55 # for reversing the URL 56 path("-/health/live/", View.as_view(), name="health-live"), 57 path("-/health/ready/", ReadyView.as_view(), name="health-ready"), 58]
LOGGER =
<BoundLoggerLazyProxy(logger=None, wrapper_class=None, processors=None, context_class=None, initial_values={}, logger_factory_args=())>
def
handler400(request, *args, **kwargs):
98 def view(request, *args, **kwargs): 99 self = cls(**initkwargs) 100 self.setup(request, *args, **kwargs) 101 if not hasattr(self, "request"): 102 raise AttributeError( 103 "%s instance has no 'request' attribute. Did you override " 104 "setup() and forget to call super()?" % cls.__name__ 105 ) 106 return self.dispatch(request, *args, **kwargs)
Show Bad Request message
def
handler403(request, *args, **kwargs):
98 def view(request, *args, **kwargs): 99 self = cls(**initkwargs) 100 self.setup(request, *args, **kwargs) 101 if not hasattr(self, "request"): 102 raise AttributeError( 103 "%s instance has no 'request' attribute. Did you override " 104 "setup() and forget to call super()?" % cls.__name__ 105 ) 106 return self.dispatch(request, *args, **kwargs)
Show Forbidden message
def
handler404(request, *args, **kwargs):
98 def view(request, *args, **kwargs): 99 self = cls(**initkwargs) 100 self.setup(request, *args, **kwargs) 101 if not hasattr(self, "request"): 102 raise AttributeError( 103 "%s instance has no 'request' attribute. Did you override " 104 "setup() and forget to call super()?" % cls.__name__ 105 ) 106 return self.dispatch(request, *args, **kwargs)
Show Not Found message
def
handler500(request, *args, **kwargs):
98 def view(request, *args, **kwargs): 99 self = cls(**initkwargs) 100 self.setup(request, *args, **kwargs) 101 if not hasattr(self, "request"): 102 raise AttributeError( 103 "%s instance has no 'request' attribute. Did you override " 104 "setup() and forget to call super()?" % cls.__name__ 105 ) 106 return self.dispatch(request, *args, **kwargs)
Show Server Error message
urlpatterns =
[<URLResolver <URLResolver list> (None:None) ''>, <URLPattern '-/metrics/' [name='metrics']>, <URLPattern '-/health/live/' [name='health-live']>, <URLPattern '-/health/ready/' [name='health-ready']>]