mirror of
https://github.com/thomiceli/opengist.git
synced 2025-06-14 06:07:14 +02:00
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).
This commit is contained in:
@ -58,6 +58,11 @@ func (s *Server) registerMiddlewares() {
|
|||||||
CookiePath: "/",
|
CookiePath: "/",
|
||||||
CookieHTTPOnly: true,
|
CookieHTTPOnly: true,
|
||||||
CookieSameSite: http.SameSiteStrictMode,
|
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())
|
s.echo.Use(Middleware(csrfInit).toEcho())
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user