Class: AWS::S3::Authentication::CanonicalString

Inherits:
String show all
Defined in:
lib/aws/s3/authentication.rb

Overview

The CanonicalString is used to generate an encrypted signature, signed with your secrect access key. It is composed of data related to the given request for which it provides authentication. This data includes the request method, request headers, and the request path. Both Header and QueryString use it to generate their signature.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from String

#previous, #previous!, #remove_extended, #remove_extended!, #tap, #to_header, #underscore, #valid_utf8?

Constructor Details

#initialize(request, options = {}) ⇒ CanonicalString


173
174
175
176
177
178
179
180
181
182
183
# File 'lib/aws/s3/authentication.rb', line 173

def initialize(request, options = {})
  super()
  @request = request
  @headers = {}
  @options = options
  # "For non-authenticated or anonymous requests. A NotImplemented error result code will be returned if 
  # an authenticated (signed) request specifies a Host: header other than 's3.amazonaws.com'"
  # (from http://docs.amazonwebservices.com/AmazonS3/2006-03-01/VirtualHosting.html)
  request['Host'] = DEFAULT_HOST
  build
end

Instance Attribute Details

#headersObject (readonly)

Returns the value of attribute headers


171
172
173
# File 'lib/aws/s3/authentication.rb', line 171

def headers
  @headers
end

#requestObject (readonly)

Returns the value of attribute request


171
172
173
# File 'lib/aws/s3/authentication.rb', line 171

def request
  @request
end

Class Method Details

.amazon_header_prefixObject


144
145
146
# File 'lib/aws/s3/authentication.rb', line 144

def amazon_header_prefix
  /^#{AMAZON_HEADER_PREFIX}/io
end

.default_headersObject


136
137
138
# File 'lib/aws/s3/authentication.rb', line 136

def default_headers
  %w(content-type content-md5)
end

.interesting_headersObject


140
141
142
# File 'lib/aws/s3/authentication.rb', line 140

def interesting_headers
  ['content-md5', 'content-type', 'date', amazon_header_prefix]
end

.query_parametersObject


148
149
150
151
152
153
154
155
# File 'lib/aws/s3/authentication.rb', line 148

def query_parameters
  %w(acl location logging notification partNumber policy
     requestPayment torrent uploadId uploads versionId
     versioning versions delete lifecycle tagging cors
     response-content-type response-content-language
     response-expires response-cache-control
     response-content-disposition response-content-encoding)
end

.query_parameters_for_signature(params) ⇒ Object


157
158
159
# File 'lib/aws/s3/authentication.rb', line 157

def query_parameters_for_signature(params)
  params.select {|k, v| query_parameters.include?(k)}
end

.resource_parametersObject


161
162
163
# File 'lib/aws/s3/authentication.rb', line 161

def resource_parameters
  Set.new %w(acl logging torrent)
end