This commit is contained in:
parent
044ed583b9
commit
118c34dac6
@ -10,6 +10,7 @@ import (
|
|||||||
|
|
||||||
"github.com/gorilla/sessions"
|
"github.com/gorilla/sessions"
|
||||||
"github.com/labstack/echo-contrib/session"
|
"github.com/labstack/echo-contrib/session"
|
||||||
|
"github.com/labstack/echo/v4"
|
||||||
"github.com/labstack/echo/v4/middleware"
|
"github.com/labstack/echo/v4/middleware"
|
||||||
"golang.org/x/time/rate"
|
"golang.org/x/time/rate"
|
||||||
)
|
)
|
||||||
@ -119,12 +120,18 @@ func (a *App) SetEchoSettings() {
|
|||||||
|
|
||||||
e.Use(session.Middleware(store))
|
e.Use(session.Middleware(store))
|
||||||
|
|
||||||
// e.Use(middleware.CSRF())
|
csrfCookieName := "pcmt_csrf"
|
||||||
|
if a.setting.HTTPSecure() {
|
||||||
|
csrfCookieName = "__Secure-" + csrfCookieName
|
||||||
|
}
|
||||||
|
|
||||||
e.Use(middleware.CSRFWithConfig(middleware.CSRFConfig{
|
e.Use(middleware.CSRFWithConfig(middleware.CSRFConfig{
|
||||||
TokenLookup: "cookie:_csrf",
|
TokenLookup: "cookie:" + csrfCookieName +
|
||||||
CookiePath: "/",
|
",form:csrf,header:" + echo.HeaderXCSRFToken,
|
||||||
// CookieDomain: "example.com",
|
CookieName: csrfCookieName,
|
||||||
// CookieSecure: true,
|
ContextKey: "csrf",
|
||||||
|
// CookieDomain: "localhost",
|
||||||
|
CookieSecure: a.setting.HTTPSecure(),
|
||||||
CookieHTTPOnly: true,
|
CookieHTTPOnly: true,
|
||||||
CookieSameSite: http.SameSiteStrictMode,
|
CookieSameSite: http.SameSiteStrictMode,
|
||||||
}),
|
}),
|
||||||
|
Loading…
Reference in New Issue
Block a user