Middleware: Fix IPv6 host parsing in CSRF check (#45911) (#45984)

- Also create tests for this middleware

Co-authored-by: Kyle Brandt <kyle@grafana.com>
(cherry picked from commit 06ed5efdf0)

Co-authored-by: ying-jeanne <74549700+ying-jeanne@users.noreply.github.com>
This commit is contained in:
Grot (@grafanabot)
2022-02-28 14:15:10 -05:00
committed by GitHub
co-authored by ying-jeanne
parent e7f52218d1
commit b0646b1be3
3 changed files with 140 additions and 5 deletions
+1 -1
View File
@@ -441,7 +441,7 @@ func (hs *HTTPServer) addMiddlewaresAndStaticRoutes() {
}
m.Use(middleware.Recovery(hs.Cfg))
m.UseMiddleware(middleware.CSRF(hs.Cfg.LoginCookieName))
m.UseMiddleware(middleware.CSRF(hs.Cfg.LoginCookieName, hs.log))
hs.mapStatic(m, hs.Cfg.StaticRootPath, "build", "public/build")
hs.mapStatic(m, hs.Cfg.StaticRootPath, "", "public", "/public/views/swagger.html")