Replace CSRF cookie with CrossOriginProtection (#36183)
Removes the CSRF cookie in favor of [`CrossOriginProtection`](https://pkg.go.dev/net/http#CrossOriginProtection) which relies purely on HTTP headers. Fixes: https://github.com/go-gitea/gitea/issues/11188 Fixes: https://github.com/go-gitea/gitea/issues/30333 Helps: https://github.com/go-gitea/gitea/issues/35107 TODOs: - [x] Fix tests - [ ] Ideally add tests to validates the protection --------- Signed-off-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
@@ -46,9 +46,7 @@ func testViewTimetrackingControls(t *testing.T, session *TestSession, user, repo
|
||||
AssertHTMLElement(t, htmlDoc, ".issue-add-time", canTrackTime)
|
||||
|
||||
issueLink := path.Join(user, repo, "issues", issue)
|
||||
reqStart := NewRequestWithValues(t, "POST", path.Join(issueLink, "times", "stopwatch", "start"), map[string]string{
|
||||
"_csrf": htmlDoc.GetCSRF(),
|
||||
})
|
||||
reqStart := NewRequest(t, "POST", path.Join(issueLink, "times", "stopwatch", "start"))
|
||||
if canTrackTime {
|
||||
session.MakeRequest(t, reqStart, http.StatusOK)
|
||||
|
||||
@@ -65,9 +63,7 @@ func testViewTimetrackingControls(t *testing.T, session *TestSession, user, repo
|
||||
// Sleep for 1 second to not get wrong order for stopping timer
|
||||
time.Sleep(time.Second)
|
||||
|
||||
reqStop := NewRequestWithValues(t, "POST", path.Join(issueLink, "times", "stopwatch", "stop"), map[string]string{
|
||||
"_csrf": htmlDoc.GetCSRF(),
|
||||
})
|
||||
reqStop := NewRequest(t, "POST", path.Join(issueLink, "times", "stopwatch", "stop"))
|
||||
session.MakeRequest(t, reqStop, http.StatusOK)
|
||||
|
||||
req = NewRequest(t, "GET", issueLink)
|
||||
|
||||
Reference in New Issue
Block a user