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

- 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 20:34:26 +01:00
committed by GitHub
co-authored by ying-jeanne
parent 6e75734bd5
commit 274cd740a5
3 changed files with 140 additions and 5 deletions
+1 -1
View File
@@ -422,7 +422,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")