How to verify a post-receive hook request actually came from github?

前端 未结 5 1525
不知归路
不知归路 2020-12-08 16:19

Github offers a way to let a URL know when a project has been updated using webhooks.

How do I verify that a post sent to my server\'s post-receive hook act

5条回答
  •  鱼传尺愫
    2020-12-08 17:12

    In addition to @mnml's answer, the second step could be to just call up the API and verify that the information given matches the last known commit for the project. It's the same process that OpenID uses to verify the data passed is valid.

    So, first I could defeat dumb reply attacks, by just checking the IP. Next I could ask github if the information I received is correct.

    GET /repos/:user/:repo/commits/:sha
    

提交回复
热议问题