Replace hook IP address validation with signature check #204
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Background
We are trying to set up a comfortable environment for development and testing, overall notes here:
https://github.com/KSP-SpaceDock/SpaceDock/wiki/Migration-notes-and-tasks
We already have branches and servers set up for alpha and beta. The last remaining piece is the automatic redeployment.
Problem
SpaceDock inherited a mechanism to restart itself via a web hook from KerbalStuff:
SpaceDock/KerbalStuff/app.py
Lines 126 to 149 in e537e22
We have done our best to set this up. #203 and #195 were merged for testing and the hook fired:
However, no pull or restart was done.
Cause
I believe this is because 10.150.1.9 (presumably the reverse proxy) does not match the IP addresses that are considered to be trusted GitHub addresses:
Since everything goes through the reverse proxy, adding it to that setting would enable everyone to trigger the hook whenever they liked, so that won't work. We need a better way of authenticating the web hook.
Changes
If you set a secret string in your web hook, GitHub will use it to sign outgoing messages in the
X-Hub-Signature
header:Now SpaceDock supports this via a
hook_secret
setting inconfig.ini
. The IP address setting is removed (it was just a bad approach).After this is merged and pulled to the alpha server, the same secret string should be set in the web hook configuration on GitHub and in the
config.ini
file on the alpha server. Then we will need to merge a PR to test it.