signet 0.12.0 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +66 -37
- data/README.md +10 -8
- data/Rakefile +24 -3
- data/lib/signet.rb +4 -7
- data/lib/signet/oauth_1.rb +11 -21
- data/lib/signet/oauth_1/client.rb +50 -71
- data/lib/signet/oauth_1/credential.rb +2 -10
- data/lib/signet/oauth_1/server.rb +5 -27
- data/lib/signet/oauth_1/signature_methods/rsa_sha1.rb +1 -1
- data/lib/signet/oauth_2.rb +9 -13
- data/lib/signet/oauth_2/client.rb +38 -46
- data/lib/signet/version.rb +1 -1
- data/signet.gemspec +8 -7
- data/spec/signet/oauth_1_spec.rb +26 -0
- data/spec/signet/oauth_2/client_spec.rb +40 -0
- metadata +20 -15
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9d6cce64f05742592f4945a2a394ab1fc239107e9c5d8145f38a4189689e46ea
|
|
4
|
+
data.tar.gz: a20b6a81fac21113e804c8cbac63db3464da5357aa7428bc17509212217e50a3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b1f2c4ab3031aa346f118bc152f129559436f92ae8b3d0008f3a2efa51fb82e0e45fec0f999c6984772be58661c90f6fbe1a1c973cf6ccdec8329696da4e1101
|
|
7
|
+
data.tar.gz: fc909052f1a89ec0f79d9b9a36ca7196cef5be879595e8c1e7699050ced959b3062881e1418fc9b8258985819f3c2bb64e7e9f60008f25e5ddccb6375934c2f5
|
data/CHANGELOG.md
CHANGED
|
@@ -1,38 +1,67 @@
|
|
|
1
|
-
|
|
1
|
+
# Release History
|
|
2
|
+
|
|
3
|
+
## [0.15.0](https://www.github.com/googleapis/signet/compare/v0.14.1...v0.15.0) (2021-03-04)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* Drop support for Ruby 2.4 and add support for Ruby 3.0 ([bd6fe87](https://www.github.com/googleapis/signet/commit/bd6fe87948f8fc7702720dae651e82f4fd348b5d))
|
|
9
|
+
|
|
10
|
+
## 0.14.1 / 2021-01-27
|
|
11
|
+
|
|
12
|
+
* Fix OAuth1 signature with duplicate query param names
|
|
13
|
+
|
|
14
|
+
## 0.14.0 / 2020-03-31
|
|
15
|
+
|
|
16
|
+
* Support for fetching ID tokens from google oauth2 endpoint.
|
|
17
|
+
|
|
18
|
+
## 0.13.2 / 2020-03-25
|
|
19
|
+
|
|
20
|
+
Rerelease of 0.13.1.
|
|
21
|
+
|
|
22
|
+
## 0.13.1 / 2020-03-24
|
|
23
|
+
|
|
24
|
+
* Update github url
|
|
25
|
+
|
|
26
|
+
## 0.13.0 / 2020-02-24
|
|
27
|
+
|
|
28
|
+
* Support Faraday 1.x
|
|
29
|
+
|
|
30
|
+
## 0.12.0 / 2019-10-08
|
|
2
31
|
|
|
3
32
|
* This version now requires Ruby 2.4.
|
|
4
33
|
* Support array values of the "aud" field.
|
|
5
34
|
* Normalize the version constant to match related gems.
|
|
6
35
|
|
|
7
|
-
|
|
36
|
+
## 0.11.0 / 2018-10-08
|
|
8
37
|
|
|
9
38
|
* Add constant time comparison for oauth signatures.
|
|
10
39
|
|
|
11
|
-
|
|
40
|
+
## 0.10.0 / 2018-09-21
|
|
12
41
|
|
|
13
42
|
* Add UnexpectedStatusError class for http status errors that are not handled.
|
|
14
43
|
|
|
15
|
-
|
|
44
|
+
## 0.9.2 / 2018-09-12
|
|
16
45
|
|
|
17
46
|
* Update issued_at correctly when it is set simultaneously with expires_in.
|
|
18
47
|
|
|
19
|
-
|
|
48
|
+
## 0.9.1 / 2018-08-29
|
|
20
49
|
|
|
21
50
|
* Warn on EOL ruby versions.
|
|
22
51
|
* Fix DateTime normalization.
|
|
23
52
|
|
|
24
|
-
|
|
53
|
+
## 0.9.0 / 2018-08-20
|
|
25
54
|
|
|
26
55
|
* Add RemoteServerError class for 5xx level errors.
|
|
27
56
|
* Allow to_json to be called with arguments
|
|
28
57
|
* Expires_in now sets and reflects current expires_at value
|
|
29
58
|
* Expires_within(0) now returns false when expires_at is nil.
|
|
30
59
|
|
|
31
|
-
|
|
60
|
+
## 0.8.1 / 2017-10-13
|
|
32
61
|
|
|
33
62
|
* Restore support for Ruby 1.9.3
|
|
34
63
|
|
|
35
|
-
|
|
64
|
+
## 0.8.0 / 2017-10-12
|
|
36
65
|
|
|
37
66
|
* Ensure the "expires_at" attribute is recalculated on refresh (chutzimir)
|
|
38
67
|
* Fix warnings on Ruby 2.4 (koic)
|
|
@@ -40,20 +69,20 @@
|
|
|
40
69
|
* Provide signature verification algorithm for compatibility with ruby-jwt 2.0 (jurriaan)
|
|
41
70
|
* Signet::OAuth2::Client#decoded_id_token can take a keyfinder block (mvastola)
|
|
42
71
|
|
|
43
|
-
|
|
72
|
+
## 0.7.3 / 2016-06-20
|
|
44
73
|
|
|
45
74
|
* Fix timestamp parsing on 32-bit systems
|
|
46
75
|
* Fix expiration check when issue/expiry times are nil
|
|
47
76
|
|
|
48
|
-
|
|
77
|
+
## 0.7.2 / 2015-12-21
|
|
49
78
|
|
|
50
79
|
* Don't assume Faraday form encoding middleware is present
|
|
51
80
|
|
|
52
|
-
|
|
81
|
+
## 0.7.1 / 2015-12-17
|
|
53
82
|
|
|
54
83
|
* Fix an issue with date parsing
|
|
55
84
|
|
|
56
|
-
|
|
85
|
+
## 0.7 / 2015-12-06
|
|
57
86
|
|
|
58
87
|
* No longer overwrite SSL environment variables.
|
|
59
88
|
* Tighten up date & URL (de)serialization for OAuth2 client
|
|
@@ -62,7 +91,7 @@
|
|
|
62
91
|
* Add expires_within(sec) method to oauth2 client to facilitate proactive
|
|
63
92
|
refreshes
|
|
64
93
|
|
|
65
|
-
|
|
94
|
+
## 0.6.1 / 2015-06-08
|
|
66
95
|
|
|
67
96
|
* Fix language warnings for unused & shadowed variables ((@blowmage)[])
|
|
68
97
|
* Update SSL cert path for OSX ((@gambaroff)[])
|
|
@@ -70,14 +99,14 @@
|
|
|
70
99
|
* Fix incorrect parameter name in OAuth2 client docs ((@samuelreh)[])
|
|
71
100
|
* Fix symbolization of URL parameter keys ((@swifthand)[])
|
|
72
101
|
|
|
73
|
-
|
|
102
|
+
## 0.6.0 / 2014-12-05
|
|
74
103
|
|
|
75
104
|
* Drop support for ruby versions < 1.9.3
|
|
76
105
|
* Update gem dependencies and lock down versions tighter
|
|
77
106
|
* Allow form encoded responses when exchanging OAuth 2 authorization codes
|
|
78
107
|
* Normalize options keys for indifferent access
|
|
79
108
|
|
|
80
|
-
|
|
109
|
+
## 0.5.1 / 2014-06-08
|
|
81
110
|
|
|
82
111
|
* Allow Hash objects to be used to initialize authorization URI
|
|
83
112
|
* Added PLAINTEXT and RSA-SHA1 signature methods to OAuth 1 support
|
|
@@ -85,53 +114,53 @@
|
|
|
85
114
|
* The `approval_prompt` option no longer defaults to `:force`
|
|
86
115
|
* The `approval_prompt` and `prompt` are now mutually exclusive.
|
|
87
116
|
|
|
88
|
-
|
|
117
|
+
## 0.5.0 / 2013-05-31
|
|
89
118
|
|
|
90
119
|
* Switched to faraday 0.9.0
|
|
91
120
|
* Added `expires_at` option
|
|
92
121
|
|
|
93
|
-
|
|
122
|
+
## 0.4.5
|
|
94
123
|
|
|
95
124
|
* Minor documentation fixes
|
|
96
125
|
* Allow postmessage as a valid redirect_uri in OAuth 2
|
|
97
126
|
|
|
98
|
-
|
|
127
|
+
## 0.4.4
|
|
99
128
|
|
|
100
129
|
* Add support for assertion profile
|
|
101
130
|
|
|
102
|
-
|
|
131
|
+
## 0.4.3
|
|
103
132
|
|
|
104
133
|
* Added method to clear credentials
|
|
105
134
|
|
|
106
|
-
|
|
135
|
+
## 0.4.2
|
|
107
136
|
|
|
108
137
|
* Backwards compatibility for MultiJson
|
|
109
138
|
|
|
110
|
-
|
|
139
|
+
## 0.4.1
|
|
111
140
|
|
|
112
141
|
* Updated Launchy dependency
|
|
113
142
|
|
|
114
|
-
|
|
143
|
+
## 0.4.0
|
|
115
144
|
|
|
116
145
|
* Added OAuth 1 server implementation
|
|
117
146
|
* Updated Faraday dependency
|
|
118
147
|
|
|
119
|
-
|
|
148
|
+
## 0.3.4
|
|
120
149
|
|
|
121
150
|
* Attempts to auto-detect CA cert location
|
|
122
151
|
|
|
123
|
-
|
|
152
|
+
## 0.3.3
|
|
124
153
|
|
|
125
154
|
* Request objects no longer recreated during processing
|
|
126
155
|
* Faraday middleware now supported
|
|
127
156
|
* Streamed requests now supported
|
|
128
157
|
* Fixed assertion profiles; client ID/secret omission no longer an error
|
|
129
158
|
|
|
130
|
-
|
|
159
|
+
## 0.3.2
|
|
131
160
|
|
|
132
161
|
* Added audience security check for ID tokens
|
|
133
162
|
|
|
134
|
-
|
|
163
|
+
## 0.3.1
|
|
135
164
|
|
|
136
165
|
* Fixed a warning while determining grant type
|
|
137
166
|
* Removed requirement that a connection be supplied when authorizing requests
|
|
@@ -139,52 +168,52 @@
|
|
|
139
168
|
* Fixed some documentation stuff around markdown formatting
|
|
140
169
|
* Added support for Google Code wiki format output when generating docs
|
|
141
170
|
|
|
142
|
-
|
|
171
|
+
## 0.3.0
|
|
143
172
|
|
|
144
173
|
* Replaced httpadapter gem dependency with faraday
|
|
145
174
|
* Replaced json gem dependency with multi_json
|
|
146
175
|
* Updated to OAuth 2.0 draft 22
|
|
147
176
|
* Complete test coverage
|
|
148
177
|
|
|
149
|
-
|
|
178
|
+
## 0.2.4
|
|
150
179
|
|
|
151
180
|
* Updated to incorporate changes to the Google OAuth endpoints
|
|
152
181
|
|
|
153
|
-
|
|
182
|
+
## 0.2.3
|
|
154
183
|
|
|
155
184
|
* Added support for JWT-formatted ID tokens.
|
|
156
185
|
* Added :issued_at option to #update_token! method.
|
|
157
186
|
|
|
158
|
-
|
|
187
|
+
## 0.2.2
|
|
159
188
|
|
|
160
189
|
* Lowered requirements for json gem
|
|
161
190
|
|
|
162
|
-
|
|
191
|
+
## 0.2.1
|
|
163
192
|
|
|
164
193
|
* Updated to keep in sync with the new httpadapter changes
|
|
165
194
|
|
|
166
|
-
|
|
195
|
+
## 0.2.0
|
|
167
196
|
|
|
168
197
|
* Added support for OAuth 2.0 draft 10
|
|
169
198
|
|
|
170
|
-
|
|
199
|
+
## 0.1.4
|
|
171
200
|
|
|
172
201
|
* Added support for a two-legged authorization flow
|
|
173
202
|
|
|
174
|
-
|
|
203
|
+
## 0.1.3
|
|
175
204
|
|
|
176
205
|
* Fixed issue with headers passed in as a Hash
|
|
177
206
|
* Fixed incompatibilities with Ruby 1.8.6
|
|
178
207
|
|
|
179
|
-
|
|
208
|
+
## 0.1.2
|
|
180
209
|
|
|
181
210
|
* Fixed bug with overzealous normalization
|
|
182
211
|
|
|
183
|
-
|
|
212
|
+
## 0.1.1
|
|
184
213
|
|
|
185
214
|
* Fixed bug with missing StringIO require
|
|
186
215
|
* Fixed issue with dependency on unreleased features of addressable
|
|
187
216
|
|
|
188
|
-
|
|
217
|
+
## 0.1.0
|
|
189
218
|
|
|
190
219
|
* Initial release
|
data/README.md
CHANGED
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
</dl>
|
|
9
9
|
|
|
10
10
|
[](https://badge.fury.io/rb/signet)
|
|
11
|
-
[](http://travis-ci.org/google/signet)
|
|
12
11
|
|
|
13
12
|
## Description
|
|
14
13
|
|
|
@@ -32,8 +31,8 @@ require 'signet/oauth_2/client'
|
|
|
32
31
|
client = Signet::OAuth2::Client.new(
|
|
33
32
|
:authorization_uri => 'https://accounts.google.com/o/oauth2/auth',
|
|
34
33
|
:token_credential_uri => 'https://oauth2.googleapis.com/token',
|
|
35
|
-
:client_id =>
|
|
36
|
-
:client_secret =>
|
|
34
|
+
:client_id => "#{YOUR_CLIENT_ID}.apps.googleusercontent.com",
|
|
35
|
+
:client_secret => YOUR_CLIENT_SECRET,
|
|
37
36
|
:scope => 'email profile',
|
|
38
37
|
:redirect_uri => 'https://example.client.com/oauth'
|
|
39
38
|
)
|
|
@@ -60,8 +59,11 @@ Be sure `https://rubygems.org` is in your gem sources.
|
|
|
60
59
|
|
|
61
60
|
## Supported Ruby Versions
|
|
62
61
|
|
|
63
|
-
This library
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
62
|
+
This library is supported on Ruby 2.5+.
|
|
63
|
+
|
|
64
|
+
Google provides official support for Ruby versions that are actively supported
|
|
65
|
+
by Ruby Core—that is, Ruby versions that are either in normal maintenance or in
|
|
66
|
+
security maintenance, and not end of life. Currently, this means Ruby 2.5 and
|
|
67
|
+
later. Older versions of Ruby _may_ still work, but are unsupported and not
|
|
68
|
+
recommended. See https://www.ruby-lang.org/en/downloads/branches/ for details
|
|
69
|
+
about the Ruby support schedule.
|
data/Rakefile
CHANGED
|
@@ -8,7 +8,7 @@ task :release_gem, :tag do |_t, args|
|
|
|
8
8
|
raise "You must provide a tag to release." if tag.nil?
|
|
9
9
|
|
|
10
10
|
# Verify the tag format "vVERSION"
|
|
11
|
-
m = tag.match
|
|
11
|
+
m = tag.match /v(?<version>\S*)/
|
|
12
12
|
raise "Tag #{tag} does not match the expected format." if m.nil?
|
|
13
13
|
|
|
14
14
|
version = m[:version]
|
|
@@ -30,16 +30,23 @@ task :release_gem, :tag do |_t, args|
|
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
path_to_be_pushed = "pkg/signet-#{version}.gem"
|
|
33
|
+
gem_was_published = nil
|
|
33
34
|
if File.file? path_to_be_pushed
|
|
34
35
|
begin
|
|
35
|
-
::Gems.push File.new(path_to_be_pushed)
|
|
36
|
+
response = ::Gems.push File.new(path_to_be_pushed)
|
|
37
|
+
puts response
|
|
38
|
+
raise unless response.include? "Successfully registered gem:"
|
|
39
|
+
gem_was_published = true
|
|
36
40
|
puts "Successfully built and pushed signet for version #{version}"
|
|
37
41
|
rescue StandardError => e
|
|
42
|
+
gem_was_published = false
|
|
38
43
|
puts "Error while releasing signet version #{version}: #{e.message}"
|
|
39
44
|
end
|
|
40
45
|
else
|
|
41
46
|
raise "Cannot build signet for version #{version}"
|
|
42
47
|
end
|
|
48
|
+
|
|
49
|
+
Rake::Task["kokoro:publish_docs"].invoke if gem_was_published
|
|
43
50
|
end
|
|
44
51
|
|
|
45
52
|
task :ci do
|
|
@@ -77,7 +84,21 @@ namespace :kokoro do
|
|
|
77
84
|
.first.split("(").last.split(")").first || "0.1.0"
|
|
78
85
|
end
|
|
79
86
|
Rake::Task["kokoro:load_env_vars"].invoke
|
|
80
|
-
Rake::Task["release_gem"].invoke "
|
|
87
|
+
Rake::Task["release_gem"].invoke "v#{version}"
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
task :post do
|
|
91
|
+
require_relative "rakelib/link_checker.rb"
|
|
92
|
+
|
|
93
|
+
link_checker = LinkChecker.new
|
|
94
|
+
link_checker.run
|
|
95
|
+
exit link_checker.exit_status
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
task :publish_docs do
|
|
99
|
+
require_relative "rakelib/devsite_builder.rb"
|
|
100
|
+
|
|
101
|
+
DevsiteBuilder.new(__dir__).publish
|
|
81
102
|
end
|
|
82
103
|
end
|
|
83
104
|
|
data/lib/signet.rb
CHANGED
|
@@ -15,8 +15,6 @@
|
|
|
15
15
|
require "signet/version"
|
|
16
16
|
|
|
17
17
|
module Signet #:nodoc:
|
|
18
|
-
# rubocop:disable Metrics/AbcSize
|
|
19
|
-
# rubocop:disable Metrics/MethodLength
|
|
20
18
|
def self.parse_auth_param_list auth_param_string
|
|
21
19
|
# Production rules from:
|
|
22
20
|
# http://tools.ietf.org/html/draft-ietf-httpbis-p1-messaging-12
|
|
@@ -54,11 +52,12 @@ module Signet #:nodoc:
|
|
|
54
52
|
# Now parse the auth-param pair strings & turn them into key-value pairs.
|
|
55
53
|
(auth_param_pairs.each_with_object [] do |pair, accu|
|
|
56
54
|
name, value = pair.split "=", 2
|
|
57
|
-
|
|
55
|
+
case value
|
|
56
|
+
when /^".*"$/
|
|
58
57
|
value = value.gsub(/^"(.*)"$/, '\1').gsub(/\\(.)/, '\1')
|
|
59
|
-
|
|
58
|
+
when /^'.*'$/
|
|
60
59
|
value = value.gsub(/^'(.*)'$/, '\1').gsub(/\\(.)/, '\1')
|
|
61
|
-
|
|
60
|
+
when %r{[()<>@,;:\\"/\[\]?={}]}
|
|
62
61
|
# Certain special characters are not allowed
|
|
63
62
|
raise ParseError,
|
|
64
63
|
"Unexpected characters in auth param " \
|
|
@@ -68,6 +67,4 @@ module Signet #:nodoc:
|
|
|
68
67
|
accu << [name, value]
|
|
69
68
|
end)
|
|
70
69
|
end
|
|
71
|
-
# rubocop:enable Metrics/AbcSize
|
|
72
|
-
# rubocop:enable Metrics/MethodLength
|
|
73
70
|
end
|
data/lib/signet/oauth_1.rb
CHANGED
|
@@ -49,9 +49,8 @@ module Signet #:nodoc:
|
|
|
49
49
|
#
|
|
50
50
|
# @return [String] A random nonce.
|
|
51
51
|
def self.generate_nonce
|
|
52
|
-
SecureRandom.random_bytes(16).unpack("H*").join
|
|
52
|
+
SecureRandom.random_bytes(16).unpack("H*").join
|
|
53
53
|
end
|
|
54
|
-
# rubocop:disable Metrics/MethodLength
|
|
55
54
|
|
|
56
55
|
##
|
|
57
56
|
# Processes an options <code>Hash</code> to find a credential key value.
|
|
@@ -65,7 +64,7 @@ module Signet #:nodoc:
|
|
|
65
64
|
# @return [String] The credential key value.
|
|
66
65
|
def self.extract_credential_key_option credential_type, options
|
|
67
66
|
# Normalize key to String to allow indifferent access.
|
|
68
|
-
options = options.
|
|
67
|
+
options = options.to_h.transform_keys(&:to_s)
|
|
69
68
|
credential_key = "#{credential_type}_credential_key"
|
|
70
69
|
credential = "#{credential_type}_credential"
|
|
71
70
|
if options[credential_key]
|
|
@@ -107,7 +106,7 @@ module Signet #:nodoc:
|
|
|
107
106
|
# @return [String] The credential secret value.
|
|
108
107
|
def self.extract_credential_secret_option credential_type, options
|
|
109
108
|
# Normalize key to String to allow indifferent access.
|
|
110
|
-
options = options.
|
|
109
|
+
options = options.to_h.transform_keys(&:to_s)
|
|
111
110
|
credential_secret = "#{credential_type}_credential_secret"
|
|
112
111
|
credential = "#{credential_type}_credential"
|
|
113
112
|
if options[credential_secret]
|
|
@@ -136,7 +135,6 @@ module Signet #:nodoc:
|
|
|
136
135
|
end
|
|
137
136
|
credential_secret
|
|
138
137
|
end
|
|
139
|
-
# rubocop:enable Metrics/MethodLength
|
|
140
138
|
|
|
141
139
|
##
|
|
142
140
|
# Normalizes a set of OAuth parameters according to the algorithm given
|
|
@@ -178,7 +176,7 @@ module Signet #:nodoc:
|
|
|
178
176
|
query: parsed_uri.query,
|
|
179
177
|
fragment: parsed_uri.fragment
|
|
180
178
|
)
|
|
181
|
-
uri_parameters = uri.query_values
|
|
179
|
+
uri_parameters = uri.query_values(Array) || []
|
|
182
180
|
uri = uri.omit(:query, :fragment).to_s
|
|
183
181
|
merged_parameters =
|
|
184
182
|
uri_parameters.concat(parameters.map { |k, v| [k, v] })
|
|
@@ -214,7 +212,7 @@ module Signet #:nodoc:
|
|
|
214
212
|
realm = realm.gsub '"', '\"'
|
|
215
213
|
parameter_list.unshift "realm=\"#{realm}\""
|
|
216
214
|
end
|
|
217
|
-
"OAuth
|
|
215
|
+
"OAuth #{parameter_list.join ', '}"
|
|
218
216
|
end
|
|
219
217
|
|
|
220
218
|
##
|
|
@@ -228,7 +226,7 @@ module Signet #:nodoc:
|
|
|
228
226
|
when /^OAuth$/i
|
|
229
227
|
# Other token types may be supported eventually
|
|
230
228
|
pairs = Signet.parse_auth_param_list(field_value[/^OAuth\s+(.*)$/i, 1])
|
|
231
|
-
|
|
229
|
+
(pairs.each_with_object [] do |(k, v), accu|
|
|
232
230
|
if k != "realm"
|
|
233
231
|
k = unencode k
|
|
234
232
|
v = unencode v
|
|
@@ -274,24 +272,18 @@ module Signet #:nodoc:
|
|
|
274
272
|
# be a temporary credential secret when obtaining a token credential
|
|
275
273
|
# for the first time
|
|
276
274
|
base_string = generate_base_string method, uri, parameters
|
|
277
|
-
parameters = parameters.
|
|
275
|
+
parameters = parameters.to_h.transform_keys(&:to_s)
|
|
278
276
|
signature_method = parameters["oauth_signature_method"]
|
|
279
277
|
case signature_method
|
|
280
278
|
when "HMAC-SHA1"
|
|
281
279
|
require "signet/oauth_1/signature_methods/hmac_sha1"
|
|
282
|
-
|
|
283
|
-
base_string, client_credential_secret, token_credential_secret
|
|
284
|
-
)
|
|
280
|
+
Signet::OAuth1::HMACSHA1.generate_signature base_string, client_credential_secret, token_credential_secret
|
|
285
281
|
when "RSA-SHA1"
|
|
286
282
|
require "signet/oauth_1/signature_methods/rsa_sha1"
|
|
287
|
-
|
|
288
|
-
base_string, client_credential_secret, token_credential_secret
|
|
289
|
-
)
|
|
283
|
+
Signet::OAuth1::RSASHA1.generate_signature base_string, client_credential_secret, token_credential_secret
|
|
290
284
|
when "PLAINTEXT"
|
|
291
285
|
require "signet/oauth_1/signature_methods/plaintext"
|
|
292
|
-
|
|
293
|
-
base_string, client_credential_secret, token_credential_secret
|
|
294
|
-
)
|
|
286
|
+
Signet::OAuth1::PLAINTEXT.generate_signature base_string, client_credential_secret, token_credential_secret
|
|
295
287
|
else
|
|
296
288
|
raise NotImplementedError,
|
|
297
289
|
"Unsupported signature method: #{signature_method}"
|
|
@@ -396,7 +388,7 @@ module Signet #:nodoc:
|
|
|
396
388
|
raise ArgumentError, "Missing :client_credential_key parameter." if client_credential_key.nil?
|
|
397
389
|
raise ArgumentError, "Missing :temporary_credential_key parameter." if temporary_credential_key.nil?
|
|
398
390
|
raise ArgumentError, "Missing :verifier parameter." if options[:verifier].nil?
|
|
399
|
-
|
|
391
|
+
[
|
|
400
392
|
["oauth_consumer_key", client_credential_key],
|
|
401
393
|
["oauth_token", temporary_credential_key],
|
|
402
394
|
["oauth_signature_method", options[:signature_method]],
|
|
@@ -405,8 +397,6 @@ module Signet #:nodoc:
|
|
|
405
397
|
["oauth_verifier", options[:verifier]],
|
|
406
398
|
["oauth_version", "1.0"]
|
|
407
399
|
]
|
|
408
|
-
# No additional parameters allowed here
|
|
409
|
-
parameters
|
|
410
400
|
end
|
|
411
401
|
|
|
412
402
|
##
|