feat(toolbar): Use the CSRF token in headers and cookies when using the sentry API#106286
Merged
feat(toolbar): Use the CSRF token in headers and cookies when using the sentry API#106286
Conversation
…he sentry API Before we only sent it in the headers, but the API is still returning "CSRF Failed: CSRF cookie not set." so we need it in both places it seems. This splits up the name & value parts, so we can set everything very clearly. To cleanup we dont need the cookie names again, we will just set all cookies to have a value of the emptystring
billyvg
approved these changes
Jan 21, 2026
Member
billyvg
left a comment
There was a problem hiding this comment.
codewise LGTM - good idea to have security sign off on it.
| document.cookie.split(';').forEach(cookie => { | ||
| const name = cookie.split('=')[0].trim(); | ||
| document.cookie = makeCookieValue(name, '', window.location.hostname, 0); | ||
| document.cookie = makeCookieValue(name, '', regionUrl, 0); |
Member
Author
There was a problem hiding this comment.
have to set stuff against sentry.io, and us.sentry.io.
through the login flow sometimes we redirect between the two, and for api requests we use the regionUrl as the base.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Followup to #106059
Before we only sent it in the headers, but the API is still returning "CSRF Failed: CSRF cookie not set." so we need it in both places it seems.
This splits up the name & value parts, so we can set everything very clearly. To cleanup we dont need the cookie names again, we will just set all cookies to have a value of the emptystring.
This change sits within the boundaries we had before; no values are leaving the scope of our dns/domains. As before we're augmenting requests (adding cookies and other headers) as we proxy messages through the page, checking all the same allowlists before we even render the page. These diagrams are still relevant, but show only the
cookieargument which is now both session and csfr tokens.