Sfoglia il codice sorgente

Allow GET requests without CSRF

Jakob Borg 11 anni fa
parent
commit
d65bbf2113
1 ha cambiato i file con 6 aggiunte e 0 eliminazioni
  1. 6 0
      cmd/syncthing/gui_csrf.go

+ 6 - 0
cmd/syncthing/gui_csrf.go

@@ -43,6 +43,12 @@ func csrfMiddleware(prefix string, next http.Handler) http.Handler {
 			return
 			return
 		}
 		}
 
 
+		if r.Method == "GET" {
+			// Allow GET requests unconditionally
+			next.ServeHTTP(w, r)
+			return
+		}
+
 		// Verify the CSRF token
 		// Verify the CSRF token
 		token := r.Header.Get("X-CSRF-Token")
 		token := r.Header.Get("X-CSRF-Token")
 		if !validCsrfToken(token) {
 		if !validCsrfToken(token) {