Add CSRF check for handlers that do not require a session but have one (#13354)
Этот коммит содержится в:
коммит произвёл
Christopher Speller
родитель
f672eb7291
Коммит
637d9e0ea6
@@ -222,7 +222,7 @@ func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
// checkCSRFToken performs a CSRF check on the provided request with the given CSRF token. Returns whether or not
|
||||
// a CSRF check occurred and whether or not it succeeded.
|
||||
func (h *Handler) checkCSRFToken(c *Context, r *http.Request, token string, tokenLocation app.TokenLocation, session *model.Session) (checked bool, passed bool) {
|
||||
csrfCheckNeeded := c.Err == nil && tokenLocation == app.TokenLocationCookie && h.RequireSession && !h.TrustRequester && r.Method != "GET"
|
||||
csrfCheckNeeded := session != nil && c.Err == nil && tokenLocation == app.TokenLocationCookie && !h.TrustRequester && r.Method != "GET"
|
||||
csrfCheckPassed := false
|
||||
|
||||
if csrfCheckNeeded {
|
||||
|
||||
Ссылка в новой задаче
Block a user