sendgrid / sendgrid-ruby

The Official Twilio SendGrid Led, Community Driven Ruby API Library
https://sendgrid.com
MIT License
621 stars 324 forks source link

feat: adds rack middleware to make request verification easier in rack apps. #428

Closed philnash closed 4 years ago

philnash commented 4 years ago

This adds a class that can be used to verify requests with a public key in rack applications like Rails or Sinatra. This was based on my work on the twilio-ruby rack middleware here.

This also changed the class to fail verification if an error was thrown. In the case where a signature was missing, OpenSSL would throw an error instead of returning false for a invalid signature. I think it's more appropriate for the verification to fail than to throw an error at this point, especially since the error came from OpenSSL and wasn't otherwise clear.

Checklist

philnash commented 4 years ago

This probably wants another look after #427 is merged just to make sure.