class Yoti::SignedRequest
Converts a basic Net::HTTP request into a Yoti
Signed Request
Public Class Methods
new(unsigned_request, path, payload = {})
click to toggle source
@param [Net::HTTPRequest] unsigned_request @param [String] path @param [#to_json,String] payload
# File lib/yoti/http/signed_request.rb, line 11 def initialize(unsigned_request, path, payload = {}) @http_req = unsigned_request @path = path @payload = payload @auth_key = Yoti::SSL.auth_key_from_pem end
Public Instance Methods
sign()
click to toggle source
@return [Net::HTTPRequest]
# File lib/yoti/http/signed_request.rb, line 21 def sign @http_req['X-Yoti-Auth-Digest'] = message_signature @http_req['X-Yoti-SDK'] = Yoti.configuration.sdk_identifier @http_req['X-Yoti-SDK-Version'] = "#{Yoti.configuration.sdk_identifier}-#{Yoti::VERSION}" @http_req end
Private Instance Methods
base64_payload()
click to toggle source
# File lib/yoti/http/signed_request.rb, line 38 def base64_payload return '' unless @payload payload_string = @payload.is_a?(String) ? @payload : @payload.to_json "&#{Base64.strict_encode64(payload_string)}" end
http_method()
click to toggle source
# File lib/yoti/http/signed_request.rb, line 34 def http_method @http_req.method end
message_signature()
click to toggle source
# File lib/yoti/http/signed_request.rb, line 30 def message_signature @message_signature ||= Yoti::SSL.get_secure_signature("#{http_method}&#{@path}#{base64_payload}") end