Module: EC2::Common::Signature
- Defined in:
- lib/ec2/common/signature.rb
Class Method Summary collapse
- .curl_args_sigv2(url, bucket, http_method, options, user, pass) ⇒ Object
- .curl_args_sigv4(url, region, bucket, http_method, optional_headers, user, pass, data = nil) ⇒ Object
- .parseURL(url, bucket) ⇒ Object
Class Method Details
.curl_args_sigv2(url, bucket, http_method, options, user, pass) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/ec2/common/signature.rb', line 19 def self.curl_args_sigv2(url, bucket, http_method, , user, pass) headers = EC2::Common::Headers.new(http_method) .each do |name, value| headers.add(name, value) end headers.sign(user, pass, url, bucket) if user and pass headers.get end |
.curl_args_sigv4(url, region, bucket, http_method, optional_headers, user, pass, data = nil) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/ec2/common/signature.rb', line 26 def self.curl_args_sigv4(url, region, bucket, http_method, optional_headers, user, pass, data=nil) aws_secret_access_key = pass aws_access_key_id = user if (user.is_a?(Hash)) aws_access_key_id = user['aws_access_key_id'] aws_secret_access_key = user['aws_secret_access_key'] delegation_token = user['aws_delegation_token'] end host, path, query = parseURL(url, bucket) hexdigest = if data HeadersV4::hexdigest data else HeadersV4::hexdigest "" end optional_headers ||= {} unless delegation_token.nil? optional_headers[EC2::Common::Headers::X_AMZ_SECURITY_TOKEN] = delegation_token end headers_obj = HeadersV4.new({:host => host, :hexdigest_body => hexdigest, :region => region, :service => "s3", :http_method => http_method, :path => path, :querystring => query, :access_key_id => aws_access_key_id, :secret_access_key => aws_secret_access_key}, optional_headers) headers = headers_obj. headers end |
.parseURL(url, bucket) ⇒ Object
58 59 60 61 62 63 64 65 |
# File 'lib/ec2/common/signature.rb', line 58 def self.parseURL(url, bucket) uri = URI.parse(url) host = uri.host path = uri.path path = "/" if path == "" [host, path, "#{uri.query}"] end |