root: add silk and debugging views
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
2399fa456b
commit
9077eff34d
|
@ -1,4 +1,5 @@
|
||||||
"""authentik URL Configuration"""
|
"""authentik URL Configuration"""
|
||||||
|
from django.conf import settings
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
from django.urls import path
|
from django.urls import path
|
||||||
from django.views.decorators.csrf import ensure_csrf_cookie
|
from django.views.decorators.csrf import ensure_csrf_cookie
|
||||||
|
@ -6,6 +7,7 @@ from django.views.generic import RedirectView
|
||||||
from django.views.generic.base import TemplateView
|
from django.views.generic.base import TemplateView
|
||||||
|
|
||||||
from authentik.core.views import apps, impersonate
|
from authentik.core.views import apps, impersonate
|
||||||
|
from authentik.core.views.debug import AccessDeniedView
|
||||||
from authentik.core.views.interface import FlowInterfaceView
|
from authentik.core.views.interface import FlowInterfaceView
|
||||||
from authentik.core.views.session import EndSessionView
|
from authentik.core.views.session import EndSessionView
|
||||||
|
|
||||||
|
@ -60,3 +62,8 @@ urlpatterns = [
|
||||||
TemplateView.as_view(template_name="if/admin.html"),
|
TemplateView.as_view(template_name="if/admin.html"),
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
if settings.DEBUG:
|
||||||
|
urlpatterns += [
|
||||||
|
path("debug/policy/deny/", AccessDeniedView.as_view(), name="debug-policy-deny"),
|
||||||
|
]
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
"""debug view"""
|
||||||
|
from django.http import HttpRequest, HttpResponse
|
||||||
|
from django.views.generic import View
|
||||||
|
|
||||||
|
from authentik.policies.denied import AccessDeniedResponse
|
||||||
|
|
||||||
|
|
||||||
|
class AccessDeniedView(View):
|
||||||
|
"""Easily access AccessDeniedResponse"""
|
||||||
|
|
||||||
|
def dispatch(self, request: HttpRequest) -> HttpResponse:
|
||||||
|
return AccessDeniedResponse(request)
|
|
@ -18,13 +18,18 @@ from authentik.events.utils import model_to_dict
|
||||||
from authentik.lib.sentry import before_send
|
from authentik.lib.sentry import before_send
|
||||||
from authentik.lib.utils.errors import exception_to_string
|
from authentik.lib.utils.errors import exception_to_string
|
||||||
|
|
||||||
IGNORED_MODELS = (
|
IGNORED_MODELS = [
|
||||||
Event,
|
Event,
|
||||||
Notification,
|
Notification,
|
||||||
UserObjectPermission,
|
UserObjectPermission,
|
||||||
AuthenticatedSession,
|
AuthenticatedSession,
|
||||||
StaticToken,
|
StaticToken,
|
||||||
)
|
]
|
||||||
|
try:
|
||||||
|
from silk.models import Request, Response
|
||||||
|
IGNORED_MODELS += [Request, Response]
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class AuditMiddleware:
|
class AuditMiddleware:
|
||||||
|
|
|
@ -460,7 +460,6 @@ _LOGGING_HANDLER_MAP = {
|
||||||
"django": "WARNING",
|
"django": "WARNING",
|
||||||
"celery": "WARNING",
|
"celery": "WARNING",
|
||||||
"selenium": "WARNING",
|
"selenium": "WARNING",
|
||||||
"grpc": LOG_LEVEL,
|
|
||||||
"docker": "WARNING",
|
"docker": "WARNING",
|
||||||
"urllib3": "WARNING",
|
"urllib3": "WARNING",
|
||||||
"websockets": "WARNING",
|
"websockets": "WARNING",
|
||||||
|
@ -468,6 +467,7 @@ _LOGGING_HANDLER_MAP = {
|
||||||
"kubernetes": "INFO",
|
"kubernetes": "INFO",
|
||||||
"asyncio": "WARNING",
|
"asyncio": "WARNING",
|
||||||
"aioredis": "WARNING",
|
"aioredis": "WARNING",
|
||||||
|
"silk": "INFO",
|
||||||
}
|
}
|
||||||
for handler_name, level in _LOGGING_HANDLER_MAP.items():
|
for handler_name, level in _LOGGING_HANDLER_MAP.items():
|
||||||
# pyright: reportGeneralTypeIssues=false
|
# pyright: reportGeneralTypeIssues=false
|
||||||
|
@ -504,6 +504,11 @@ for _app in INSTALLED_APPS:
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
CELERY_TASK_ALWAYS_EAGER = True
|
CELERY_TASK_ALWAYS_EAGER = True
|
||||||
os.environ[ENV_GIT_HASH_KEY] = "dev"
|
os.environ[ENV_GIT_HASH_KEY] = "dev"
|
||||||
|
INSTALLED_APPS.append("silk")
|
||||||
|
SILKY_PYTHON_PROFILER = True
|
||||||
|
MIDDLEWARE = [
|
||||||
|
"silk.middleware.SilkyMiddleware"
|
||||||
|
] + MIDDLEWARE
|
||||||
|
|
||||||
INSTALLED_APPS.append("authentik.core")
|
INSTALLED_APPS.append("authentik.core")
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
"""authentik URL Configuration"""
|
"""authentik URL Configuration"""
|
||||||
from django.urls import include, path
|
from django.urls import include, path
|
||||||
from structlog.stdlib import get_logger
|
from structlog.stdlib import get_logger
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
from authentik.core.views import error
|
from authentik.core.views import error
|
||||||
from authentik.lib.utils.reflection import get_apps
|
from authentik.lib.utils.reflection import get_apps
|
||||||
|
@ -47,3 +48,8 @@ urlpatterns += [
|
||||||
path("-/health/live/", LiveView.as_view(), name="health-live"),
|
path("-/health/live/", LiveView.as_view(), name="health-live"),
|
||||||
path("-/health/ready/", ReadyView.as_view(), name="health-ready"),
|
path("-/health/ready/", ReadyView.as_view(), name="health-ready"),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
if settings.DEBUG:
|
||||||
|
urlpatterns += [
|
||||||
|
path("debug/silk/", include("silk.urls", namespace="silk")),
|
||||||
|
]
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -158,6 +158,7 @@ pytest-django = "*"
|
||||||
pytest-randomly = "*"
|
pytest-randomly = "*"
|
||||||
requests-mock = "*"
|
requests-mock = "*"
|
||||||
selenium = "*"
|
selenium = "*"
|
||||||
|
django-silk = "*"
|
||||||
|
|
||||||
[build-system]
|
[build-system]
|
||||||
requires = ["poetry-core>=1.0.0"]
|
requires = ["poetry-core>=1.0.0"]
|
||||||
|
|
Reference in New Issue