mirror of
https://github.com/mudler/LocalAI.git
synced 2026-10-28 09:08:54 -04:00
FLAG_MOTION and FLAG_UPSCALE were both declared as 1 << 26 on separate branches, and a merge combined the two const blocks without a conflict. Add a spec that checks every flag from GetAllModelConfigUsecases() is a single bit that no other flag uses, so a collision fails the tests. FLAG_MOTION itself moves to 1 << 27. Assisted-by: Claude Code:claude-sonnet-5-5 Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
26 lines
816 B
Go
26 lines
816 B
Go
// SPDX-License-Identifier: MIT
|
|
|
|
package auth
|
|
|
|
import (
|
|
"github.com/labstack/echo/v4"
|
|
"github.com/labstack/echo/v4/middleware"
|
|
)
|
|
|
|
// CSRFMiddleware must run after Middleware so only validated header credentials
|
|
// grant an exemption. Cookie authentication must still pass the browser checks.
|
|
func CSRFMiddleware() echo.MiddlewareFunc {
|
|
return middleware.CSRFWithConfig(middleware.CSRFConfig{
|
|
Skipper: func(c echo.Context) bool {
|
|
if authenticated, _ := c.Get(contextKeyHeaderAuthenticated).(bool); authenticated {
|
|
return true
|
|
}
|
|
// Preserve support for clients that do not send fetch metadata.
|
|
return c.Request().Header.Get("Sec-Fetch-Site") == ""
|
|
},
|
|
AllowSecFetchSiteFunc: func(c echo.Context) (bool, error) {
|
|
return c.Request().Header.Get("Sec-Fetch-Site") == "same-site", nil
|
|
},
|
|
})
|
|
}
|