转成 标准的jwt Token

This commit is contained in:
eson 2023-07-10 17:54:10 +08:00
parent 8f95be2ba5
commit fb4414fab6
14 changed files with 23 additions and 0 deletions
goctl_template/api
server
backend/internal/svc
canteen/internal/svc
data-transfer/internal/svc
home-user-auth/internal/svc
inventory/internal/svc
map-library/internal/svc
orders/internal/svc
product-model/internal/svc
product-template/internal/svc
product/internal/svc
shopping-cart-confirmation/internal/svc
upload/internal/svc
webset/internal/svc

View File

@ -36,6 +36,8 @@ func (svcCtx *ServiceContext) ParseJwtToken(r *http.Request) (jwt.MapClaims, err
if AuthKey == "" {
return nil, nil
}
AuthKey = AuthKey[7:]
if len(AuthKey) <= 50 {
return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey)))

View File

@ -37,6 +37,8 @@ func (svcCtx *ServiceContext) ParseJwtToken(r *http.Request) (jwt.MapClaims, err
return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey)))
}
AuthKey = AuthKey[7:]
token, err := jwt.Parse(AuthKey, func(token *jwt.Token) (interface{}, error) {
// 检查签名方法是否为 HS256
if _, ok := token.Method.(*jwt.SigningMethodHMAC); !ok {

View File

@ -34,6 +34,8 @@ func (svcCtx *ServiceContext) ParseJwtToken(r *http.Request) (jwt.MapClaims, err
if AuthKey == "" {
return nil, nil
}
AuthKey = AuthKey[7:]
if len(AuthKey) <= 50 {
return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey)))
}

View File

@ -34,6 +34,8 @@ func (svcCtx *ServiceContext) ParseJwtToken(r *http.Request) (jwt.MapClaims, err
if AuthKey == "" {
return nil, nil
}
AuthKey = AuthKey[7:]
if len(AuthKey) <= 50 {
return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey)))
}

View File

@ -34,6 +34,7 @@ func (svcCtx *ServiceContext) ParseJwtToken(r *http.Request) (jwt.MapClaims, err
if AuthKey == "" {
return nil, nil
}
AuthKey = AuthKey[7:]
if len(AuthKey) <= 50 {
return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey)))

View File

@ -34,6 +34,7 @@ func (svcCtx *ServiceContext) ParseJwtToken(r *http.Request) (jwt.MapClaims, err
if AuthKey == "" {
return nil, nil
}
AuthKey = AuthKey[7:]
if len(AuthKey) <= 50 {
return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey)))

View File

@ -34,6 +34,8 @@ func (svcCtx *ServiceContext) ParseJwtToken(r *http.Request) (jwt.MapClaims, err
if AuthKey == "" {
return nil, nil
}
AuthKey = AuthKey[7:]
if len(AuthKey) <= 50 {
return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey)))
}

View File

@ -34,6 +34,8 @@ func (svcCtx *ServiceContext) ParseJwtToken(r *http.Request) (jwt.MapClaims, err
if AuthKey == "" {
return nil, nil
}
AuthKey = AuthKey[7:]
if len(AuthKey) <= 50 {
return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey)))
}

View File

@ -34,6 +34,7 @@ func (svcCtx *ServiceContext) ParseJwtToken(r *http.Request) (jwt.MapClaims, err
if AuthKey == "" {
return nil, nil
}
AuthKey = AuthKey[7:]
if len(AuthKey) <= 50 {
return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey)))

View File

@ -34,6 +34,8 @@ func (svcCtx *ServiceContext) ParseJwtToken(r *http.Request) (jwt.MapClaims, err
if AuthKey == "" {
return nil, nil
}
AuthKey = AuthKey[7:]
if len(AuthKey) <= 50 {
return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey)))
}

View File

@ -34,6 +34,8 @@ func (svcCtx *ServiceContext) ParseJwtToken(r *http.Request) (jwt.MapClaims, err
if AuthKey == "" {
return nil, nil
}
AuthKey = AuthKey[7:]
if len(AuthKey) <= 50 {
return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey)))
}

View File

@ -34,6 +34,8 @@ func (svcCtx *ServiceContext) ParseJwtToken(r *http.Request) (jwt.MapClaims, err
if AuthKey == "" {
return nil, nil
}
AuthKey = AuthKey[7:]
if len(AuthKey) <= 50 {
return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey)))
}

View File

@ -45,6 +45,7 @@ func (svcCtx *ServiceContext) ParseJwtToken(r *http.Request) (jwt.MapClaims, err
if AuthKey == "" {
return nil, nil
}
AuthKey = AuthKey[7:]
if len(AuthKey) <= 50 {
return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey)))

View File

@ -34,6 +34,7 @@ func (svcCtx *ServiceContext) ParseJwtToken(r *http.Request) (jwt.MapClaims, err
if AuthKey == "" {
return nil, nil
}
AuthKey = AuthKey[7:]
if len(AuthKey) <= 50 {
return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey)))