class TencentCloudCos::Authorization
Attributes
config[R]
Public Class Methods
new(config)
click to toggle source
# File lib/tencent_cloud_cos/authorization.rb, line 8 def initialize(config) @config = config end
Public Instance Methods
auth_header()
click to toggle source
# File lib/tencent_cloud_cos/authorization.rb, line 20 def auth_header auth = "q-sign-algorithm=sha1&q-ak=#{secret_id}&q-sign-time=#{sign_time}&q-key-time=#{sign_time}&q-header-list=content-type;host&q-url-param-list=&q-signature=#{sign}" end
sign()
click to toggle source
# File lib/tencent_cloud_cos/authorization.rb, line 12 def sign sign_key = OpenSSL::HMAC.hexdigest('sha1', secret_key, sign_time) http_string = "#{method}\n#{uri}\n\ncontent-type=#{content_type}&host=#{host}\n" sha1ed_http_string = Digest::SHA1.hexdigest http_string string_to_sign = "sha1\n#{sign_time}\n#{sha1ed_http_string}\n" signature = OpenSSL::HMAC.hexdigest('sha1', sign_key, string_to_sign) end
Private Instance Methods
content_type()
click to toggle source
# File lib/tencent_cloud_cos/authorization.rb, line 50 def content_type URI::escape(@config.content_type, /\W/) end
host()
click to toggle source
# File lib/tencent_cloud_cos/authorization.rb, line 26 def host @config.host end
method()
click to toggle source
# File lib/tencent_cloud_cos/authorization.rb, line 42 def method @config.method end
secret_id()
click to toggle source
# File lib/tencent_cloud_cos/authorization.rb, line 30 def secret_id @config.secret_id end
secret_key()
click to toggle source
# File lib/tencent_cloud_cos/authorization.rb, line 34 def secret_key @config.secret_key end
sign_time()
click to toggle source
# File lib/tencent_cloud_cos/authorization.rb, line 46 def sign_time "#{Time.now.to_i-60};#{Time.now.to_i + 3600}" end
uri()
click to toggle source
# File lib/tencent_cloud_cos/authorization.rb, line 38 def uri @config.uri end