From ffe3ec0cb4534db23ba0d3dc28ba167e5db2883e Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Fri, 2 Apr 2021 23:21:40 +0200 Subject: [PATCH] root: disable django admin Signed-off-by: Jens Langhammer --- authentik/core/admin.py | 20 -------------------- authentik/root/settings.py | 1 - authentik/root/urls.py | 10 ---------- 3 files changed, 31 deletions(-) delete mode 100644 authentik/core/admin.py diff --git a/authentik/core/admin.py b/authentik/core/admin.py deleted file mode 100644 index e6ba03829..000000000 --- a/authentik/core/admin.py +++ /dev/null @@ -1,20 +0,0 @@ -"""authentik core admin""" - -from django.apps import AppConfig, apps -from django.contrib import admin -from django.contrib.admin.sites import AlreadyRegistered -from guardian.admin import GuardedModelAdmin - - -def admin_autoregister(app: AppConfig): - """Automatically register all models from app""" - for model in app.get_models(): - try: - admin.site.register(model, GuardedModelAdmin) - except AlreadyRegistered: - pass - - -for _app in apps.get_app_configs(): - if _app.label.startswith("authentik_"): - admin_autoregister(_app) diff --git a/authentik/root/settings.py b/authentik/root/settings.py index 39fe5439b..584a6385c 100644 --- a/authentik/root/settings.py +++ b/authentik/root/settings.py @@ -78,7 +78,6 @@ AUTHENTICATION_BACKENDS = [ # Application definition INSTALLED_APPS = [ - "django.contrib.admin", "django.contrib.auth", "django.contrib.contenttypes", "django.contrib.sessions", diff --git a/authentik/root/urls.py b/authentik/root/urls.py index 95c0a1646..1dd9a9a3a 100644 --- a/authentik/root/urls.py +++ b/authentik/root/urls.py @@ -1,9 +1,7 @@ """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 structlog.stdlib import get_logger from authentik.core.views import error @@ -11,13 +9,6 @@ from authentik.lib.utils.reflection import get_apps from authentik.root.monitoring import LiveView, MetricsView, ReadyView 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() @@ -54,7 +45,6 @@ for _authentik_app in get_apps(): ) urlpatterns += [ - path("administration/django/", admin.site.urls), 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"),