class Azure::Table::Auth::SharedKey

Attributes

account_name[R]

The account name

Public Instance Methods

canonicalized_resource(uri) click to toggle source

Calculate the Canonicalized Resource string for a request.

@param uri [URI] The request's URI.

@return [String] with the canonicalized resource.

# File lib/azure/table/auth/shared_key.rb, line 47
def canonicalized_resource(uri)
  resource = "/#{account_name}#{uri.path}"

  comp = CGI.parse(uri.query.to_s).fetch('comp', nil)
  resource = [resource, 'comp=' + comp[0]].join('?') if comp

  resource
end
signable_string(method, uri, headers) click to toggle source

Generate the string to sign.

@param method [Symbol] The HTTP request method. @param uri [URI] The URI of the request we're signing. @param headers [Hash] The HTTP request headers.

Returns a plain text string.

# File lib/azure/table/auth/shared_key.rb, line 32
def signable_string(method, uri, headers)
  [
      method.to_s.upcase,
      headers.fetch('Content-MD5', ''),
      headers.fetch('Content-Type', ''),
      headers.fetch('Date') { headers.fetch('x-ms-date') },
      canonicalized_resource(uri)
  ].join("\n")
end