Class: Incoming::Strategies::HTTPPost
- Inherits:
-
Object
- Object
- Incoming::Strategies::HTTPPost
- Includes:
- Incoming::Strategy
- Defined in:
- lib/incoming/strategies/http_post.rb
Instance Attribute Summary collapse
-
#signature ⇒ Object
Returns the value of attribute signature.
-
#timestamp ⇒ Object
Returns the value of attribute timestamp.
-
#token ⇒ Object
Returns the value of attribute token.
Attributes included from Incoming::Strategy
Instance Method Summary collapse
- #authenticate ⇒ Object
-
#initialize(request) ⇒ HTTPPost
constructor
A new instance of HTTPPost.
Methods included from Incoming::Strategy
Constructor Details
#initialize(request) ⇒ HTTPPost
Returns a new instance of HTTPPost.
10 11 12 13 14 15 16 17 |
# File 'lib/incoming/strategies/http_post.rb', line 10 def initialize(request) params = request.params @signature = params['signature'] @token = params['token'] @timestamp = params['timestamp'] @message = Mail.new(params['message']) end |
Instance Attribute Details
#signature ⇒ Object
Returns the value of attribute signature.
8 9 10 |
# File 'lib/incoming/strategies/http_post.rb', line 8 def signature @signature end |
#timestamp ⇒ Object
Returns the value of attribute timestamp.
8 9 10 |
# File 'lib/incoming/strategies/http_post.rb', line 8 def @timestamp end |
#token ⇒ Object
Returns the value of attribute token.
8 9 10 |
# File 'lib/incoming/strategies/http_post.rb', line 8 def token @token end |
Instance Method Details
#authenticate ⇒ Object
19 20 21 22 |
# File 'lib/incoming/strategies/http_post.rb', line 19 def authenticate hexdigest = OpenSSL::HMAC.hexdigest(OpenSSL::Digest::Digest.new('SHA256'), self.class.[:secret], [, token].join) hexdigest.eql?(signature) or false end |