Class: DIDWW::Callback::RequestValidator
- Inherits:
-
Object
- Object
- DIDWW::Callback::RequestValidator
- Defined in:
- lib/didww/callback/request_validator.rb
Overview
signature = env validator.validate(uri, params, signature) #=> true if the request is from DIDWW # or with rails
Constant Summary collapse
- DIGEST_ALGO =
'SHA1'
- HEADER =
'X-DIDWW-Signature'
Instance Method Summary collapse
-
#initialize(api_key) ⇒ RequestValidator
constructor
A new instance of RequestValidator.
-
#validate(url, payload, signature) ⇒ Boolean
Whether signature valid or not.
Constructor Details
#initialize(api_key) ⇒ RequestValidator
Returns a new instance of RequestValidator.
23 24 25 |
# File 'lib/didww/callback/request_validator.rb', line 23 def initialize(api_key) @api_key = api_key end |
Instance Method Details
#validate(url, payload, signature) ⇒ Boolean
Returns whether signature valid or not.
31 32 33 34 35 |
# File 'lib/didww/callback/request_validator.rb', line 31 def validate(url, payload, signature) return false if signature.blank? signature == valid_signature(url, payload) end |