api: add logging to sentry proxy
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
52bb774f73
commit
74169860cf
|
@ -10,10 +10,13 @@ from rest_framework.permissions import AllowAny
|
||||||
from rest_framework.request import Request
|
from rest_framework.request import Request
|
||||||
from rest_framework.throttling import AnonRateThrottle
|
from rest_framework.throttling import AnonRateThrottle
|
||||||
from rest_framework.views import APIView
|
from rest_framework.views import APIView
|
||||||
|
from structlog.stdlib import get_logger
|
||||||
|
|
||||||
from authentik.api.tasks import sentry_proxy
|
from authentik.api.tasks import sentry_proxy
|
||||||
from authentik.lib.config import CONFIG
|
from authentik.lib.config import CONFIG
|
||||||
|
|
||||||
|
LOGGER = get_logger()
|
||||||
|
|
||||||
|
|
||||||
class PlainTextParser(BaseParser):
|
class PlainTextParser(BaseParser):
|
||||||
"""Plain text parser."""
|
"""Plain text parser."""
|
||||||
|
@ -45,6 +48,7 @@ class SentryTunnelView(APIView):
|
||||||
"""Sentry tunnel, to prevent ad blockers from blocking sentry"""
|
"""Sentry tunnel, to prevent ad blockers from blocking sentry"""
|
||||||
# Only allow usage of this endpoint when error reporting is enabled
|
# Only allow usage of this endpoint when error reporting is enabled
|
||||||
if not CONFIG.y_bool("error_reporting.enabled", False):
|
if not CONFIG.y_bool("error_reporting.enabled", False):
|
||||||
|
LOGGER.debug("error reporting disabled")
|
||||||
return HttpResponse(status=400)
|
return HttpResponse(status=400)
|
||||||
# Body is 2 json objects separated by \n
|
# Body is 2 json objects separated by \n
|
||||||
full_body = request.body
|
full_body = request.body
|
||||||
|
@ -55,6 +59,7 @@ class SentryTunnelView(APIView):
|
||||||
# Check that the DSN is what we expect
|
# Check that the DSN is what we expect
|
||||||
dsn = header.get("dsn", "")
|
dsn = header.get("dsn", "")
|
||||||
if dsn != settings.SENTRY_DSN:
|
if dsn != settings.SENTRY_DSN:
|
||||||
|
LOGGER.debug("Invalid dsn", have=dsn, expected=settings.SENTRY_DSN)
|
||||||
return HttpResponse(status=400)
|
return HttpResponse(status=400)
|
||||||
sentry_proxy.delay(full_body.decode())
|
sentry_proxy.delay(full_body.decode())
|
||||||
return HttpResponse(status=204)
|
return HttpResponse(status=204)
|
||||||
|
|
Reference in New Issue