aws-sdk-core 2.3.12 → 2.3.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/apis/s3/2006-03-01/api-2.json +2 -2
- data/apis/s3/2006-03-01/paginators-1.json +9 -0
- data/lib/aws-sdk-core/cloudfront.rb +8 -0
- data/lib/aws-sdk-core/cloudfront/url_signer.rb +167 -0
- data/lib/aws-sdk-core/version.rb +1 -1
- data/lib/seahorse/client/configuration.rb +9 -3
- data/lib/seahorse/client/net_http/connection_pool.rb +0 -11
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 824789d9b05e226344a7369f43a1a0c31052c0fc
|
4
|
+
data.tar.gz: 932e136986cb354d8da7f6fd565aa111d93ccc5d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8482776c328cfdff143cc1919a91e6b1025bb0bffe9f541e38b9b01f3b9a6756e4f830fa0844cf764fcda2e498a90b5daf7a8da477c740ad3ba1dfacdf473585
|
7
|
+
data.tar.gz: b4bb03463ff83bf2e46b7a87f07511c769076c601a8854edfd924ccd57710af03f709c749978b49be538679136b57fdfe2ae53a98198bf99c68b654bba9cc722
|
@@ -963,7 +963,7 @@
|
|
963
963
|
"ContentDisposition":{"type":"string"},
|
964
964
|
"ContentEncoding":{"type":"string"},
|
965
965
|
"ContentLanguage":{"type":"string"},
|
966
|
-
"ContentLength":{"type":"
|
966
|
+
"ContentLength":{"type":"long"},
|
967
967
|
"ContentMD5":{"type":"string"},
|
968
968
|
"ContentRange":{"type":"string"},
|
969
969
|
"ContentType":{"type":"string"},
|
@@ -2913,7 +2913,7 @@
|
|
2913
2913
|
"StartAfter":{
|
2914
2914
|
"shape":"StartAfter",
|
2915
2915
|
"location":"querystring",
|
2916
|
-
"locationName":"start-
|
2916
|
+
"locationName":"start-after"
|
2917
2917
|
}
|
2918
2918
|
}
|
2919
2919
|
},
|
@@ -46,6 +46,15 @@
|
|
46
46
|
"CommonPrefixes"
|
47
47
|
]
|
48
48
|
},
|
49
|
+
"ListObjectsV2": {
|
50
|
+
"limit_key": "MaxKeys",
|
51
|
+
"output_token": "NextContinuationToken",
|
52
|
+
"input_token": "ContinuationToken",
|
53
|
+
"result_key": [
|
54
|
+
"Contents",
|
55
|
+
"CommonPrefixes"
|
56
|
+
]
|
57
|
+
},
|
49
58
|
"ListParts": {
|
50
59
|
"more_results": "IsTruncated",
|
51
60
|
"limit_key": "MaxParts",
|
@@ -5,3 +5,11 @@ Aws.add_service(:CloudFront, {
|
|
5
5
|
paginators: "#{Aws::API_DIR}/cloudfront/2016-01-28/paginators-1.json",
|
6
6
|
waiters: "#{Aws::API_DIR}/cloudfront/2016-01-28/waiters-2.json",
|
7
7
|
})
|
8
|
+
|
9
|
+
module Aws
|
10
|
+
module CloudFront
|
11
|
+
|
12
|
+
autoload :UrlSigner, 'aws-sdk-core/cloudfront/url_signer.rb'
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,167 @@
|
|
1
|
+
require 'base64'
|
2
|
+
require 'uri'
|
3
|
+
require 'time'
|
4
|
+
require 'json'
|
5
|
+
require 'openssl'
|
6
|
+
|
7
|
+
module Aws
|
8
|
+
module CloudFront
|
9
|
+
|
10
|
+
# Allows you to create signed URLs for Amazon CloudFront resources
|
11
|
+
#
|
12
|
+
# signer = Aws::CloudFront::UrlSigner.new
|
13
|
+
# url = signer.signed_url(url,
|
14
|
+
# key_pair_id: "cf-keypair-id",
|
15
|
+
# private_key_path: "./cf_private_key.pem"
|
16
|
+
# )
|
17
|
+
#
|
18
|
+
class UrlSigner
|
19
|
+
|
20
|
+
# @option options [String] :key_pair_id
|
21
|
+
# @option options [String] :private_key
|
22
|
+
# @option options [String] :private_key_path
|
23
|
+
def initialize(options = {})
|
24
|
+
@key_pair_id = key_pair_id(options)
|
25
|
+
@private_key = private_key(options)
|
26
|
+
end
|
27
|
+
|
28
|
+
# create a signed Amazon CloudFront URL
|
29
|
+
# @param [String] url
|
30
|
+
# @option params [Time, DateTime, Date, String, Integer<timestamp>] :expires
|
31
|
+
# @option params [String<JSON>] :policy
|
32
|
+
def signed_url(url, params = {})
|
33
|
+
url_sections = url.split('://')
|
34
|
+
if url_sections.length < 2
|
35
|
+
raise ArgumentError, "Invaild URL:#{url}"
|
36
|
+
end
|
37
|
+
# removing wildcard character to get real scheme
|
38
|
+
scheme = url_sections[0].gsub('*', '')
|
39
|
+
uri = "#{scheme}://#{url_sections[1]}"
|
40
|
+
signed_content = signature(
|
41
|
+
:resource => resource(scheme, uri),
|
42
|
+
:expires => time(params[:expires]),
|
43
|
+
:policy => params[:policy]
|
44
|
+
)
|
45
|
+
|
46
|
+
start_flag = URI.parse(uri).query ? '&' : '?'
|
47
|
+
uri = "#{uri}#{start_flag}#{signed_content}"
|
48
|
+
|
49
|
+
if scheme == 'rtmp'
|
50
|
+
rtmp_url(URI(uri))
|
51
|
+
else
|
52
|
+
uri
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def time(expires)
|
59
|
+
case expires
|
60
|
+
when Time then expires.to_i
|
61
|
+
when DateTime, Date then expires.to_time.to_i
|
62
|
+
when String then Time.parse(expires).to_i
|
63
|
+
when Integer, NIL then expires
|
64
|
+
else
|
65
|
+
msg = "expected a time value for :expires, got `#{expires.class}'"
|
66
|
+
raise ArgumentError, msg
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
# create a relative signed URL for RTMP distribution
|
71
|
+
def rtmp_url(uri)
|
72
|
+
result = uri.path.gsub(' ', '/')
|
73
|
+
result[0] = ''
|
74
|
+
if uri.query
|
75
|
+
"#{result}?#{uri.query}"
|
76
|
+
else
|
77
|
+
result
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
# prepare resource for signing
|
82
|
+
def resource(scheme, url)
|
83
|
+
case scheme
|
84
|
+
when 'http', 'http*', 'https' then url
|
85
|
+
when 'rtmp'
|
86
|
+
url_info = URI.parse(url)
|
87
|
+
path = url_info.path
|
88
|
+
path[0] = ''
|
89
|
+
resource_content = "#{File.dirname(path)}/#{File.basename(path)}".gsub(' ', '/')
|
90
|
+
if url_info.query
|
91
|
+
"#{resource_content}?#{uri.query}"
|
92
|
+
else
|
93
|
+
resource_content
|
94
|
+
end
|
95
|
+
else
|
96
|
+
msg = "Invaild URI scheme:#{scheme}.Scheme must be one of: http, https or rtmp."
|
97
|
+
raise ArgumentError, msg
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
# create signed values that used to construct signed URLs
|
102
|
+
# @option param [String] :resource
|
103
|
+
# @option param [Integer<timestamp>] :expires
|
104
|
+
# @option param [String<JSON>] :policy
|
105
|
+
def signature(params = {})
|
106
|
+
signature_content = []
|
107
|
+
if params[:policy]
|
108
|
+
policy = params[:policy].gsub('/\s/s', '')
|
109
|
+
signature_content << "Policy=#{encode(policy)}"
|
110
|
+
elsif params[:resource] && params[:expires]
|
111
|
+
policy = canned_policy(params[:resource], params[:expires])
|
112
|
+
signature_content << "Expires=#{params[:expires]}"
|
113
|
+
else
|
114
|
+
msg = "Either a policy or a resource with an expiration time must be provided."
|
115
|
+
raise ArgumentError, msg
|
116
|
+
end
|
117
|
+
|
118
|
+
signature_content << "Signature=#{encode(sign_policy(policy))}"
|
119
|
+
signature_content << "Key-Pair-Id=#{@key_pair_id}"
|
120
|
+
signature_content.join('&').gsub("\n", '')
|
121
|
+
end
|
122
|
+
|
123
|
+
# create the signature string with policy signed
|
124
|
+
def sign_policy(policy)
|
125
|
+
key = OpenSSL::PKey::RSA.new(@private_key)
|
126
|
+
key.sign(OpenSSL::Digest::SHA1.new, policy)
|
127
|
+
end
|
128
|
+
|
129
|
+
# create canned policy that used for signing
|
130
|
+
def canned_policy(resource, expires)
|
131
|
+
json_hash = {
|
132
|
+
'Statement' => [
|
133
|
+
'Resource' => resource,
|
134
|
+
'Condition' => {
|
135
|
+
'DateLessThan' => {'AWS:EpochTime' => expires}
|
136
|
+
}
|
137
|
+
]
|
138
|
+
}
|
139
|
+
json_hash.to_json
|
140
|
+
end
|
141
|
+
|
142
|
+
def encode(policy)
|
143
|
+
Base64.encode64(policy).gsub(/[+=\/]/, '+' => '-', '=' => '_', '/' => '~')
|
144
|
+
end
|
145
|
+
|
146
|
+
def key_pair_id(options)
|
147
|
+
if options[:key_pair_id].nil? or options[:key_pair_id] == ''
|
148
|
+
raise ArgumentError, ":key_pair_id must not be blank"
|
149
|
+
else
|
150
|
+
options[:key_pair_id]
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
def private_key(options)
|
155
|
+
if options[:private_key]
|
156
|
+
options[:private_key]
|
157
|
+
elsif options[:private_key_path]
|
158
|
+
File.open(options[:private_key_path], 'rb') { |f| f.read }
|
159
|
+
else
|
160
|
+
msg = ":private_key or :private_key_path should be provided"
|
161
|
+
raise ArgumentError, msg
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
data/lib/aws-sdk-core/version.rb
CHANGED
@@ -59,9 +59,15 @@ module Seahorse
|
|
59
59
|
end
|
60
60
|
|
61
61
|
# @api private
|
62
|
-
DynamicDefault
|
63
|
-
|
64
|
-
|
62
|
+
class DynamicDefault
|
63
|
+
attr_accessor :block
|
64
|
+
|
65
|
+
def initialize(block = nil)
|
66
|
+
@block = block
|
67
|
+
end
|
68
|
+
|
69
|
+
def call(*args)
|
70
|
+
@block.call(*args)
|
65
71
|
end
|
66
72
|
end
|
67
73
|
|
@@ -10,17 +10,6 @@ module Seahorse
|
|
10
10
|
module Client
|
11
11
|
module NetHttp
|
12
12
|
|
13
|
-
# @attr_reader [URI::HTTP,nil] http_proxy Returns the configured proxy.
|
14
|
-
# @attr_reader [Integer,Float] http_open_timeout
|
15
|
-
# @attr_reader [Integer,Float] http_read_timeout
|
16
|
-
# @attr_reader [Integer,Float] http_idle_timeout
|
17
|
-
# @attr_reader [Float,nil] http_continue_timeout
|
18
|
-
# @attr_reader [Boolean] http_wire_trace
|
19
|
-
# @attr_reader [Logger,nil] logger
|
20
|
-
# @attr_reader [Boolean] ssl_verify_peer
|
21
|
-
# @attr_reader [String,nil] ssl_ca_bundle
|
22
|
-
# @attr_reader [String,nil] ssl_ca_directory
|
23
|
-
# @attr_reader [String,nil] ssl_ca_store
|
24
13
|
class ConnectionPool
|
25
14
|
|
26
15
|
@pools_mutex = Mutex.new
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aws-sdk-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Amazon Web Services
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06-
|
11
|
+
date: 2016-06-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jmespath
|
@@ -261,6 +261,7 @@ files:
|
|
261
261
|
- lib/aws-sdk-core/client_waiters.rb
|
262
262
|
- lib/aws-sdk-core/cloudformation.rb
|
263
263
|
- lib/aws-sdk-core/cloudfront.rb
|
264
|
+
- lib/aws-sdk-core/cloudfront/url_signer.rb
|
264
265
|
- lib/aws-sdk-core/cloudhsm.rb
|
265
266
|
- lib/aws-sdk-core/cloudsearch.rb
|
266
267
|
- lib/aws-sdk-core/cloudsearchdomain.rb
|