修复编译

This commit is contained in:
flowshadow
2025-10-10 21:35:34 +08:00
parent 6ac6ac5eda
commit d91c1070c9
11 changed files with 3019 additions and 2146 deletions

View File

@@ -2,11 +2,15 @@ package middleware
import (
"fmt"
"github.com/labstack/echo/v4"
echoMiddleware "github.com/labstack/echo/v4/middleware"
"gitlab.com/texm/shokku/internal/env"
"gitlab.com/texm/shokku/internal/server/auth"
"strings"
"github.com/golang-jwt/jwt/v5"
echojwt "github.com/labstack/echo-jwt/v4"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
"gitlab.com/texm/shokku/internal/env"
"gitlab.com/texm/shokku/internal/server/auth"
)
const (
@@ -36,22 +40,25 @@ func ProvideUserContext(e *env.Env) echo.MiddlewareFunc {
}
}
func tokenAuthSkipper(e *env.Env) echoMiddleware.Skipper {
func tokenAuthSkipper(e *env.Env) middleware.Skipper {
return func(c echo.Context) bool {
return skipDuringSetup(e, c)
}
}
func TokenAuth(e *env.Env) echo.MiddlewareFunc {
config := echoMiddleware.JWTConfig{
Claims: &auth.User{},
config := echojwt.WithConfig(echojwt.Config{
NewClaimsFunc: func(c echo.Context) jwt.Claims {
// &auth.User{}
return jwt.MapClaims{}
},
SigningKey: e.Auth.GetSigningKey(),
TokenLookupFuncs: []echoMiddleware.ValuesExtractor{SplitTokenLookup},
TokenLookupFuncs: []middleware.ValuesExtractor{SplitTokenLookup},
TokenLookup: "header:Authorization",
ContextKey: tokenContextKey,
Skipper: tokenAuthSkipper(e),
}
return echoMiddleware.JWTWithConfig(config)
})
return config
}
func SplitTokenLookup(c echo.Context) ([]string, error) {