lib/azure/signature.rb
# Generate a signature for use with the table service. Use the +options+
# hash to pass optional information. The following keys are supported:
#
# - :auth_type. Either 'SharedKey' (the default) or 'SharedKeyLight'.
# - :verb. The http verb used for SharedKey auth. The default is 'GET'.
# - :date. The date (or x-ms-date) used. The default is Time.now.httpdate.
# - :content_md5. The Content-MD5 if desired. The default is nil.
# - :content_type. The Content-Type if desired. The default is nil.
# - :auth_string. If true, prepends the auth_type + account name to the
#    result and returns a string. The default is false.
#
# You may also use the string forms as keys, e.g. "Auth-Type" instead of
# :auth_type, if you prefer.
#
# The result is a digest string that you can use as an authorization header
# for future http requests to (presumably) Azure storage endpoints.
#
Generate a signature for use with the table service. Use the +options+
hash to pass optional information. The following keys are supported.



You may also use the string forms as keys, e.g. "Auth-Type" instead of
:auth_type, if you prefer.

The result is a digest string that you can use as an authorization header
for future http requests to (presumably) Azure storage endpoints.
Generate a signature for use with the table service . Use the + options + hash to pass optional information . The following keys are supported . You may also use the string forms as keys e . g . " Auth - Type " instead of : auth_type if you prefer . The result is a digest string that you can use as an authorization header for future http requests to ( presumably ) Azure storage endpoints .
def table_signature(options = {})
      options = options.transform_keys { |key| key.to_s.downcase.tr('_', '-') }
      auth_type    = options['auth-type'] || 'SharedKey'
      verb         = options['verb'] || 'GET'
      date         = options['date'] || options['x-ms-date'] || Time.now.httpdate
      auth_string  = options['auth-string'] || false
      content_md5  = options['content-md5']
      content_type = options['content-type']
      unless ['SharedKey', 'SharedKeyLight'].include?(auth_type)
        raise ArgumentError, "auth type must be SharedKey or SharedKeyLight"
      end
      if auth_type == 'SharedKey'
        body = [verb, content_md5, content_type, date, canonical_resource].join("\n").encode('UTF-8')
      else
        body = [date, canonical_resource].join("\n").encode('UTF-8')
      end
      if auth_string
        "#{auth_type} #{account_name}:" + sign(body)
      else
        sign(body)
      end
    end
def table_signature ( options = { } ) options = options . transform_keys { | key | key . to_s . downcase . tr ( '_' , '-' ) } auth_type = options [ 'auth-type' ] || 'SharedKey' verb = options [ 'verb' ] || 'GET' date = options [ 'date' ] || options [ 'x-ms-date' ] || Time . now . httpdate auth_string = options [ 'auth-string' ] || false content_md5 = options [ 'content-md5' ] content_type = options [ 'content-type' ] unless [ 'SharedKey' , 'SharedKeyLight' ] . include? ( auth_type ) raise ArgumentError , "auth type must be SharedKey or SharedKeyLight" end if auth_type == 'SharedKey' body = [ verb , content_md5 , content_type , date , canonical_resource ] . join ( "\n" ) . encode ( 'UTF-8' ) else body = [ date , canonical_resource ] . join ( "\n" ) . encode ( 'UTF-8' ) end if auth_string "#{auth_type} #{account_name}:" + sign ( body ) else sign ( body ) end end
Generate a signature for use with the table service.
Generate a signature for use with the table service .
options
<not_specific>