diff --git a/authentik/root/asgi/app.py b/authentik/root/asgi/app.py index 97bbb5300..00010f86a 100644 --- a/authentik/root/asgi/app.py +++ b/authentik/root/asgi/app.py @@ -13,7 +13,6 @@ from defusedxml import defuse_stdlib from django.core.asgi import get_asgi_application from sentry_sdk.integrations.asgi import SentryAsgiMiddleware -from authentik.root.asgi.error_handler import ASGIErrorHandler from authentik.root.asgi.logger import ASGILogger # DJANGO_SETTINGS_MODULE is set in gunicorn.conf.py @@ -24,16 +23,14 @@ django.setup() # pylint: disable=wrong-import-position from authentik.root import websocket # noqa # isort:skip -application = ASGIErrorHandler( - ASGILogger( - guarantee_single_callable( - SentryAsgiMiddleware( - ProtocolTypeRouter( - { - "http": get_asgi_application(), - "websocket": URLRouter(websocket.websocket_urlpatterns), - } - ) +application = ASGILogger( + guarantee_single_callable( + SentryAsgiMiddleware( + ProtocolTypeRouter( + { + "http": get_asgi_application(), + "websocket": URLRouter(websocket.websocket_urlpatterns), + } ) ) ) diff --git a/authentik/root/asgi/error_handler.py b/authentik/root/asgi/error_handler.py deleted file mode 100644 index de04e7532..000000000 --- a/authentik/root/asgi/error_handler.py +++ /dev/null @@ -1,38 +0,0 @@ -"""ASGI Error handler""" -from structlog.stdlib import get_logger - -from authentik.root.asgi.types import ASGIApp, Receive, Scope, Send - -LOGGER = get_logger("authentik.asgi") - - -class ASGIErrorHandler: - """ASGI Error handler""" - - app: ASGIApp - - def __init__(self, app: ASGIApp): - self.app = app - - async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None: - try: - return await self.app(scope, receive, send) - except Exception as exc: # pylint: disable=broad-except - LOGGER.warning("Fatal ASGI exception", exc=exc) - return await self.error_handler(scope, send) - - async def error_handler(self, scope: Scope, send: Send) -> None: - """Return a generic error message""" - if scope.get("scheme", "http") == "http": - return await send( - { - "type": "http.request", - "body": b"Internal server error", - "more_body": False, - } - ) - return await send( - { - "type": "websocket.close", - } - ) diff --git a/internal/outpost/proxyv2/application/error.go b/internal/outpost/proxyv2/application/error.go index ba7d78d9a..1c4f75cdf 100644 --- a/internal/outpost/proxyv2/application/error.go +++ b/internal/outpost/proxyv2/application/error.go @@ -10,7 +10,7 @@ import ( // NewProxyErrorHandler creates a ProxyErrorHandler using the template given. func NewProxyErrorHandler(errorTemplate *template.Template) func(http.ResponseWriter, *http.Request, error) { return func(rw http.ResponseWriter, req *http.Request, proxyErr error) { - log.Errorf("Error proxying to upstream server: %v", proxyErr) + log.WithError(proxyErr).Warning("Error proxying to upstream server") rw.WriteHeader(http.StatusBadGateway) data := struct { Title string