class Uploadcare::Param::SecureAuthHeader
This object returns headers needed for authentication This authentication method is more secure, but more tedious
Public Class Methods
call(**options)
click to toggle source
@see uploadcare.com/docs/api_reference/rest/requests_auth/#auth-uploadcare
# File lib/uploadcare/param/secure_auth_header.rb, line 11 def self.call(**options) @method = options[:method] @body = options[:content] || '' @content_type = options[:content_type] @uri = options[:uri] @date_for_header = timestamp { 'Date': @date_for_header, 'Authorization': "Uploadcare #{Uploadcare.config.public_key}:#{signature}" } end
signature()
click to toggle source
# File lib/uploadcare/param/secure_auth_header.rb, line 24 def signature content_md5 = Digest::MD5.hexdigest(@body) sign_string = [@method, content_md5, @content_type, @date_for_header, @uri].join("\n") digest = OpenSSL::Digest.new('sha1') OpenSSL::HMAC.hexdigest(digest, Uploadcare.config.secret_key, sign_string) end
timestamp()
click to toggle source
# File lib/uploadcare/param/secure_auth_header.rb, line 31 def timestamp Time.now.gmtime.strftime('%a, %d %b %Y %H:%M:%S GMT') end