Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork6.3k
Fix Feishu webhook signature verification#34788
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
SnowballXueQiu commentedJun 20, 2025
@techknowlogick All errors fixed |
Uh oh!
There was an error while loading.Please reload this page.
**Performance Overhead** `fmt.Sprintf` is **slower** than simple string concatenation or `strconv.FormatInt` because: * It uses reflection and parsing logic internally. * It's designed for formatting many types, not just basic strings or numbers.Co-Authored-By: hiifong <i@hiif.ong>
wxiaoguang commentedJun 20, 2025
Added a test (the test data is generated by Feishu python demo), and simplified the code a little |
SnowballXueQiu commentedJun 20, 2025
@wxiaoguang Sorry, due to a funny problem, one of your commit(probably called 'change a better name') was reverted. Please push your code again. |
wxiaoguang commentedJun 20, 2025
Done. Hopefully the updated code looks good to you. Thank you very much for the PR |
40dec17 intogo-gitea:mainUh oh!
There was an error while loading.Please reload this page.
# Fix Feishu Webhook Signature VerificationThis PR implements proper signature verification for Feishu (Lark)webhooks according to the [officialdocumentation](https://open.feishu.cn/document/client-docs/bot-v3/add-custom-bot).## Changes- Implemented the `GenSign` function based on Feishu's official Gosample code- Modified the webhook request creation to include timestamp andsignature in the payload when a secret is configured- Fixed the signature generation algorithm to properly use HMAC-SHA256with the correct string format## Implementation DetailsThe signature verification works as follows:1. When a webhook secret is provided, a timestamp is generated2. The signature string is created using `timestamp + "\n" + secret`3. The HMAC-SHA256 algorithm is applied to an empty string using thesignature string as the key4. The result is Base64 encoded to produce the final signature5. Both timestamp and signature are added to the payloadAccording to Feishu's documentation, the timestamp must be within 1 hour(3600 seconds) of the current time to be considered valid.## Security NoteFeishu emphasizes the importance of keeping webhook URLs secure. Do notdisclose them on GitHub, blogs, or any public sites to preventunauthorized use.## References- [Feishu Custom BotDocumentation](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>
wxiaoguang commentedJun 21, 2025
Found that the fix is incomplete, there is no "Secret" input on the UI |
* giteaofficial/main: (22 commits) [skip ci] Updated translations via Crowdin Fix required contexts and commit status matching bug (go-gitea#34815) Add "Cancel workflow run" button to Actions list page (go-gitea#34817) Use `shallowRef` instead of `ref` in `.vue` files where possible (go-gitea#34813) Edit file workflow for creating a fork and proposing changes (go-gitea#34240) Refactor packages (go-gitea#34777) Refactor wiki (go-gitea#34805) [skip ci] Updated translations via Crowdin Upgrade htmx to 2.0.5 (go-gitea#34809) Forks repository list page follow other repositories page (go-gitea#34784) Add post-installation redirect based on admin account status (go-gitea#34493) Rework delete org and rename org UI (go-gitea#34762) Refactor editor (go-gitea#34780) Improve img lazy loading (go-gitea#34804) [skip ci] Updated translations via Crowdin Fix Feishu webhook signature verification (go-gitea#34788) Upgrade chi to v5.2.2 (go-gitea#34798) Fix the issue of abnormal interface when there is no issue-item on the project page (go-gitea#34791) Fix container range bug (go-gitea#34795) Fix OCI manifest parser (go-gitea#34797) ...
wxiaoguang commentedJul 5, 2025
-> Refactor webhook and fix feishu/lark secret#34961 |
Fix Feishu Webhook Signature Verification
This PR implements proper signature verification for Feishu (Lark) webhooks according to theofficial documentation.
Changes
GenSignfunction based on Feishu's official Go sample codeImplementation Details
The signature verification works as follows:
timestamp + "\n" + secretAccording 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