Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix Missing CSRF token in sentry

Tags:

c++

c

django

sentry

After fighting with sentry when installing it on openshift i got it up and running only to discover that when sending an event to my server it will throw this error:

12:30:59 [WARNING] django.request: Forbidden (CSRF cookie not set.): /api/1/envelope/ (status_code=403 request=<WSGIRequest: POST u'/api/1/envelope/'>) 10.125.2.1 - - [20/Jul/2020:12:30:59 +0000] "POST /api/1/envelope/ HTTP/1.1" 403 6059 "-" "sentry.native/0.3.4"

If I send a curl request to the API i get a neat HTML webpage that shows the csrf error. Anyone got an idea what might be the problem here?

like image 660
HFinch Avatar asked Jul 20 '20 12:07

HFinch


People also ask

What does missing CSRF token mean?

Invalid or missing CSRF token This error message means that your browser couldn't create a secure cookie, or couldn't access that cookie to authorize your login. This can be caused by ad- or script-blocking plugins, but also by the browser itself if it's not allowed to set cookies.

How do I enable CSRF cookies on Mac?

Open Safari Preferences from the drop-down menu in the navigation bar or by typing Cmd + , (⌘,). Click the Privacy tab and make sure that "Cookies and website data" is set to either "Always allow" or "Allow from websites I visit".

How long do CSRF tokens last?

It remains valid for 24 hours.


1 Answers

Proxy /api/ to sentry relay worker. Relevant part from https://github.com/getsentry/onpremise/blob/master/nginx/nginx.conf

upstream relay { server relay:3000; }
upstream sentry { server web:9000; }
server {
    location /api/store/ { proxy_pass http://relay; }
    location ~ ^/api/[1-9]\d*/ { proxy_pass http://relay; }
    location / { proxy_pass http://sentry; }
}
like image 155
temoto Avatar answered Oct 16 '22 11:10

temoto