cloudfront-signer 2.1.1 → 2.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog.markdown +2 -0
- data/lib/cloudfront-signer.rb +14 -8
- data/lib/cloudfront-signer/version.rb +1 -1
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39a04cdad6eadba7f441fb8cfba1c643b3f5fe9b
|
4
|
+
data.tar.gz: 7786c9d47b121178a26e832b129b9a163e299bf5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39a5a4e824e33d04b5b5d19726f2a935e0b51d3202ed9819900cf9ff952b6e1eea17a335a355d5990a0048e1c2f203684a5033d38abe1d381b36d86e62c62a14
|
7
|
+
data.tar.gz: 03a54b2be4915bb859b96c5ffba4fb15d5c845a8c0fef62f70e81dc6566e73b4d4c3653d31906599100f5a78829694dee2e2f98a4ae42b505a822dc7a18f000f
|
data/ChangeLog.markdown
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
### 2.1.2 / 2015-04-16
|
2
|
+
* Accepted merge request from https://github.com/tuvistavie - fixing custom policy bug.
|
1
3
|
### 2.1.1 / 2013-10-31
|
2
4
|
* Added changelog file
|
3
5
|
* 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
@@ -4,6 +4,7 @@ require 'openssl'
|
|
4
4
|
require 'time'
|
5
5
|
require 'base64'
|
6
6
|
require "cloudfront-signer/version"
|
7
|
+
require 'json'
|
7
8
|
|
8
9
|
module AWS
|
9
10
|
module CF
|
@@ -176,9 +177,10 @@ module AWS
|
|
176
177
|
policy = IO.read(policy_options[:policy_file])
|
177
178
|
result = "#{subject}#{separator}Policy=#{encode_policy(policy)}&Signature=#{create_signature(policy)}&Key-Pair-Id=#{@key_pair_id}"
|
178
179
|
else
|
180
|
+
policy_options[:expires] = epoch_time(policy_options[:expires] || Time.now + default_expires)
|
179
181
|
if policy_options.keys.size <= 1
|
180
182
|
# Canned Policy - shorter URL
|
181
|
-
expires_at =
|
183
|
+
expires_at = policy_options[:expires]
|
182
184
|
policy = %({"Statement":[{"Resource":"#{subject}","Condition":{"DateLessThan":{"AWS:EpochTime":#{expires_at}}}}]})
|
183
185
|
result = "#{subject}#{separator}Expires=#{expires_at}&Signature=#{create_signature(policy)}&Key-Pair-Id=#{@key_pair_id}"
|
184
186
|
else
|
@@ -196,23 +198,27 @@ module AWS
|
|
196
198
|
end
|
197
199
|
end
|
198
200
|
|
199
|
-
|
200
201
|
# Private helper methods
|
201
202
|
private
|
202
203
|
|
203
|
-
|
204
204
|
def self.generate_custom_policy(resource, options)
|
205
|
-
conditions =
|
206
|
-
conditions
|
207
|
-
conditions
|
208
|
-
|
205
|
+
conditions = { 'DateLessThan' => { 'AWS:EpochTime' => epoch_time(options[:expires]) } }
|
206
|
+
conditions['DateGreaterThan'] = { 'AWS:EpochTime' => epoch_time(options[:starting]) } if options[:starting]
|
207
|
+
conditions['IpAddress'] = { 'AWS:SourceIp' => option[:ip_range] } if options[:ip_range]
|
208
|
+
{
|
209
|
+
'Statement' => [{
|
210
|
+
'Resource' => resource,
|
211
|
+
'Condition' => conditions
|
212
|
+
}]
|
213
|
+
}.to_json
|
209
214
|
end
|
210
215
|
|
211
216
|
def self.epoch_time(timelike)
|
212
217
|
case timelike
|
213
218
|
when String then Time.parse(timelike).to_i
|
214
219
|
when Time then timelike.to_i
|
215
|
-
|
220
|
+
when Fixnum then timelike
|
221
|
+
else raise ArgumentError.new("Invalid argument - String, Fixnum or Time required - #{timelike.class} passed.")
|
216
222
|
end
|
217
223
|
end
|
218
224
|
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloudfront-signer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anthony Bouch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-04-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
description: A gem to sign url and stream paths for Amazon CloudFront private content.
|
@@ -33,8 +33,8 @@ executables: []
|
|
33
33
|
extensions: []
|
34
34
|
extra_rdoc_files: []
|
35
35
|
files:
|
36
|
-
- .gitignore
|
37
|
-
- .rspec
|
36
|
+
- ".gitignore"
|
37
|
+
- ".rspec"
|
38
38
|
- ChangeLog.markdown
|
39
39
|
- Gemfile
|
40
40
|
- LICENSE
|
@@ -58,17 +58,17 @@ require_paths:
|
|
58
58
|
- lib
|
59
59
|
required_ruby_version: !ruby/object:Gem::Requirement
|
60
60
|
requirements:
|
61
|
-
- -
|
61
|
+
- - ">="
|
62
62
|
- !ruby/object:Gem::Version
|
63
63
|
version: '0'
|
64
64
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
requirements: []
|
70
70
|
rubyforge_project: cloudfront-signer
|
71
|
-
rubygems_version: 2.
|
71
|
+
rubygems_version: 2.2.2
|
72
72
|
signing_key:
|
73
73
|
specification_version: 4
|
74
74
|
summary: A gem to sign url and stream paths for Amazon CloudFront private content.
|