- callback sign.
This commit is contained in:
@@ -15,6 +15,7 @@ type CallbackResponse struct {
|
||||
Sign string `json:"sign"`
|
||||
Source string `json:"source"`
|
||||
Ticket string `json:"ticket"`
|
||||
Encrypt string `json:"encrypt"`
|
||||
Timestamp int64 `json:"timestamp"`
|
||||
Version int `json:"version"`
|
||||
Body *ResponseResult `json:"body"`
|
||||
@@ -54,6 +55,8 @@ func (a *API) Err2CallbackResponse(cmd string, err error, data interface{}) *Cal
|
||||
"ticket": []string{response.Ticket},
|
||||
"source": []string{response.Source},
|
||||
"body": []string{string(utils.MustMarshal(response.Body))},
|
||||
secretKey: []string{a.secret},
|
||||
"encrypt": []string{""},
|
||||
}
|
||||
response.Sign = a.signParams(params)
|
||||
return response
|
||||
@@ -68,7 +71,12 @@ func (a *API) unmarshalData(cmd string, data []byte, msg interface{}) (callbackR
|
||||
}
|
||||
|
||||
func (a *API) CheckCallbackValidation(request *http.Request) (callbackResponse *CallbackResponse) {
|
||||
sign := a.signParams(request.PostForm)
|
||||
params := make(url.Values)
|
||||
for k, v := range request.PostForm {
|
||||
params[k] = v
|
||||
}
|
||||
params[secretKey] = []string{a.secret}
|
||||
sign := a.signParams(params)
|
||||
if sign != request.FormValue(signKey) {
|
||||
msg := fmt.Sprintf("Signature is not ok, mine:%v, get:%v", sign, request.FormValue(signKey))
|
||||
baseapi.SugarLogger.Info(msg)
|
||||
|
||||
Reference in New Issue
Block a user