修复编译
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user