faraday_middleware-aws-signers-v4 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.travis.yml +8 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +59 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/faraday_middleware-aws-signers-v4.gemspec +26 -0
- data/lib/faraday_middleware/aws_signers_v4.rb +8 -0
- data/lib/faraday_middleware/aws_signers_v4_ext.rb +9 -0
- data/lib/faraday_middleware/request/aws_signers_v4.rb +55 -0
- metadata +155 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: aafb50aa4390e660b4c1bdceaa59f5d291d0b789
|
4
|
+
data.tar.gz: e4ccc44622ce0380eea0427d25c1dc3630afe354
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a2eb96ebb046c43e1f11d8867eda6e69f4e879597ca4d064c8ae980adc2058ec38e80ff9610cc68d26d32a3f042c4ddd027ab1b973e882b4e0838ec56ef5cfea
|
7
|
+
data.tar.gz: d4a0c50fd088b4635021c46aefab34540033a67a8f3e35e0e38b6c913ebad2dc42289dfc96e3f83221d4460dc6644fefea3dad12c9aed6fab1517577e5ff95c2
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Genki Sugawara
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# FaradayMiddleware::AwsSignersV4
|
2
|
+
|
3
|
+
Faraday middleware for Signature Version 4.
|
4
|
+
|
5
|
+
[![Build Status](https://travis-ci.org/winebarrel/faraday_middleware-aws-signers-v4.svg)](https://travis-ci.org/winebarrel/faraday_middleware-aws-signers-v4)
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'faraday_middleware-aws-signers-v4'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install faraday_middleware-aws-signers-v4
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
require 'faraday_middleware'
|
27
|
+
require 'faraday_middleware/aws_signers_v4'
|
28
|
+
require 'pp'
|
29
|
+
|
30
|
+
conn = Faraday.new(:url => 'https://apigateway.us-east-1.amazonaws.com') do |faraday|
|
31
|
+
faraday.request :aws_signers_v4,
|
32
|
+
credentials: Aws::Credentials.new(ENV['AWS_ACCESS_KEY_ID'], ENV['AWS_SECRET_ACCESS_KEY']),
|
33
|
+
service_name: 'apigateway',
|
34
|
+
region: 'us-east-1'
|
35
|
+
|
36
|
+
faraday.response :json, :content_type => /\bjson$/
|
37
|
+
faraday.response :raise_error
|
38
|
+
|
39
|
+
faraday.adapter Faraday.default_adapter
|
40
|
+
end
|
41
|
+
|
42
|
+
res = conn.get '/account'
|
43
|
+
pp res.body
|
44
|
+
# => {"accountUpdate"=>
|
45
|
+
# {"name"=>nil,
|
46
|
+
# "template"=>false,
|
47
|
+
# "templateSkipList"=>nil,
|
48
|
+
# "title"=>nil,
|
49
|
+
# "updateAccountInput"=>nil},
|
50
|
+
# "cloudwatchRoleArn"=>nil,
|
51
|
+
# "self"=>
|
52
|
+
# {"__type"=>
|
53
|
+
# "GetAccountRequest:http://internal.amazon.com/coral/com.amazonaws.backplane.controlplane/",
|
54
|
+
# "name"=>nil,
|
55
|
+
# "template"=>false,
|
56
|
+
# "templateSkipList"=>nil,
|
57
|
+
# "title"=>nil},
|
58
|
+
# "throttleSettings"=>{"burstLimit"=>1000, "rateLimit"=>500.0}}
|
59
|
+
```
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "faraday_middleware/aws_signers_v4"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
Gem::Specification.new do |spec|
|
3
|
+
spec.name = 'faraday_middleware-aws-signers-v4'
|
4
|
+
spec.version = '0.1.0'
|
5
|
+
spec.authors = ['Genki Sugawara']
|
6
|
+
spec.email = ['sgwr_dts@yahoo.co.jp']
|
7
|
+
|
8
|
+
spec.summary = %q{Faraday middleware for Signature Version 4.}
|
9
|
+
spec.description = %q{Faraday middleware for Signature Version 4.}
|
10
|
+
spec.homepage = 'https://github.com/winebarrel/faraday_middleware-aws-signers-v4'
|
11
|
+
spec.license = 'MIT'
|
12
|
+
|
13
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
14
|
+
spec.bindir = 'exe'
|
15
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
16
|
+
spec.require_paths = ['lib']
|
17
|
+
|
18
|
+
spec.add_dependency 'faraday', '~> 0.9'
|
19
|
+
spec.add_dependency 'aws-sdk', '~> 2.1'
|
20
|
+
|
21
|
+
spec.add_development_dependency 'bundler'
|
22
|
+
spec.add_development_dependency 'rake'
|
23
|
+
spec.add_development_dependency 'rspec', '>= 3.0.0'
|
24
|
+
spec.add_development_dependency 'timecop'
|
25
|
+
spec.add_development_dependency 'faraday_middleware'
|
26
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'faraday_middleware/aws_signers_v4_ext'
|
2
|
+
|
3
|
+
class FaradayMiddleware::AwsSignersV4 < Faraday::Middleware
|
4
|
+
class Request
|
5
|
+
def initialize(env)
|
6
|
+
@env = env
|
7
|
+
end
|
8
|
+
|
9
|
+
def headers
|
10
|
+
@env.request_headers
|
11
|
+
end
|
12
|
+
|
13
|
+
def body
|
14
|
+
@env.body || ''
|
15
|
+
end
|
16
|
+
|
17
|
+
def endpoint
|
18
|
+
@env.url
|
19
|
+
end
|
20
|
+
|
21
|
+
def http_method
|
22
|
+
@env.method.to_s.upcase
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def initialize(app, options = nil)
|
27
|
+
super(app)
|
28
|
+
|
29
|
+
credentials = options.fetch(:credentials)
|
30
|
+
service_name = options.fetch(:service_name)
|
31
|
+
region = options.fetch(:region)
|
32
|
+
@signer = Aws::Signers::V4.new(credentials, service_name, region)
|
33
|
+
|
34
|
+
@net_http = app.is_a?(Faraday::Adapter::NetHttp)
|
35
|
+
end
|
36
|
+
|
37
|
+
def call(env)
|
38
|
+
normalize_for_net_http!(env)
|
39
|
+
req = Request.new(env)
|
40
|
+
@signer.sign(req)
|
41
|
+
@app.call(env)
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def normalize_for_net_http!(env)
|
47
|
+
return unless @net_http
|
48
|
+
|
49
|
+
if Net::HTTP::HAVE_ZLIB
|
50
|
+
env.request_headers['Accept-Encoding'] ||= 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3'
|
51
|
+
end
|
52
|
+
|
53
|
+
env.request_headers['Accept'] ||= '*/*'
|
54
|
+
end
|
55
|
+
end
|
metadata
ADDED
@@ -0,0 +1,155 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: faraday_middleware-aws-signers-v4
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Genki Sugawara
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-07-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.9'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.9'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: aws-sdk
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.1'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 3.0.0
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 3.0.0
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: timecop
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: faraday_middleware
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: Faraday middleware for Signature Version 4.
|
112
|
+
email:
|
113
|
+
- sgwr_dts@yahoo.co.jp
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- .gitignore
|
119
|
+
- .rspec
|
120
|
+
- .travis.yml
|
121
|
+
- Gemfile
|
122
|
+
- LICENSE.txt
|
123
|
+
- README.md
|
124
|
+
- Rakefile
|
125
|
+
- bin/console
|
126
|
+
- bin/setup
|
127
|
+
- faraday_middleware-aws-signers-v4.gemspec
|
128
|
+
- lib/faraday_middleware/aws_signers_v4.rb
|
129
|
+
- lib/faraday_middleware/aws_signers_v4_ext.rb
|
130
|
+
- lib/faraday_middleware/request/aws_signers_v4.rb
|
131
|
+
homepage: https://github.com/winebarrel/faraday_middleware-aws-signers-v4
|
132
|
+
licenses:
|
133
|
+
- MIT
|
134
|
+
metadata: {}
|
135
|
+
post_install_message:
|
136
|
+
rdoc_options: []
|
137
|
+
require_paths:
|
138
|
+
- lib
|
139
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
140
|
+
requirements:
|
141
|
+
- - '>='
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '0'
|
144
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
145
|
+
requirements:
|
146
|
+
- - '>='
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: '0'
|
149
|
+
requirements: []
|
150
|
+
rubyforge_project:
|
151
|
+
rubygems_version: 2.0.14
|
152
|
+
signing_key:
|
153
|
+
specification_version: 4
|
154
|
+
summary: Faraday middleware for Signature Version 4.
|
155
|
+
test_files: []
|