diff --git a/main.go b/main.go index 5ae6252..2902f29 100644 --- a/main.go +++ b/main.go @@ -100,6 +100,17 @@ func writeLogger(c *gin.Context) { go dao.InsertLogToDB(path, ip, method, params) } +type CustomClaims struct { + ID string `json:"id"` + Username string `json:"username"` + UserID int `json:"user_id"` +} + +func (c CustomClaims) Valid() error { + //TODO implement me + panic("custom claims valid not implement yet!") +} + func JWTAuthMiddleware() gin.HandlerFunc { return func(c *gin.Context) { if proto.Config.LOG_SAVE_DAYS > 0 { @@ -157,7 +168,7 @@ func JWTAuthMiddleware() gin.HandlerFunc { // return proto.SigningKey, nil //}) - claims := &proto.CustomClaims{} + claims := &CustomClaims{} token, err := jwt.ParseWithClaims(tokenString, claims, func(t *jwt.Token) (interface{}, error) { // 验证签名算法 if _, ok := t.Method.(*jwt.SigningMethodHMAC); !ok { diff --git a/proto/conf.go b/proto/conf.go index 58a43b8..cbc7196 100644 --- a/proto/conf.go +++ b/proto/conf.go @@ -3,7 +3,6 @@ package proto import ( "encoding/json" "fmt" - "github.com/golang-jwt/jwt/v5" "gorm.io/gorm" "log" "os" @@ -175,15 +174,3 @@ func DefaultConfig() { Config.SERVER_NAME = "default" Config.SPARK_PPT_USAGE = false } - -type CustomClaims struct { - ID string `json:"id"` - Username string `json:"username"` - UserID int `json:"user_id"` - jwt.RegisteredClaims -} - -func (c CustomClaims) Valid() error { - //TODO implement me - panic("implement me") -}