转成 标准的jwt Token
This commit is contained in:
parent
8f95be2ba5
commit
fb4414fab6
@ -36,6 +36,8 @@ func (svcCtx *ServiceContext) ParseJwtToken(r *http.Request) (jwt.MapClaims, err
|
|||||||
if AuthKey == "" {
|
if AuthKey == "" {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
AuthKey = AuthKey[7:]
|
||||||
|
|
||||||
|
|
||||||
if len(AuthKey) <= 50 {
|
if len(AuthKey) <= 50 {
|
||||||
return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey)))
|
return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey)))
|
||||||
|
@ -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)))
|
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) {
|
token, err := jwt.Parse(AuthKey, func(token *jwt.Token) (interface{}, error) {
|
||||||
// 检查签名方法是否为 HS256
|
// 检查签名方法是否为 HS256
|
||||||
if _, ok := token.Method.(*jwt.SigningMethodHMAC); !ok {
|
if _, ok := token.Method.(*jwt.SigningMethodHMAC); !ok {
|
||||||
|
@ -34,6 +34,8 @@ func (svcCtx *ServiceContext) ParseJwtToken(r *http.Request) (jwt.MapClaims, err
|
|||||||
if AuthKey == "" {
|
if AuthKey == "" {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
AuthKey = AuthKey[7:]
|
||||||
|
|
||||||
if len(AuthKey) <= 50 {
|
if len(AuthKey) <= 50 {
|
||||||
return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey)))
|
return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey)))
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,8 @@ func (svcCtx *ServiceContext) ParseJwtToken(r *http.Request) (jwt.MapClaims, err
|
|||||||
if AuthKey == "" {
|
if AuthKey == "" {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
AuthKey = AuthKey[7:]
|
||||||
|
|
||||||
if len(AuthKey) <= 50 {
|
if len(AuthKey) <= 50 {
|
||||||
return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey)))
|
return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey)))
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,7 @@ func (svcCtx *ServiceContext) ParseJwtToken(r *http.Request) (jwt.MapClaims, err
|
|||||||
if AuthKey == "" {
|
if AuthKey == "" {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
AuthKey = AuthKey[7:]
|
||||||
|
|
||||||
if len(AuthKey) <= 50 {
|
if len(AuthKey) <= 50 {
|
||||||
return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey)))
|
return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey)))
|
||||||
|
@ -34,6 +34,7 @@ func (svcCtx *ServiceContext) ParseJwtToken(r *http.Request) (jwt.MapClaims, err
|
|||||||
if AuthKey == "" {
|
if AuthKey == "" {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
AuthKey = AuthKey[7:]
|
||||||
|
|
||||||
if len(AuthKey) <= 50 {
|
if len(AuthKey) <= 50 {
|
||||||
return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey)))
|
return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey)))
|
||||||
|
@ -34,6 +34,8 @@ func (svcCtx *ServiceContext) ParseJwtToken(r *http.Request) (jwt.MapClaims, err
|
|||||||
if AuthKey == "" {
|
if AuthKey == "" {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
AuthKey = AuthKey[7:]
|
||||||
|
|
||||||
if len(AuthKey) <= 50 {
|
if len(AuthKey) <= 50 {
|
||||||
return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey)))
|
return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey)))
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,8 @@ func (svcCtx *ServiceContext) ParseJwtToken(r *http.Request) (jwt.MapClaims, err
|
|||||||
if AuthKey == "" {
|
if AuthKey == "" {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
AuthKey = AuthKey[7:]
|
||||||
|
|
||||||
if len(AuthKey) <= 50 {
|
if len(AuthKey) <= 50 {
|
||||||
return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey)))
|
return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey)))
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,7 @@ func (svcCtx *ServiceContext) ParseJwtToken(r *http.Request) (jwt.MapClaims, err
|
|||||||
if AuthKey == "" {
|
if AuthKey == "" {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
AuthKey = AuthKey[7:]
|
||||||
|
|
||||||
if len(AuthKey) <= 50 {
|
if len(AuthKey) <= 50 {
|
||||||
return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey)))
|
return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey)))
|
||||||
|
@ -34,6 +34,8 @@ func (svcCtx *ServiceContext) ParseJwtToken(r *http.Request) (jwt.MapClaims, err
|
|||||||
if AuthKey == "" {
|
if AuthKey == "" {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
AuthKey = AuthKey[7:]
|
||||||
|
|
||||||
if len(AuthKey) <= 50 {
|
if len(AuthKey) <= 50 {
|
||||||
return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey)))
|
return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey)))
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,8 @@ func (svcCtx *ServiceContext) ParseJwtToken(r *http.Request) (jwt.MapClaims, err
|
|||||||
if AuthKey == "" {
|
if AuthKey == "" {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
AuthKey = AuthKey[7:]
|
||||||
|
|
||||||
if len(AuthKey) <= 50 {
|
if len(AuthKey) <= 50 {
|
||||||
return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey)))
|
return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey)))
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,8 @@ func (svcCtx *ServiceContext) ParseJwtToken(r *http.Request) (jwt.MapClaims, err
|
|||||||
if AuthKey == "" {
|
if AuthKey == "" {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
AuthKey = AuthKey[7:]
|
||||||
|
|
||||||
if len(AuthKey) <= 50 {
|
if len(AuthKey) <= 50 {
|
||||||
return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey)))
|
return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey)))
|
||||||
}
|
}
|
||||||
|
@ -45,6 +45,7 @@ func (svcCtx *ServiceContext) ParseJwtToken(r *http.Request) (jwt.MapClaims, err
|
|||||||
if AuthKey == "" {
|
if AuthKey == "" {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
AuthKey = AuthKey[7:]
|
||||||
|
|
||||||
if len(AuthKey) <= 50 {
|
if len(AuthKey) <= 50 {
|
||||||
return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey)))
|
return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey)))
|
||||||
|
@ -34,6 +34,7 @@ func (svcCtx *ServiceContext) ParseJwtToken(r *http.Request) (jwt.MapClaims, err
|
|||||||
if AuthKey == "" {
|
if AuthKey == "" {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
AuthKey = AuthKey[7:]
|
||||||
|
|
||||||
if len(AuthKey) <= 50 {
|
if len(AuthKey) <= 50 {
|
||||||
return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey)))
|
return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey)))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user