HashNuke/mailgun — pull request #21 by alansikora (2013-09-30 19:53:40+00:00)
Title: Added webhook's authenticity check functionality

Added a Secure module with a method called "check_request_auth", that'll receive 3 parameters:

timestamp: the timestamp that was sent on the webhook request
token: the token that was sent on the webhook request
signature: the signature that was sent on the webhook request

Also, the Secure module gets a parameter called offset, that is used to check if the webhook request is new enough, preventing someone to copy a timestamp, token and signature and use them to make requests anytime.

```ruby
# will return true to up to 10 minutes old requests
@mailgun.secure(10).check_request_auth(timestamp, token, signature)

# will return true to up to 5 minutes old requests (default)
@mailgun.secure.check_request_auth(timestamp, token, signature)
```

However, if you want to skip timestamp check, just pass false when you call the secure module:

```ruby
# will return true to any valid request, old or not
@mailgun.secure(false).check_request_auth(timestamp, token, signature)
```