New upstream version 12.3.8

This commit is contained in:
Pirate Praveen 2019-12-05 21:41:47 +05:30
parent 860976d237
commit 1d92d9db41
15 changed files with 275 additions and 0 deletions

View file

@ -0,0 +1,10 @@
/.bundle/
/.yardoc
/Gemfile.lock
/_yardoc/
/coverage/
/doc/
/pkg/
/spec/reports/
/tmp/
test.rb

View file

@ -0,0 +1,2 @@
--color
--require spec_helper

View file

@ -0,0 +1,12 @@
sudo: false
cache: bundler
language: ruby
rvm:
- 2.0.0
- 2.1.10
- 2.2.6
- 2.3.3
- 2.4.0
script:
- bundle install
- bundle exec rake

View file

@ -0,0 +1,4 @@
source 'https://rubygems.org'
# Specify your gem's dependencies in faraday_middleware-aws-signers-v4.gemspec
gemspec

View file

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2015 Genki Sugawara
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View file

@ -0,0 +1,67 @@
# FaradayMiddleware::AwsSignersV4
[Faraday](https://github.com/lostisland/faraday) middleware for AWS Signature Version 4.
[![Gem Version](https://badge.fury.io/rb/faraday_middleware-aws-signers-v4.svg)](http://badge.fury.io/rb/faraday_middleware-aws-signers-v4)
[![Build Status](https://travis-ci.org/winebarrel/faraday_middleware-aws-signers-v4.svg)](https://travis-ci.org/winebarrel/faraday_middleware-aws-signers-v4)
[![Coverage Status](https://coveralls.io/repos/winebarrel/faraday_middleware-aws-signers-v4/badge.svg?branch=master&service=github)](https://coveralls.io/github/winebarrel/faraday_middleware-aws-signers-v4?branch=master)
**Currently developing new gem to support aws-sdk-v3.**
**see https://github.com/winebarrel/faraday_middleware-aws-sigv4**
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'faraday_middleware-aws-signers-v4'
```
And then execute:
$ bundle
Or install it yourself as:
$ gem install faraday_middleware-aws-signers-v4
## Usage
```ruby
require 'faraday_middleware'
require 'faraday_middleware/aws_signers_v4'
require 'pp'
conn = Faraday.new(url: 'https://apigateway.us-east-1.amazonaws.com') do |faraday|
faraday.request :aws_signers_v4,
credentials: Aws::Credentials.new(ENV['AWS_ACCESS_KEY_ID'], ENV['AWS_SECRET_ACCESS_KEY']),
# If you use the credentials file:
#credentials: Aws::SharedCredentials.new.credentials,
service_name: 'apigateway',
region: 'us-east-1'
faraday.response :json, :content_type => /\bjson\b/
faraday.response :raise_error
faraday.adapter Faraday.default_adapter
end
res = conn.get '/account'
pp res.body
# => {"accountUpdate"=>
# {"name"=>nil,
# "template"=>false,
# "templateSkipList"=>nil,
# "title"=>nil,
# "updateAccountInput"=>nil},
# "cloudwatchRoleArn"=>nil,
# "self"=>
# {"__type"=>
# "GetAccountRequest:http://internal.amazon.com/coral/com.amazonaws.backplane.controlplane/",
# "name"=>nil,
# "template"=>false,
# "templateSkipList"=>nil,
# "title"=>nil},
# "throttleSettings"=>{"burstLimit"=>1000, "rateLimit"=>500.0}}
```

View file

@ -0,0 +1,6 @@
require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
task :default => :spec

View file

@ -0,0 +1,14 @@
#!/usr/bin/env ruby
require "bundler/setup"
require "faraday_middleware/aws_signers_v4"
# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.
# (If you use this, don't forget to add pry to your Gemfile!)
# require "pry"
# Pry.start
require "irb"
IRB.start

View file

@ -0,0 +1,7 @@
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
bundle install
# Do any other automated setup that you need to do here

View file

@ -0,0 +1,28 @@
# coding: utf-8
Gem::Specification.new do |spec|
spec.name = 'faraday_middleware-aws-signers-v4'
spec.version = '0.1.9'
spec.authors = ['Genki Sugawara']
spec.email = ['sgwr_dts@yahoo.co.jp']
spec.summary = %q{Faraday middleware for AWS Signature Version 4.}
spec.description = %q{Faraday middleware for AWS Signature Version 4.}
spec.homepage = 'https://github.com/winebarrel/faraday_middleware-aws-signers-v4'
spec.license = 'MIT'
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
spec.bindir = 'exe'
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ['lib']
spec.add_dependency 'faraday', '~> 0.9'
spec.add_dependency 'aws-sdk-resources', '>= 2', '< 3'
spec.add_development_dependency 'bundler'
spec.add_development_dependency 'rake'
spec.add_development_dependency 'rspec', '>= 3.0.0'
spec.add_development_dependency 'timecop'
spec.add_development_dependency 'faraday_middleware'
spec.add_development_dependency 'coveralls'
spec.add_development_dependency 'webmock'
end

View file

@ -0,0 +1 @@
require 'faraday_middleware/aws_signers_v4'

View file

@ -0,0 +1,8 @@
require 'aws-sdk-resources'
require 'faraday'
module FaradayMiddleware
autoload :AwsSignersV4, 'faraday_middleware/request/aws_signers_v4'
Faraday::Request.register_middleware :aws_signers_v4 => lambda { AwsSignersV4 }
end

View file

@ -0,0 +1,13 @@
require 'aws-sdk-core/signers/v4'
module AwsSignersV4Ext
def signed_headers(request)
super.downcase
end
end
class Aws::Signers::V4
unless Aws::Signers::V4 < AwsSignersV4Ext
prepend AwsSignersV4Ext
end
end

View file

@ -0,0 +1,25 @@
require 'uri'
require 'aws-sdk-resources'
module URI
def self.seahorse_encode_www_form(params)
params.map {|key, value|
encoded_key = encode_www_form_component(key)
if value.nil?
encoded_key
elsif value.respond_to?(:to_ary)
value.to_ary.map {|v|
if v.nil?
# bug?
#encoded_key
else
encoded_key + '=' + Seahorse::Util.uri_escape(v)
end
}.join('&')
else
encoded_key + '=' + Seahorse::Util.uri_escape(value)
end
}.join('&')
end
end

View file

@ -0,0 +1,57 @@
require 'faraday_middleware/ext/uri_ext'
require 'faraday_middleware/aws_signers_v4_ext'
class FaradayMiddleware::AwsSignersV4 < Faraday::Middleware
class Request
def initialize(env)
@env = env
end
def headers
@env.request_headers
end
def body
@env.body || ''
end
def endpoint
url = @env.url.dup
# Escape the query string or the request won't sign correctly
if url and url.query
re_escape_query!(url)
end
url
end
def http_method
@env.method.to_s.upcase
end
private
def re_escape_query!(url)
params = URI.decode_www_form(url.query)
if params.any? {|k, v| v =~ / / }
url.query = URI.seahorse_encode_www_form(params)
end
end
end # of class Request
def initialize(app, options = nil)
super(app)
@credentials = options.fetch(:credentials)
@service_name = options.fetch(:service_name)
@region = options.fetch(:region)
end
def call(env)
req = Request.new(env)
Aws::Signers::V4.new(@credentials, @service_name, @region).sign(req)
@app.call(env)
end
end