Syndicate endpoint: Support multiple methods of supplying a token #571
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.
Finally spent some time investigating how to use JWT/JWS tokens in Netlify’s webhook feature.
Rather than provide a
token
in the URLs query string (the token for which expires after 90 days), you can instead provide a secret token. This would be saved as an environment variable for your Indiekit server to use (WEBHOOK_SECRET
1) and this same value would be supplied for ‘JWS secret token’ in Netlify’s outgoing webhook form.If a secret token is provided, Netlify will send a signature in the
X-Webhook-Signature
header. Indiekit will see this, verify it can be signed with the shared secret, and then generate a short lived (10 minutes) access token with only theupdate
scope. In addition, theme
value will be taken from theurl
value provided in the webhook body from Netlify.This means that, the verified token supplied by the
X-Webhook-Signature
header:issuer
value ofnetlify
In addition, the webhook will only syndicate if the URL matches that provided in an Indiekit server’s configuration (
publication.me
).Hopefully this method is a little more convenient, and saves sharing an access token with Netlify. It does mean saving another environment variable, however.
A bearer token can be provided in a
token
query string, or using theaccess_token
form body value.The syndication endpoint is also no longer behind authentication; no posts can be updated as the Micropub endpoint remains behind authentication (and can only be authenticated using a valid access token, or one generated using a webhook signature as described above).
Footnotes
WEBHOOK_SECRET
orNETLIFY_SECRET
🤔 ↩