title: Stripe webhook authentication - Ruby
body: <p>My ruby-on-rails application uses stripe for card payments. Stripe has a provision of webhooks through which it contacts back to my application and gives details about every transactions - succeeded or failed. </p>
  
  <p>For this, I have in my controller something like this:</p>
  
  <pre><code>class StripeController &lt; ApplicationController
    def webhook
      data_json = JSON.parse request.body.read
      p data_json['data']['object']['customer']
    end
  </code></pre>
  
  <p>My question is how can I validate the authenticity of this webhook? To my knowledge and understanding one can easily imitate this (man-in-the-middle attack).  </p>