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.
@@ -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
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ test.rb
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ - 2.1.5
5
+ - 2.2.1
6
+ script:
7
+ - bundle install
8
+ - bundle exec rake
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in faraday_middleware-aws-signers-v4.gemspec
4
+ gemspec
@@ -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.
@@ -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
+ ```
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -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
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -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,8 @@
1
+ require 'aws-sdk'
2
+ require 'faraday'
3
+
4
+ module FaradayMiddleware
5
+ autoload :AwsSignersV4, 'faraday_middleware/request/aws_signers_v4'
6
+
7
+ Faraday::Request.register_middleware :aws_signers_v4 => lambda { AwsSignersV4 }
8
+ end
@@ -0,0 +1,9 @@
1
+ require 'aws-sdk-core/signers/v4'
2
+
3
+ class Aws::Signers::V4
4
+ alias signed_headers_orig signed_headers
5
+
6
+ def signed_headers(request)
7
+ signed_headers_orig(request).downcase
8
+ end
9
+ 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: []