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:
@@ -79,7 +79,6 @@ func testMirrorPush(t *testing.T, u *url.URL) {
|
||||
|
||||
func testCreatePushMirror(t *testing.T, session *TestSession, owner, repo, address, username, password, interval string) {
|
||||
req := NewRequestWithValues(t, "POST", fmt.Sprintf("/%s/%s/settings", url.PathEscape(owner), url.PathEscape(repo)), map[string]string{
|
||||
"_csrf": GetUserCSRFToken(t, session),
|
||||
"action": "push-mirror-add",
|
||||
"push_mirror_address": address,
|
||||
"push_mirror_username": username,
|
||||
@@ -94,7 +93,6 @@ func testCreatePushMirror(t *testing.T, session *TestSession, owner, repo, addre
|
||||
|
||||
func doRemovePushMirror(t *testing.T, session *TestSession, owner, repo string, pushMirrorID int64) bool {
|
||||
req := NewRequestWithValues(t, "POST", fmt.Sprintf("/%s/%s/settings", url.PathEscape(owner), url.PathEscape(repo)), map[string]string{
|
||||
"_csrf": GetUserCSRFToken(t, session),
|
||||
"action": "push-mirror-remove",
|
||||
"push_mirror_id": strconv.FormatInt(pushMirrorID, 10),
|
||||
})
|
||||
@@ -105,7 +103,6 @@ func doRemovePushMirror(t *testing.T, session *TestSession, owner, repo string,
|
||||
|
||||
func doUpdatePushMirror(t *testing.T, session *TestSession, owner, repo string, pushMirrorID int64, interval string) bool {
|
||||
req := NewRequestWithValues(t, "POST", fmt.Sprintf("/%s/%s/settings", owner, repo), map[string]string{
|
||||
"_csrf": GetUserCSRFToken(t, session),
|
||||
"action": "push-mirror-update",
|
||||
"push_mirror_id": strconv.FormatInt(pushMirrorID, 10),
|
||||
"push_mirror_interval": interval,
|
||||
|
||||
Reference in New Issue
Block a user