Class: AlexaRuby::Validator
- Inherits:
-
Object
- Object
- AlexaRuby::Validator
- Defined in:
- lib/alexa_ruby/request/base_request/validator.rb
Overview
Validator is responsible for Amazon request validation:
- SignatureCertChainUrl validation
- Amazon Alexa request signature validation
Constant Summary collapse
- TIMESTAMP_TOLERANCE =
150
Instance Method Summary collapse
-
#initialize(cert_chain_url, signature, request, timestamp_diff = nil) ⇒ Validator
constructor
Setup new validator.
-
#valid_request? ⇒ Boolean
Check if it is a valid Amazon request.
Constructor Details
#initialize(cert_chain_url, signature, request, timestamp_diff = nil) ⇒ Validator
Setup new validator
17 18 19 20 21 22 |
# File 'lib/alexa_ruby/request/base_request/validator.rb', line 17 def initialize(cert_chain_url, signature, request, = nil) @chain_url = cert_chain_url @signature = signature @request = request @timestamp_diff = || TIMESTAMP_TOLERANCE end |
Instance Method Details
#valid_request? ⇒ Boolean
Check if it is a valid Amazon request
27 28 29 30 31 32 33 34 |
# File 'lib/alexa_ruby/request/base_request/validator.rb', line 27 def valid_request? unless raise ArgumentError, 'Outdated request: request timestamp is more than ' \ "#{@timestamp_diff} seconds later than current time" end valid_uri? && valid_certificates? end |