mirror of
https://github.com/usememos/memos.git
synced 2025-01-01 01:51:46 +08:00
chore: fix CSRF (#876)
This commit is contained in:
parent
64e5c343c5
commit
c9bb2b785d
2 changed files with 5 additions and 0 deletions
|
@ -27,6 +27,7 @@ func setUserSession(ctx echo.Context, user *api.User) error {
|
||||||
Path: "/",
|
Path: "/",
|
||||||
MaxAge: 3600 * 24 * 30,
|
MaxAge: 3600 * 24 * 30,
|
||||||
HttpOnly: true,
|
HttpOnly: true,
|
||||||
|
SameSite: http.SameSiteStrictMode,
|
||||||
}
|
}
|
||||||
sess.Values[userIDContextKey] = user.ID
|
sess.Values[userIDContextKey] = user.ID
|
||||||
err := sess.Save(ctx.Request(), ctx.Response())
|
err := sess.Save(ctx.Request(), ctx.Response())
|
||||||
|
|
|
@ -36,6 +36,10 @@ func NewServer(profile *profile.Profile) *Server {
|
||||||
`"status":${status},"error":"${error}"}` + "\n",
|
`"status":${status},"error":"${error}"}` + "\n",
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
e.Use(middleware.CSRFWithConfig(middleware.CSRFConfig{
|
||||||
|
TokenLookup: "cookie:_csrf",
|
||||||
|
}))
|
||||||
|
|
||||||
e.Use(middleware.CORS())
|
e.Use(middleware.CORS())
|
||||||
|
|
||||||
e.Use(middleware.TimeoutWithConfig(middleware.TimeoutConfig{
|
e.Use(middleware.TimeoutWithConfig(middleware.TimeoutConfig{
|
||||||
|
|
Loading…
Reference in a new issue