Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syndicate endpoint: Support multiple methods of supplying a token #571

Merged
merged 2 commits into from
Jan 7, 2023

Conversation

paulrobertlloyd
Copy link
Collaborator

@paulrobertlloyd paulrobertlloyd commented Jan 5, 2023

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_SECRET1) 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 the update scope. In addition, the me value will be taken from the url value provided in the webhook body from Netlify.

This means that, the verified token supplied by the X-Webhook-Signature header:

  • MUST use SHA256 algorithm
  • MUST be have an issuer value of netlify
  • MUST be signed using the same secret token

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 the access_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

  1. WEBHOOK_SECRET or NETLIFY_SECRET 🤔

@paulrobertlloyd paulrobertlloyd added enhancement New feature or request plugin-endpoint Endpoint plug-in labels Jan 5, 2023
@paulrobertlloyd paulrobertlloyd self-assigned this Jan 5, 2023
@paulrobertlloyd
Copy link
Collaborator Author

@sentience Feel free to chime in with any feedback. Once this is merged, I think syndication should work properly again, and also be easier to set up and maintain.

@paulrobertlloyd paulrobertlloyd marked this pull request as ready for review January 7, 2023 21:21
@paulrobertlloyd paulrobertlloyd merged commit 23e6c92 into main Jan 7, 2023
@paulrobertlloyd paulrobertlloyd deleted the netlify-webhook-token branch January 7, 2023 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request plugin-endpoint Endpoint plug-in
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant