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 {
|
func (req *Notify) ToJson() []byte {
|
||||||
//kvRows := utils.SortStruct(req.Body)
|
|
||||||
//b, _ := json.Marshal(kvRows)
|
|
||||||
b, _ := json.Marshal(req.Body)
|
b, _ := json.Marshal(req.Body)
|
||||||
return b
|
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
|
milliseconds := now.Unix()*1000 + int64(now.Nanosecond())/1e6
|
||||||
h.Add("reqTs", fmt.Sprintf("%d", milliseconds))
|
h.Add("reqTs", fmt.Sprintf("%d", milliseconds))
|
||||||
|
|
||||||
encodedHash := utils.Sha(vo.Version, config.Config.AppId, bizMethod, req.GetReId(), string(req.ToJson()))
|
rehash := utils.Sha(vo.Version, config.Config.AppId, bizMethod, req.GetReId(), string(req.ToJson()))
|
||||||
signValue, err := utils.Sign(encodedHash, utils.FormatPEMPrivateKey(config.Extra.RsaPrk))
|
signValue, err := utils.Sign(rehash, utils.FormatPEMPrivateKey(config.Extra.RsaPrk))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -45,8 +45,8 @@ func verify(config *Config, req *po.Notify, notifyBizMethod string) error {
|
||||||
if req.Headers.BizMethod != notifyBizMethod {
|
if req.Headers.BizMethod != notifyBizMethod {
|
||||||
return fmt.Errorf("业务方法不匹配")
|
return fmt.Errorf("业务方法不匹配")
|
||||||
}
|
}
|
||||||
encodedHash := utils.Sha(req.Headers.Version, config.Config.AppId, req.Headers.BizMethod, req.GetReId(), string(req.ToJson()))
|
rehash := utils.Sha(req.Headers.Version, config.Config.AppId, req.Headers.BizMethod, req.GetReId(), string(req.ToJson()))
|
||||||
lowerStr := strings.ToLower(encodedHash)
|
lowerStr := strings.ToLower(rehash)
|
||||||
if utils.Verify(lowerStr, req.Headers.Sign, utils.FormatPEMPrivateKey(config.Extra.RsaNpk)) {
|
if utils.Verify(lowerStr, req.Headers.Sign, utils.FormatPEMPrivateKey(config.Extra.RsaNpk)) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue