mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Auth: Fix POST request failures with anonymous access (#26049)
Macaron context.QueryBool() seems to modify the request context that causes the POST and PUT requests to fail with: "http: proxy error: net/http: HTTP/1.x transport connection broken: http: ContentLength=333 with Body length 0"
This commit is contained in:
parent
632c54f91d
commit
44dff6fdd0
@ -2,6 +2,7 @@ package middleware
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
macaron "gopkg.in/macaron.v1"
|
||||
@ -87,7 +88,13 @@ func RoleAuth(roles ...models.RoleType) macaron.Handler {
|
||||
|
||||
func Auth(options *AuthOptions) macaron.Handler {
|
||||
return func(c *models.ReqContext) {
|
||||
forceLogin := c.AllowAnonymous && c.QueryBool("forceLogin")
|
||||
forceLogin := false
|
||||
if c.AllowAnonymous {
|
||||
forceLoginParam, err := strconv.ParseBool(c.Req.URL.Query().Get("forceLogin"))
|
||||
if err == nil {
|
||||
forceLogin = forceLoginParam
|
||||
}
|
||||
}
|
||||
requireLogin := !c.AllowAnonymous || forceLogin
|
||||
if !c.IsSignedIn && options.ReqSignedIn && requireLogin {
|
||||
notAuthorized(c)
|
||||
|
Loading…
Reference in New Issue
Block a user