1
0

Skip CSRF for embeds (#402)

* Skip CSRF for embeds

The CSRF middleware sets a _csrf cookie also for loading the embed
javascript on third-party sites. With this change no _csrf cookie is set
when loading the embed javascript (regardless if third-party site or
first-party).
هذا الالتزام موجود في:
Andreas Jaggi
2025-01-20 02:18:45 +01:00
ملتزم من قبل GitHub
الأصل f935ee1a7e
التزام a752e0561d

عرض الملف

@@ -58,6 +58,11 @@ func (s *Server) registerMiddlewares() {
CookiePath: "/",
CookieHTTPOnly: true,
CookieSameSite: http.SameSiteStrictMode,
Skipper: func(ctx echo.Context) bool {
/* skip CSRF for embeds */
gistName := ctx.Param("gistname")
return filepath.Ext(gistName) == ".js"
},
}))
s.echo.Use(Middleware(csrfInit).toEcho())
}