Class: AWS::DefaultSigner

Inherits:
Object
  • Object
show all
Defined in:
lib/aws/default_signer.rb

Overview

Computes signatures using credentials that are stored in memory.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(access_key_id, secret_access_key) ⇒ DefaultSigner

Returns a new instance of DefaultSigner.

Parameters:

  • access_key_id (String)

    The Access Key ID used to sign requests.

  • secret_access_key (String)

    The Secret Access Key used to sign requests.



33
34
35
36
# File 'lib/aws/default_signer.rb', line 33

def initialize(access_key_id, secret_access_key)
  @access_key_id = access_key_id
  @secret_access_key = secret_access_key
end

Instance Attribute Details

#access_key_idString (readonly)

Returns The Access Key ID used to sign requests.

Returns:

  • (String)

    The Access Key ID used to sign requests.



23
24
25
# File 'lib/aws/default_signer.rb', line 23

def access_key_id
  @access_key_id
end

#secret_access_keyString (readonly)

Returns The Secret Access Key used to sign requests.

Returns:

  • (String)

    The Secret Access Key used to sign requests.



26
27
28
# File 'lib/aws/default_signer.rb', line 26

def secret_access_key
  @secret_access_key
end

Instance Method Details

#sign(string_to_sign, digest_method = 'sha256') ⇒ Object

Signs a string using the credentials stored in memory.

Parameters:

  • string_to_sign (String)

    The string to sign.

  • digest_method (String) (defaults to: 'sha256')

    The digest method to use when computing the HMAC digest.



44
45
46
47
48
49
50
# File 'lib/aws/default_signer.rb', line 44

def sign(string_to_sign, digest_method = 'sha256')
  Base64.encode64(
    OpenSSL::HMAC.digest(
      OpenSSL::Digest::Digest.new(digest_method),
      secret_access_key, 
      string_to_sign)).strip
end