cloudfront-signer 2.1.2 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog.markdown +4 -0
- data/lib/cloudfront-signer.rb +23 -13
- data/lib/cloudfront-signer/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d944157441307ac5089ebdebf6cb792ae146de9
|
4
|
+
data.tar.gz: c1e333b58d90f8d3538a50daa6dc7d812b92e53c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc3ca840dd7ba3894e4dbb265b3ccc0dd2412397dbfd4887d09112c06b4985679c9f8607b5d67a21df72b7e0f4278d4daec8561aa9835a4c220012232326b152
|
7
|
+
data.tar.gz: 9888e0ce34a7892461721a68f61aa4480b93ac3ea9f7deb33fb146274508d5578313e1e4f2b9bb27d43896749f38a2ed3e0a91b8d8f13cb88c42ebfae0ffc51e
|
data/ChangeLog.markdown
CHANGED
@@ -1,5 +1,9 @@
|
|
1
|
+
### 2.2.0 / 2015-04-29
|
2
|
+
* Accepted merge request from https://github.com/leonelgalan - `sign_params` method returns raw params to be used in urls or cookies.
|
3
|
+
|
1
4
|
### 2.1.2 / 2015-04-16
|
2
5
|
* Accepted merge request from https://github.com/tuvistavie - fixing custom policy bug.
|
6
|
+
|
3
7
|
### 2.1.1 / 2013-10-31
|
4
8
|
* Added changelog file
|
5
9
|
* Aceppted merge request from https://github.com/bullfight, Refactored configuration to allow for key to be passed in directly.
|
data/lib/cloudfront-signer.rb
CHANGED
@@ -157,15 +157,11 @@ module AWS
|
|
157
157
|
self.sign(subject, {:remove_spaces => false, :html_escape => true}, policy_options)
|
158
158
|
end
|
159
159
|
|
160
|
-
|
161
|
-
# Public: Sign a subject url or stream resource name with optional configuration and
|
160
|
+
# Public: Builds a signed url or stream resource name with optional configuration and
|
162
161
|
# policy options
|
163
162
|
#
|
164
163
|
# Returns a String
|
165
164
|
def self.sign(subject, configuration_options = {}, policy_options = {})
|
166
|
-
|
167
|
-
raise "Configure using AWS::CF::Signer.configure before signing." unless self.is_configured?
|
168
|
-
|
169
165
|
# If the url or stream path already has a query string parameter - append to that.
|
170
166
|
separator = subject =~ /\?/ ? '&' : '?'
|
171
167
|
|
@@ -173,29 +169,43 @@ module AWS
|
|
173
169
|
subject.gsub!(/\s/, "%20")
|
174
170
|
end
|
175
171
|
|
172
|
+
result = subject + separator + self.signed_params(subject, policy_options).collect{ |k,v| "#{k}=#{v}" }.join('&')
|
173
|
+
|
174
|
+
if configuration_options[:html_escape]
|
175
|
+
return html_encode(result)
|
176
|
+
else
|
177
|
+
return result
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
# Public: Sign a subject url or stream resource name with optional policy options.
|
182
|
+
# It returns raw params to be used in urls or cookies
|
183
|
+
#
|
184
|
+
# Returns a Hash
|
185
|
+
def self.signed_params(subject, policy_options = {})
|
186
|
+
result = {}
|
187
|
+
|
176
188
|
if policy_options[:policy_file]
|
177
189
|
policy = IO.read(policy_options[:policy_file])
|
178
|
-
result =
|
190
|
+
result['Policy'] = encode_policy(policy)
|
179
191
|
else
|
180
192
|
policy_options[:expires] = epoch_time(policy_options[:expires] || Time.now + default_expires)
|
193
|
+
|
181
194
|
if policy_options.keys.size <= 1
|
182
195
|
# Canned Policy - shorter URL
|
183
196
|
expires_at = policy_options[:expires]
|
184
197
|
policy = %({"Statement":[{"Resource":"#{subject}","Condition":{"DateLessThan":{"AWS:EpochTime":#{expires_at}}}}]})
|
185
|
-
result =
|
198
|
+
result['Expires'] = expires_at
|
186
199
|
else
|
187
200
|
# Custom Policy
|
188
201
|
resource = policy_options[:resource] || subject
|
189
202
|
policy = generate_custom_policy(resource, policy_options)
|
190
|
-
result =
|
203
|
+
result['Policy'] = encode_policy(policy)
|
191
204
|
end
|
192
205
|
end
|
193
206
|
|
194
|
-
|
195
|
-
|
196
|
-
else
|
197
|
-
return result
|
198
|
-
end
|
207
|
+
result.merge 'Signature' => create_signature(policy),
|
208
|
+
'Key-Pair-Id' => @key_pair_id
|
199
209
|
end
|
200
210
|
|
201
211
|
# Private helper methods
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloudfront-signer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anthony Bouch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|