Class: Mailgun::Secure
Instance Method Summary collapse
-
#check_request_auth(timestamp, token, signature, offset = -5)) ⇒ Object
check request auth.
-
#initialize(mailgun) ⇒ Secure
constructor
A new instance of Secure.
Constructor Details
#initialize(mailgun) ⇒ Secure
Returns a new instance of Secure.
13 14 15 |
# File 'lib/mailgun/secure.rb', line 13 def initialize(mailgun) @mailgun = mailgun end |
Instance Method Details
#check_request_auth(timestamp, token, signature, offset = -5)) ⇒ Object
check request auth
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/mailgun/secure.rb', line 18 def check_request_auth(, token, signature, offset=-5) if offset != 0 offset = Time.now.to_i + offset * 60 return false if < offset end return signature == OpenSSL::HMAC.hexdigest( OpenSSL::Digest::Digest.new('sha256'), Mailgun.api_key, '%s%s' % [, token]) end |