mirror of
https://github.com/usememos/memos.git
synced 2025-02-14 10:20:49 +01:00
chore: update skipper name (#1080)
This commit is contained in:
parent
a997e1d10d
commit
870559046f
@ -58,7 +58,7 @@ func aclMiddleware(s *Server, next echo.HandlerFunc) echo.HandlerFunc {
|
|||||||
ctx := c.Request().Context()
|
ctx := c.Request().Context()
|
||||||
path := c.Path()
|
path := c.Path()
|
||||||
|
|
||||||
if s.DefaultAuthSkipper(c) {
|
if s.defaultAuthSkipper(c) {
|
||||||
return next(c)
|
return next(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,16 +18,16 @@ func composeResponse(data interface{}) response {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func DefaultGetRequestSkipper(c echo.Context) bool {
|
func defaultGetRequestSkipper(c echo.Context) bool {
|
||||||
return c.Request().Method == http.MethodGet
|
return c.Request().Method == http.MethodGet
|
||||||
}
|
}
|
||||||
|
|
||||||
func DefaultAPIRequestSkipper(c echo.Context) bool {
|
func defaultAPIRequestSkipper(c echo.Context) bool {
|
||||||
path := c.Path()
|
path := c.Path()
|
||||||
return common.HasPrefixes(path, "/api")
|
return common.HasPrefixes(path, "/api")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (server *Server) DefaultAuthSkipper(c echo.Context) bool {
|
func (server *Server) defaultAuthSkipper(c echo.Context) bool {
|
||||||
ctx := c.Request().Context()
|
ctx := c.Request().Context()
|
||||||
path := c.Path()
|
path := c.Path()
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ func embedFrontend(e *echo.Echo) {
|
|||||||
// Use echo static middleware to serve the built dist folder
|
// Use echo static middleware to serve the built dist folder
|
||||||
// refer: https://github.com/labstack/echo/blob/master/middleware/static.go
|
// refer: https://github.com/labstack/echo/blob/master/middleware/static.go
|
||||||
e.Use(middleware.StaticWithConfig(middleware.StaticConfig{
|
e.Use(middleware.StaticWithConfig(middleware.StaticConfig{
|
||||||
Skipper: DefaultAPIRequestSkipper,
|
Skipper: defaultAPIRequestSkipper,
|
||||||
HTML5: true,
|
HTML5: true,
|
||||||
Filesystem: getFileSystem("dist"),
|
Filesystem: getFileSystem("dist"),
|
||||||
}))
|
}))
|
||||||
@ -38,6 +38,7 @@ func embedFrontend(e *echo.Echo) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
assetsGroup.Use(middleware.StaticWithConfig(middleware.StaticConfig{
|
assetsGroup.Use(middleware.StaticWithConfig(middleware.StaticConfig{
|
||||||
|
Skipper: defaultAPIRequestSkipper,
|
||||||
HTML5: true,
|
HTML5: true,
|
||||||
Filesystem: getFileSystem("dist/assets"),
|
Filesystem: getFileSystem("dist/assets"),
|
||||||
}))
|
}))
|
||||||
|
@ -15,11 +15,11 @@ type Profile struct {
|
|||||||
// Mode can be "prod" or "dev"
|
// Mode can be "prod" or "dev"
|
||||||
Mode string `json:"mode"`
|
Mode string `json:"mode"`
|
||||||
// Port is the binding port for server
|
// Port is the binding port for server
|
||||||
Port int `json:"port"`
|
Port int `json:"-"`
|
||||||
// Data is the data directory
|
// Data is the data directory
|
||||||
Data string `json:"data"`
|
Data string `json:"-"`
|
||||||
// DSN points to where Memos stores its own data
|
// DSN points to where Memos stores its own data
|
||||||
DSN string `json:"dsn"`
|
DSN string `json:"-"`
|
||||||
// Version is the current version of server
|
// Version is the current version of server
|
||||||
Version string `json:"version"`
|
Version string `json:"version"`
|
||||||
}
|
}
|
||||||
|
@ -58,14 +58,14 @@ func NewServer(ctx context.Context, profile *profile.Profile) (*Server, error) {
|
|||||||
e.Use(middleware.Gzip())
|
e.Use(middleware.Gzip())
|
||||||
|
|
||||||
e.Use(middleware.CSRFWithConfig(middleware.CSRFConfig{
|
e.Use(middleware.CSRFWithConfig(middleware.CSRFConfig{
|
||||||
Skipper: s.DefaultAuthSkipper,
|
Skipper: s.defaultAuthSkipper,
|
||||||
TokenLookup: "cookie:_csrf",
|
TokenLookup: "cookie:_csrf",
|
||||||
}))
|
}))
|
||||||
|
|
||||||
e.Use(middleware.CORS())
|
e.Use(middleware.CORS())
|
||||||
|
|
||||||
e.Use(middleware.SecureWithConfig(middleware.SecureConfig{
|
e.Use(middleware.SecureWithConfig(middleware.SecureConfig{
|
||||||
Skipper: DefaultGetRequestSkipper,
|
Skipper: defaultGetRequestSkipper,
|
||||||
XSSProtection: "1; mode=block",
|
XSSProtection: "1; mode=block",
|
||||||
ContentTypeNosniff: "nosniff",
|
ContentTypeNosniff: "nosniff",
|
||||||
XFrameOptions: "SAMEORIGIN",
|
XFrameOptions: "SAMEORIGIN",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user