Class: Aws::Sigv2::Signer Deprecated
- Inherits:
-
Object
- Object
- Aws::Sigv2::Signer
- Defined in:
- gems/aws-sigv2/lib/aws-sigv2/signer.rb
Overview
Deprecated.
This signer is deprecated. You should use
the aws-sigv4
gem instead.
Instance Attribute Summary collapse
-
#credentials_provider ⇒ #credentials
readonly
Returns an object that responds to
#credentials
returning a Credentials object.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Signer
constructor
A new instance of Signer.
-
#sign_request(request) ⇒ Hash
Computes a version 2 signature.
Constructor Details
#initialize(access_key_id: , secret_access_key: , session_token: nil) ⇒ Signer #initialize(credentials: ) ⇒ Signer #initialize(credentials_provider: ) ⇒ Signer
Returns a new instance of Signer.
30 31 32 |
# File 'gems/aws-sigv2/lib/aws-sigv2/signer.rb', line 30 def initialize( = {}) @credentials_provider = extract_credentials_provider() end |
Instance Attribute Details
#credentials_provider ⇒ #credentials (readonly)
Returns an object that responds
to #credentials
returning a Credentials object.
36 37 38 |
# File 'gems/aws-sigv2/lib/aws-sigv2/signer.rb', line 36 def credentials_provider @credentials_provider end |
Instance Method Details
#sign_request(request) ⇒ Hash
Computes a version 2 signature. The signature is returned as a hash of request parameters that should be applied to the HTTP request. The given request will not be modified.
signature = signer.sign_request(
http_method: 'POST',
url: 'https://domain.com',
params: {
'Param.Name' => 'Param.Value',
}
)
# Returns a hash with the following keys:
signature['AWSAccessKeyId']
signature['SecurityToken'] # when using session credentials
signature['Timestamp']
signature['SignatureVersion']
signature['SignatureMethod']
signature['Signature']
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'gems/aws-sigv2/lib/aws-sigv2/signer.rb', line 79 def sign_request(request) creds = @credentials_provider.credentials http_method = extract_http_method(request) url = extract_url(request) params = request[:params] || {} = params['Timestamp'] ||= Time.now.utc.strftime('%Y-%m-%dT%H:%M:%SZ') auth_params = {} auth_params['AWSAccessKeyId'] = creds.access_key_id auth_params['SecurityToken'] = creds.session_token if creds.session_token auth_params['Timestamp'] = auth_params['SignatureVersion'] = '2' auth_params['SignatureMethod'] = 'HmacSHA256' sts = string_to_sign(http_method, url, params.merge(auth_params)) auth_params['Signature'] = signature(sts, creds.secret_access_key) auth_params end |