File: README.md

package info (click to toggle)
ruby-faraday-middleware-aws-sigv4 1.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 124 kB
  • sloc: ruby: 65; makefile: 4
file content (84 lines) | stat: -rw-r--r-- 2,642 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# FaradayMiddleware::AwsSigV4

[Faraday](https://github.com/lostisland/faraday) middleware for AWS Signature Version 4 using [aws-sigv4](https://rubygems.org/gems/aws-sigv4).

[![Gem Version](https://badge.fury.io/rb/faraday_middleware-aws-sigv4.svg)](https://badge.fury.io/rb/faraday_middleware-aws-sigv4)
[![Build Status](https://github.com/winebarrel/faraday_middleware-aws-sigv4/workflows/test/badge.svg?branch=master)](https://github.com/winebarrel/faraday_middleware-aws-sigv4/actions)
[![Coverage Status](https://coveralls.io/repos/github/winebarrel/faraday_middleware-aws-sigv4/badge.svg?branch=master)](https://coveralls.io/github/winebarrel/faraday_middleware-aws-sigv4?branch=master)

## Required dependency version

| version    | ruby     | faraday   |
|------------|----------|-----------|
| `>= 1.0.0` | `>= 2.5` | `>= 2.0`  |
| `>= 0.6.0` | `>= 2.4` | `>= 1.8`  |
| `>= 0.5.0` | `>= 2.4` | `>= 0.15` |
| `>= 0.3.0` | `>= 2.3` | `>= 0.15` |
| `< 0.3.0`  | -        | `< 0.15`  |

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'faraday_middleware-aws-sigv4'
```

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install faraday_middleware-aws-sigv4

## Usage

```ruby
require 'faraday_middleware/aws_sigv4'
require 'pp'

conn = Faraday.new(url: 'https://apigateway.us-east-1.amazonaws.com') do |faraday|
  faraday.request :aws_sigv4,
    service: 'apigateway',
    region: 'us-east-1',
    access_key_id: ENV['AWS_ACCESS_KEY_ID'],
    secret_access_key: ENV['AWS_SECRET_ACCESS_KEY']
  # see http://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/Sigv4/Signer.html

  faraday.response :json, content_type: /\bjson\b/

  # NOTE: If you need to send case sensitive headers like `x-amz-access-token` in `SP API`.
  # cf. https://github.com/lostisland/faraday/issues/747#issuecomment-439864181
  faraday.adapter Faraday.default_adapter
end

res = conn.get '/account'

pp res.body
#=> {"_links"=>
#     {"curies"=>
#       {"href"=>
#         "http://docs.aws.amazon.com/apigateway/latest/developerguide/account-apigateway-{rel}.html",
#        "name"=>"account",
#        "templated"=>true},
#      "self"=>{"href"=>"/account"},
#      "account:update"=>{"href"=>"/account"}},
#    "throttleSettings"=>{"rateLimit"=>10000.0, "burstLimit"=>5000}}
```

## Upgrading from `faraday_middleware-aws-signers-v4`

If you previously provided the `service_name` option, you need to rename it `service`

## Test

```sh
bundle install
bundle exec appraisal install
bundle exec appraisal faraday-2.0 rake
```

## Related Links

* http://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/Sigv4/Signer.html