Class: CORS::Policy::S3
- Inherits:
-
Object
- Object
- CORS::Policy::S3
- Includes:
- CORS::Policy
- Defined in:
- lib/cors/policy/s3.rb
Overview
CORS policy for Amazon S3. See CORS module documenation for an example.
Instance Attribute Summary
Attributes included from CORS::Policy
Instance Method Summary collapse
-
#manifest ⇒ Object
Compile the S3 authorization manifest from the parameters.
-
#sign!(access_key, secret_access_key) ⇒ Object
Sign the #manifest with the AWS credentials.
Methods included from CORS::Policy
included, #initialize, #rules, #sign, #valid?
Instance Method Details
#manifest ⇒ Object
Compile the S3 authorization manifest from the parameters.
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/cors/policy/s3.rb', line 14 def manifest [].tap do |manifest| manifest << attributes["method"].upcase manifest << attributes["md5"] manifest << attributes["content-type"] manifest << attributes["date"] normalized_headers.each do |(header, *values)| manifest << "#{header}:#{values.join(",")}" end manifest << attributes["filename"] end.join("\n") end |
#sign!(access_key, secret_access_key) ⇒ Object
Sign the #manifest with the AWS credentials.
31 32 33 34 35 |
# File 'lib/cors/policy/s3.rb', line 31 def sign!(access_key, secret_access_key) digest = OpenSSL::HMAC.digest("sha1", secret_access_key, manifest) signature = Base64.strict_encode64(digest) "AWS #{access_key}:#{signature}" end |