diff --git a/authentik/events/middleware.py b/authentik/events/middleware.py index 2405fe4a5..0c9be762c 100644 --- a/authentik/events/middleware.py +++ b/authentik/events/middleware.py @@ -25,11 +25,11 @@ IGNORED_MODELS = [ AuthenticatedSession, StaticToken, ] -try: +if settings.DEBUG: from silk.models import Request, Response + IGNORED_MODELS += [Request, Response] -except: - pass +IGNORED_MODELS = tuple(IGNORED_MODELS) class AuditMiddleware: diff --git a/authentik/root/settings.py b/authentik/root/settings.py index 9fe5cf5b1..5375e0089 100644 --- a/authentik/root/settings.py +++ b/authentik/root/settings.py @@ -506,9 +506,7 @@ if DEBUG: os.environ[ENV_GIT_HASH_KEY] = "dev" INSTALLED_APPS.append("silk") SILKY_PYTHON_PROFILER = True - MIDDLEWARE = [ - "silk.middleware.SilkyMiddleware" - ] + MIDDLEWARE + MIDDLEWARE = ["silk.middleware.SilkyMiddleware"] + MIDDLEWARE INSTALLED_APPS.append("authentik.core") diff --git a/authentik/root/urls.py b/authentik/root/urls.py index dfa1dde68..6a7385d28 100644 --- a/authentik/root/urls.py +++ b/authentik/root/urls.py @@ -1,7 +1,7 @@ """authentik URL Configuration""" +from django.conf import settings from django.urls import include, path from structlog.stdlib import get_logger -from django.conf import settings from authentik.core.views import error from authentik.lib.utils.reflection import get_apps