plugin code 优化
This commit is contained in:
parent
85b5f2b316
commit
516d03c267
|
@ -69,8 +69,6 @@ func (req *Notify) GetReId() string {
|
|||
}
|
||||
|
||||
func (req *Notify) ToJson() []byte {
|
||||
//kvRows := utils.SortStruct(req.Body)
|
||||
//b, _ := json.Marshal(kvRows)
|
||||
b, _ := json.Marshal(req.Body)
|
||||
return b
|
||||
}
|
||||
|
|
|
@ -26,8 +26,8 @@ func headers(config *Config, req po.Req, bizMethod string) map[string][]string {
|
|||
milliseconds := now.Unix()*1000 + int64(now.Nanosecond())/1e6
|
||||
h.Add("reqTs", fmt.Sprintf("%d", milliseconds))
|
||||
|
||||
encodedHash := utils.Sha(vo.Version, config.Config.AppId, bizMethod, req.GetReId(), string(req.ToJson()))
|
||||
signValue, err := utils.Sign(encodedHash, utils.FormatPEMPrivateKey(config.Extra.RsaPrk))
|
||||
rehash := utils.Sha(vo.Version, config.Config.AppId, bizMethod, req.GetReId(), string(req.ToJson()))
|
||||
signValue, err := utils.Sign(rehash, utils.FormatPEMPrivateKey(config.Extra.RsaPrk))
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
@ -45,8 +45,8 @@ func verify(config *Config, req *po.Notify, notifyBizMethod string) error {
|
|||
if req.Headers.BizMethod != notifyBizMethod {
|
||||
return fmt.Errorf("业务方法不匹配")
|
||||
}
|
||||
encodedHash := utils.Sha(req.Headers.Version, config.Config.AppId, req.Headers.BizMethod, req.GetReId(), string(req.ToJson()))
|
||||
lowerStr := strings.ToLower(encodedHash)
|
||||
rehash := utils.Sha(req.Headers.Version, config.Config.AppId, req.Headers.BizMethod, req.GetReId(), string(req.ToJson()))
|
||||
lowerStr := strings.ToLower(rehash)
|
||||
if utils.Verify(lowerStr, req.Headers.Sign, utils.FormatPEMPrivateKey(config.Extra.RsaNpk)) {
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue