diff options
author | Snowball_233 <wangrb.qq@outlook.com> | 2025-06-21 04:09:03 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-06-20 13:09:03 -0700 |
commit | 40dec17b5c8fd7e79e7a0a397311d68a0587f095 (patch) | |
tree | 09627cce78f9ad9b65bf0c32e3bd570cf5d93eb5 /templates/package | |
parent | 90eb831418dc4afa838f420af3aff4285a14b9dd (diff) | |
download | gitea-main.tar.gz gitea-main.zip |
# Fix Feishu Webhook Signature Verification
This PR implements proper signature verification for Feishu (Lark)
webhooks according to the [official
documentation](https://open.feishu.cn/document/client-docs/bot-v3/add-custom-bot).
## Changes
- Implemented the `GenSign` function based on Feishu's official Go
sample code
- Modified the webhook request creation to include timestamp and
signature in the payload when a secret is configured
- Fixed the signature generation algorithm to properly use HMAC-SHA256
with the correct string format
## Implementation Details
The signature verification works as follows:
1. When a webhook secret is provided, a timestamp is generated
2. The signature string is created using `timestamp + "\n" + secret`
3. The HMAC-SHA256 algorithm is applied to an empty string using the
signature string as the key
4. The result is Base64 encoded to produce the final signature
5. Both timestamp and signature are added to the payload
According to Feishu's documentation, the timestamp must be within 1 hour
(3600 seconds) of the current time to be considered valid.
## Security Note
Feishu emphasizes the importance of keeping webhook URLs secure. Do not
disclose them on GitHub, blogs, or any public sites to prevent
unauthorized use.
## References
- [Feishu Custom Bot
Documentation](https://open.feishu.cn/document/client-docs/bot-v3/add-custom-bot)
---------
Co-authored-by: hiifong <i@hiif.ong>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'templates/package')
0 files changed, 0 insertions, 0 deletions