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

Add cryptographic signing for outgoing webhooks. #216

Open
andrewculver opened this issue Mar 24, 2023 · 2 comments · May be fixed by #292
Open

Add cryptographic signing for outgoing webhooks. #216

andrewculver opened this issue Mar 24, 2023 · 2 comments · May be fixed by #292
Assignees

Comments

@andrewculver
Copy link
Contributor

No description provided.

@bhumi1102
Copy link
Contributor

bhumi1102 commented Apr 19, 2023

Thinking through this: If we add cryptographic signing to BT outgoing webhooks, the clients receiving the webhooks would 1. need to update code to verify the signature and 2. we'd need a mechanism to generate and provide a shared secret? does that match up with what you're thinking?

Not sure the best to share the signing secret, I suppose somewhere in the BT admin dashboard. Stripe provides the signing secret in the stripe CLI. I also dug up the code stripe is using the sign their webhooks for fun:

      # Computes a webhook signature given a time (probably the current time),
      # a payload, and a signing secret.
      def self.compute_signature(timestamp, payload, secret)
        raise ArgumentError, "timestamp should be an instance of Time" \
          unless timestamp.is_a?(Time)
        raise ArgumentError, "payload should be a string" \
          unless payload.is_a?(String)
        raise ArgumentError, "secret should be a string" \
          unless secret.is_a?(String)

        timestamped_payload = "#{timestamp.to_i}.#{payload}"
        OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new("sha256"), secret,
                                timestamped_payload)
      end

@andrewculver
Copy link
Contributor Author

@bhumi1102 Verifying the signature is totally optional, so no one will need to update any webhook processing code. It'll just give them a good option for validating the webhook originated at the right place and has not been tampered with.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants