diff --git a/back/services/notify.ts b/back/services/notify.ts index 934a86ed..22609748 100644 --- a/back/services/notify.ts +++ b/back/services/notify.ts @@ -562,6 +562,8 @@ export default class NotificationService { }; // Add signature if secret is provided + // Note: Feishu's signature algorithm uses timestamp+"\n"+secret as the HMAC key + // and signs an empty message, which differs from typical HMAC usage if (larkSecret) { const timestamp = Math.floor(Date.now() / 1000).toString(); const stringToSign = `${timestamp}\n${larkSecret}`; diff --git a/sample/notify.js b/sample/notify.js index fd68bea0..49ae9f24 100644 --- a/sample/notify.js +++ b/sample/notify.js @@ -995,6 +995,8 @@ function fsBotNotify(text, desp) { const body = { msg_type: 'text', content: { text: `${text}\n\n${desp}` } }; // Add signature if secret is provided + // Note: Feishu's signature algorithm uses timestamp+"\n"+secret as the HMAC key + // and signs an empty message, which differs from typical HMAC usage if (FSSECRET) { const crypto = require('crypto'); const timestamp = Math.floor(Date.now() / 1000).toString(); diff --git a/sample/notify.py b/sample/notify.py index 410ab7ae..8dd885ca 100644 --- a/sample/notify.py +++ b/sample/notify.py @@ -236,6 +236,8 @@ def feishu_bot(title: str, content: str) -> None: data = {"msg_type": "text", "content": {"text": f"{title}\n\n{content}"}} # Add signature if secret is provided + # Note: Feishu's signature algorithm uses timestamp+"\n"+secret as the HMAC key + # and signs an empty message, which differs from typical HMAC usage if push_config.get("FSSECRET"): timestamp = str(int(time.time())) string_to_sign = f'{timestamp}\n{push_config.get("FSSECRET")}'