Skip to content

Commit b3d9150

Browse files
authored
fix(crons) Add missing CSRF exemption for checkin endpoint (#45694)
The method delegator also needs to be able to apply CSRF exemption so that monitors can accept a DSN auth. There is an existing test for this authentication mode but it doesn't have issues with CSRF and I don't yet know why. Refs #45690
1 parent 20f4c1b commit b3d9150

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

src/sentry/api/urls.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,6 +1334,7 @@
13341334
method_dispatch(
13351335
GET=OrganizationMonitorCheckInIndexEndpoint.as_view(),
13361336
POST=MonitorIngestCheckInIndexEndpoint.as_view(), # Legacy ingest endpoint
1337+
csrf_exempt=True,
13371338
),
13381339
name="sentry-api-0-organization-monitor-check-in-index",
13391340
),

src/sentry/api/utils.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
from django.http import HttpResponseNotAllowed
1111
from django.utils import timezone
12+
from django.views.decorators.csrf import csrf_exempt
1213
from rest_framework.request import Request
1314

1415
from sentry import options
@@ -283,4 +284,7 @@ def dispatcher(request, *args, **kwargs): # type: ignore[no-untyped-def]
283284
handler = dispatch_mapping.get(request.method, invalid_method)
284285
return handler(request, *args, **kwargs)
285286

287+
if dispatch_mapping.get("csrf_exempt"):
288+
return csrf_exempt(dispatcher)
289+
286290
return dispatcher

0 commit comments

Comments
 (0)