aws4_signer 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 40d14a60591fbacc5974d2146d052a90d6c82e8d
4
- data.tar.gz: ac94c5b92bf12e4617387070a7616d3f6066365a
3
+ metadata.gz: 432614434e71166bf50ad3588c95cdd18fc71c63
4
+ data.tar.gz: a907bf8eb98ffb2218eadb207b57d1760ca5e88f
5
5
  SHA512:
6
- metadata.gz: a975872efa7da0c5c1bd42f25a132c5213a0c10e7f54196158fb9df615a1a2351645942e697bfeb47dd8a8b0b39279acba2a7bb4078ab994668e1627f3e27f18
7
- data.tar.gz: 995dbc0117c08c1d96165eb138637164e3422733d80a0f3ad2f56bc80681bff606f4556fb60786118fcf628cc8cf86ad327f0ab034b77a52fca57267238853a3
6
+ metadata.gz: 9bb2184b312e4f6cbb4112e0114bfdb6a51ff2e8de7378cbf0c81cc57ed29e52ac479eac8af02af34701256687ac98b6460a1c1981046c4ef588f0c61ce8f730
7
+ data.tar.gz: 95cbcdc3f383db2cbb028c68d2e7f9167f6d703efd8846cea658257561f13d9e690fb458c3fb4286ab7996538e2ae274a406539d4f57ff30f81c5cb39347f288
@@ -21,16 +21,17 @@ class Aws4Signer
21
21
  end.join
22
22
  end
23
23
 
24
- def initialize(access_key_id, secret_access_key, region, service)
24
+ def initialize(access_key_id, secret_access_key, region, service, security_token: nil)
25
25
  @access_key_id = access_key_id
26
26
  @secret_access_key = secret_access_key
27
27
  @region = region
28
28
  @service = service
29
+ @security_token = security_token
29
30
  end
30
31
 
31
32
  def sign(verb, uri, headers: {}, body: '')
32
33
  raise ArgumentError, 'URI must provided' unless uri
33
- Signature.new(@access_key_id, @secret_access_key, @region, @service, verb, uri, headers, body)
34
+ Signature.new(@access_key_id, @secret_access_key, @region, @service, verb, uri, headers, body, security_token: @security_token)
34
35
  end
35
36
 
36
37
  def sign_http_request(req, uri = nil)
@@ -1,6 +1,6 @@
1
1
  class Aws4Signer
2
2
  class Signature
3
- def initialize(access_key_id, secret_access_key, region, service, verb, uri, headers, body)
3
+ def initialize(access_key_id, secret_access_key, region, service, verb, uri, headers, body, security_token: nil)
4
4
  @access_key_id = access_key_id
5
5
  @secret_access_key = secret_access_key
6
6
  @region = region
@@ -17,6 +17,7 @@ class Aws4Signer
17
17
  end
18
18
 
19
19
  @headers["x-amz-date"] ||= @headers.delete("X-Amz-Date")
20
+ @headers["x-amz-security-token"] = security_token if security_token
20
21
  unless @headers["x-amz-date"]
21
22
  @date = Time.now.utc
22
23
  @headers["x-amz-date"] = @date.strftime("%Y%m%dT%H%M%SZ")
@@ -1,3 +1,3 @@
1
1
  class Aws4Signer
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -12,6 +12,7 @@ describe Aws4Signer::Signature do
12
12
  {'x-foo' => 'bar'}
13
13
  end
14
14
  let(:body) { 'hello' }
15
+ let(:options) { {} }
15
16
 
16
17
  let(:signature) do
17
18
  Aws4Signer::Signature.new(
@@ -23,6 +24,7 @@ describe Aws4Signer::Signature do
23
24
  uri,
24
25
  headers,
25
26
  body,
27
+ **options
26
28
  )
27
29
  end
28
30
 
@@ -59,6 +61,14 @@ describe Aws4Signer::Signature do
59
61
  assert_equal 'example.com', signature.headers['Host']
60
62
  end
61
63
  end
64
+
65
+ describe "with security token" do
66
+ let(:options) { {security_token: 'session-token'} }
67
+
68
+ it "assigns x-amz-security-token" do
69
+ assert_equal 'session-token', signature.headers['x-amz-security-token']
70
+ end
71
+ end
62
72
  end
63
73
 
64
74
  describe "#attach_to_http_request" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws4_signer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shota Fukumori (sora_h)
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-17 00:00:00.000000000 Z
11
+ date: 2014-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler