Sha256: 3dca9110620f4fc49369b96f96b0d336e693ee75124a78c6ac778c6549803808

Contents?: true

Size: 890 Bytes

Versions: 2

Compression:

Stored size: 890 Bytes

Contents

require "azure/configuration"

module Azure
  class Auth
    # The account name.
    attr :account_name

    # Public: Initialize the Auth object.
    #
    # account_name - A String with the Azure account's name. Defaults to the one
    #                in the global configuration.
    def initialize(account_name=Azure.config.account_name)
      @account_name = account_name
    end

    # Public: Signs an HTTP request before it's made, by adding the
    # Authorization header.
    #
    # request - An Azure::Request that hasn't been signed.
    # signer  - A signing strategy, such as Azure::Table::Auth::SharedKey.
    #
    # Returns the modified request.
    def sign(request, signer)
      signature = signer.sign(request.method, request.uri, request.headers)
      request.headers["Authorization"] = "#{signer.name} #{account_name}:#{signature}"
      request
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
azure-0.1.1 lib/azure/auth.rb
azure-0.1.0 lib/azure/auth.rb