Class: Freeclimb::RequestVerifier

Inherits:
Object
  • Object
show all
Defined in:
lib/freeclimb/utils/request_verifier.rb

Constant Summary collapse

@@DEFAULT_TOLERANCE =
5 * 60 * 1000

Class Method Summary collapse

Class Method Details

.verify_request_signature(request_body, request_header, signing_secret, tolerance = DEFAULT_TOLERANCE) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/freeclimb/utils/request_verifier.rb', line 6

def verify_request_signature(request_body, request_header, signing_secret, tolerance=DEFAULT_TOLERANCE)
    request_verifier_object = Freeclimb::RequestVerifier.new()
    request_verifier_object.instance_eval{ check_request_body(request_body) }
    request_verifier_object.instance_eval{ check_request_header(request_header) }
    request_verifier_object.instance_eval{ check_signing_secret(signing_secret) }
    request_verifier_object.instance_eval{ check_tolerance(tolerance) }
    info = Freeclimb::SignatureInformation.new(request_header)
    request_verifier_object.instance_eval{ verify_tolerance(info, tolerance) }
    request_verifier_object.instance_eval{ verify_signature(info, request_body, signing_secret)}
end