fix
This commit is contained in:
parent
e5480583d9
commit
6bfcc53073
@ -10,4 +10,9 @@ type Config struct {
|
|||||||
SourceMysql string
|
SourceMysql string
|
||||||
Auth types.Auth
|
Auth types.Auth
|
||||||
SourceRabbitMq string
|
SourceRabbitMq string
|
||||||
|
FeiShu struct {
|
||||||
|
ApiHost string
|
||||||
|
EncryptKey string
|
||||||
|
VerificationToken string
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,9 +61,8 @@ func (l *WebhookLogic) Webhook(w http.ResponseWriter, r *http.Request) {
|
|||||||
//计算签名
|
//计算签名
|
||||||
timestamp := r.Header.Get("X-Lark-Request-Timestamp")
|
timestamp := r.Header.Get("X-Lark-Request-Timestamp")
|
||||||
nonce := r.Header.Get("X-Lark-Request-Nonce")
|
nonce := r.Header.Get("X-Lark-Request-Nonce")
|
||||||
encryptKey := "DmiHQ2bHhKiR3KK4tIjLShbs13eErxKA"
|
|
||||||
signature := r.Header.Get("X-Lark-Signature")
|
signature := r.Header.Get("X-Lark-Signature")
|
||||||
sign := l.CalculateFeiShuWebhookSignature(timestamp, nonce, encryptKey, bodyBytes)
|
sign := l.CalculateFeiShuWebhookSignature(timestamp, nonce, l.svcCtx.Config.FeiShu.EncryptKey, bodyBytes)
|
||||||
if signature != sign {
|
if signature != sign {
|
||||||
logx.Error("非法的消息,签名验证不通过", sign, "====", signature)
|
logx.Error("非法的消息,签名验证不通过", sign, "====", signature)
|
||||||
return
|
return
|
||||||
@ -78,7 +77,7 @@ func (l *WebhookLogic) Webhook(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
//解密
|
//解密
|
||||||
realMsgBytes, err := l.DecryptFeiShuWebhookMsg(encryptMsg.Encrypt, encryptKey)
|
realMsgBytes, err := l.DecryptFeiShuWebhookMsg(encryptMsg.Encrypt, l.svcCtx.Config.FeiShu.EncryptKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logx.Error(err)
|
logx.Error(err)
|
||||||
return
|
return
|
||||||
@ -144,8 +143,8 @@ func (l *WebhookLogic) CalculateFeiShuWebhookSignature(timestamp, nonce, encrypt
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 解密事件消息
|
// 解密事件消息
|
||||||
func (l *WebhookLogic) DecryptFeiShuWebhookMsg(encrypt string, encryptKey string) ([]byte, error) {
|
func (l *WebhookLogic) DecryptFeiShuWebhookMsg(encryptData string, encryptKey string) ([]byte, error) {
|
||||||
buf, err := base64.StdEncoding.DecodeString(encrypt)
|
buf, err := base64.StdEncoding.DecodeString(encryptData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("base64StdEncode Error[%v]", err)
|
return nil, fmt.Errorf("base64StdEncode Error[%v]", err)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user