signet 0.13.2 → 0.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +11 -0
- data/CHANGELOG.md +70 -40
- data/CODE_OF_CONDUCT.md +43 -0
- data/README.md +10 -7
- data/SECURITY.md +7 -0
- data/lib/signet/oauth_1/client.rb +50 -71
- data/lib/signet/oauth_1/credential.rb +3 -11
- data/lib/signet/oauth_1/server.rb +5 -27
- data/lib/signet/oauth_1/signature_methods/hmac_sha1.rb +1 -1
- data/lib/signet/oauth_1/signature_methods/plaintext.rb +1 -1
- data/lib/signet/oauth_1/signature_methods/rsa_sha1.rb +2 -2
- data/lib/signet/oauth_1.rb +12 -22
- data/lib/signet/oauth_2/client.rb +55 -58
- data/lib/signet/oauth_2.rb +10 -14
- data/lib/signet/version.rb +1 -1
- data/lib/signet.rb +5 -8
- metadata +27 -27
- data/Gemfile +0 -8
- data/Rakefile +0 -112
- data/signet.gemspec +0 -44
- data/spec/signet/oauth_1/client_spec.rb +0 -810
- data/spec/signet/oauth_1/credential_spec.rb +0 -169
- data/spec/signet/oauth_1/server_spec.rb +0 -839
- data/spec/signet/oauth_1/signature_methods/hmac_sha1_spec.rb +0 -61
- data/spec/signet/oauth_1/signature_methods/plaintext_spec.rb +0 -61
- data/spec/signet/oauth_1/signature_methods/rsa_sha1_spec.rb +0 -126
- data/spec/signet/oauth_1_spec.rb +0 -1010
- data/spec/signet/oauth_2/client_spec.rb +0 -1214
- data/spec/signet/oauth_2_spec.rb +0 -194
- data/spec/signet_spec.rb +0 -78
- data/spec/spec.opts +0 -2
- data/spec/spec_helper.rb +0 -10
- data/spec/spec_helper_spec.rb +0 -17
- data/website/index.html +0 -95
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7bc1d85dc2f8c727e54436bb38a284576cb81ea5ee0b0af58860678cb069bde9
|
4
|
+
data.tar.gz: e0b149f3ee841fe5f30af08a2d0e6cebbfbc173d1370d4e4a8fc3b2109fa54a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ef091d389b3ac52e87dba96f8647a072acf11a346244600bca551b23ead3c24bb73d75209af7c79c261769d5589053c84a3bb837fb57f2b063e19d3516d0ad4
|
7
|
+
data.tar.gz: d8a38134dd48453e0e976639b7ded1838ee363ab3b27917847f27e8de98adcb9f60f28359a90459a75537a03595417bd7275e4b3f291019cb13ea4eb09383495
|
data/.yardopts
ADDED
data/CHANGELOG.md
CHANGED
@@ -1,50 +1,80 @@
|
|
1
|
-
|
1
|
+
# Release History
|
2
|
+
|
3
|
+
## [0.16.0](https://www.github.com/googleapis/signet/compare/signet/v0.15.0...signet/v0.16.0) (2021-09-03)
|
4
|
+
|
5
|
+
|
6
|
+
### Features
|
7
|
+
|
8
|
+
* Support for fetching an access token with basic auth ([3c43e32](https://www.github.com/googleapis/signet/commit/3c43e3201d79b1e2303e672f3c07e060c5079423))
|
9
|
+
|
10
|
+
|
11
|
+
### Bug Fixes
|
12
|
+
|
13
|
+
* Remove extraneous files from the gem ([e515bb6](https://www.github.com/googleapis/signet/commit/e515bb627a64e32ec885412fed8b01eb73067ee0))
|
14
|
+
* Require addressable 2.8 to remediate vulnerability ([9a2f899](https://www.github.com/googleapis/signet/commit/9a2f8996f522538c4bb7998535e2a50331d564fc))
|
15
|
+
|
16
|
+
## [0.15.0](https://www.github.com/googleapis/signet/compare/v0.14.1...v0.15.0) (2021-03-04)
|
17
|
+
|
18
|
+
|
19
|
+
### Features
|
20
|
+
|
21
|
+
* Drop support for Ruby 2.4 and add support for Ruby 3.0 ([bd6fe87](https://www.github.com/googleapis/signet/commit/bd6fe87948f8fc7702720dae651e82f4fd348b5d))
|
22
|
+
|
23
|
+
## 0.14.1 / 2021-01-27
|
24
|
+
|
25
|
+
* Fix OAuth1 signature with duplicate query param names
|
26
|
+
|
27
|
+
## 0.14.0 / 2020-03-31
|
28
|
+
|
29
|
+
* Support for fetching ID tokens from google oauth2 endpoint.
|
30
|
+
|
31
|
+
## 0.13.2 / 2020-03-25
|
2
32
|
|
3
33
|
Rerelease of 0.13.1.
|
4
34
|
|
5
|
-
|
35
|
+
## 0.13.1 / 2020-03-24
|
6
36
|
|
7
37
|
* Update github url
|
8
38
|
|
9
|
-
|
39
|
+
## 0.13.0 / 2020-02-24
|
10
40
|
|
11
41
|
* Support Faraday 1.x
|
12
42
|
|
13
|
-
|
43
|
+
## 0.12.0 / 2019-10-08
|
14
44
|
|
15
45
|
* This version now requires Ruby 2.4.
|
16
46
|
* Support array values of the "aud" field.
|
17
47
|
* Normalize the version constant to match related gems.
|
18
48
|
|
19
|
-
|
49
|
+
## 0.11.0 / 2018-10-08
|
20
50
|
|
21
51
|
* Add constant time comparison for oauth signatures.
|
22
52
|
|
23
|
-
|
53
|
+
## 0.10.0 / 2018-09-21
|
24
54
|
|
25
55
|
* Add UnexpectedStatusError class for http status errors that are not handled.
|
26
56
|
|
27
|
-
|
57
|
+
## 0.9.2 / 2018-09-12
|
28
58
|
|
29
59
|
* Update issued_at correctly when it is set simultaneously with expires_in.
|
30
60
|
|
31
|
-
|
61
|
+
## 0.9.1 / 2018-08-29
|
32
62
|
|
33
63
|
* Warn on EOL ruby versions.
|
34
64
|
* Fix DateTime normalization.
|
35
65
|
|
36
|
-
|
66
|
+
## 0.9.0 / 2018-08-20
|
37
67
|
|
38
68
|
* Add RemoteServerError class for 5xx level errors.
|
39
69
|
* Allow to_json to be called with arguments
|
40
70
|
* Expires_in now sets and reflects current expires_at value
|
41
71
|
* Expires_within(0) now returns false when expires_at is nil.
|
42
72
|
|
43
|
-
|
73
|
+
## 0.8.1 / 2017-10-13
|
44
74
|
|
45
75
|
* Restore support for Ruby 1.9.3
|
46
76
|
|
47
|
-
|
77
|
+
## 0.8.0 / 2017-10-12
|
48
78
|
|
49
79
|
* Ensure the "expires_at" attribute is recalculated on refresh (chutzimir)
|
50
80
|
* Fix warnings on Ruby 2.4 (koic)
|
@@ -52,20 +82,20 @@ Rerelease of 0.13.1.
|
|
52
82
|
* Provide signature verification algorithm for compatibility with ruby-jwt 2.0 (jurriaan)
|
53
83
|
* Signet::OAuth2::Client#decoded_id_token can take a keyfinder block (mvastola)
|
54
84
|
|
55
|
-
|
85
|
+
## 0.7.3 / 2016-06-20
|
56
86
|
|
57
87
|
* Fix timestamp parsing on 32-bit systems
|
58
88
|
* Fix expiration check when issue/expiry times are nil
|
59
89
|
|
60
|
-
|
90
|
+
## 0.7.2 / 2015-12-21
|
61
91
|
|
62
92
|
* Don't assume Faraday form encoding middleware is present
|
63
93
|
|
64
|
-
|
94
|
+
## 0.7.1 / 2015-12-17
|
65
95
|
|
66
96
|
* Fix an issue with date parsing
|
67
97
|
|
68
|
-
|
98
|
+
## 0.7 / 2015-12-06
|
69
99
|
|
70
100
|
* No longer overwrite SSL environment variables.
|
71
101
|
* Tighten up date & URL (de)serialization for OAuth2 client
|
@@ -74,7 +104,7 @@ Rerelease of 0.13.1.
|
|
74
104
|
* Add expires_within(sec) method to oauth2 client to facilitate proactive
|
75
105
|
refreshes
|
76
106
|
|
77
|
-
|
107
|
+
## 0.6.1 / 2015-06-08
|
78
108
|
|
79
109
|
* Fix language warnings for unused & shadowed variables ((@blowmage)[])
|
80
110
|
* Update SSL cert path for OSX ((@gambaroff)[])
|
@@ -82,14 +112,14 @@ Rerelease of 0.13.1.
|
|
82
112
|
* Fix incorrect parameter name in OAuth2 client docs ((@samuelreh)[])
|
83
113
|
* Fix symbolization of URL parameter keys ((@swifthand)[])
|
84
114
|
|
85
|
-
|
115
|
+
## 0.6.0 / 2014-12-05
|
86
116
|
|
87
117
|
* Drop support for ruby versions < 1.9.3
|
88
118
|
* Update gem dependencies and lock down versions tighter
|
89
119
|
* Allow form encoded responses when exchanging OAuth 2 authorization codes
|
90
120
|
* Normalize options keys for indifferent access
|
91
121
|
|
92
|
-
|
122
|
+
## 0.5.1 / 2014-06-08
|
93
123
|
|
94
124
|
* Allow Hash objects to be used to initialize authorization URI
|
95
125
|
* Added PLAINTEXT and RSA-SHA1 signature methods to OAuth 1 support
|
@@ -97,53 +127,53 @@ Rerelease of 0.13.1.
|
|
97
127
|
* The `approval_prompt` option no longer defaults to `:force`
|
98
128
|
* The `approval_prompt` and `prompt` are now mutually exclusive.
|
99
129
|
|
100
|
-
|
130
|
+
## 0.5.0 / 2013-05-31
|
101
131
|
|
102
132
|
* Switched to faraday 0.9.0
|
103
133
|
* Added `expires_at` option
|
104
134
|
|
105
|
-
|
135
|
+
## 0.4.5
|
106
136
|
|
107
137
|
* Minor documentation fixes
|
108
138
|
* Allow postmessage as a valid redirect_uri in OAuth 2
|
109
139
|
|
110
|
-
|
140
|
+
## 0.4.4
|
111
141
|
|
112
142
|
* Add support for assertion profile
|
113
143
|
|
114
|
-
|
144
|
+
## 0.4.3
|
115
145
|
|
116
146
|
* Added method to clear credentials
|
117
147
|
|
118
|
-
|
148
|
+
## 0.4.2
|
119
149
|
|
120
150
|
* Backwards compatibility for MultiJson
|
121
151
|
|
122
|
-
|
152
|
+
## 0.4.1
|
123
153
|
|
124
154
|
* Updated Launchy dependency
|
125
155
|
|
126
|
-
|
156
|
+
## 0.4.0
|
127
157
|
|
128
158
|
* Added OAuth 1 server implementation
|
129
159
|
* Updated Faraday dependency
|
130
160
|
|
131
|
-
|
161
|
+
## 0.3.4
|
132
162
|
|
133
163
|
* Attempts to auto-detect CA cert location
|
134
164
|
|
135
|
-
|
165
|
+
## 0.3.3
|
136
166
|
|
137
167
|
* Request objects no longer recreated during processing
|
138
168
|
* Faraday middleware now supported
|
139
169
|
* Streamed requests now supported
|
140
170
|
* Fixed assertion profiles; client ID/secret omission no longer an error
|
141
171
|
|
142
|
-
|
172
|
+
## 0.3.2
|
143
173
|
|
144
174
|
* Added audience security check for ID tokens
|
145
175
|
|
146
|
-
|
176
|
+
## 0.3.1
|
147
177
|
|
148
178
|
* Fixed a warning while determining grant type
|
149
179
|
* Removed requirement that a connection be supplied when authorizing requests
|
@@ -151,52 +181,52 @@ Rerelease of 0.13.1.
|
|
151
181
|
* Fixed some documentation stuff around markdown formatting
|
152
182
|
* Added support for Google Code wiki format output when generating docs
|
153
183
|
|
154
|
-
|
184
|
+
## 0.3.0
|
155
185
|
|
156
186
|
* Replaced httpadapter gem dependency with faraday
|
157
187
|
* Replaced json gem dependency with multi_json
|
158
188
|
* Updated to OAuth 2.0 draft 22
|
159
189
|
* Complete test coverage
|
160
190
|
|
161
|
-
|
191
|
+
## 0.2.4
|
162
192
|
|
163
193
|
* Updated to incorporate changes to the Google OAuth endpoints
|
164
194
|
|
165
|
-
|
195
|
+
## 0.2.3
|
166
196
|
|
167
197
|
* Added support for JWT-formatted ID tokens.
|
168
198
|
* Added :issued_at option to #update_token! method.
|
169
199
|
|
170
|
-
|
200
|
+
## 0.2.2
|
171
201
|
|
172
202
|
* Lowered requirements for json gem
|
173
203
|
|
174
|
-
|
204
|
+
## 0.2.1
|
175
205
|
|
176
206
|
* Updated to keep in sync with the new httpadapter changes
|
177
207
|
|
178
|
-
|
208
|
+
## 0.2.0
|
179
209
|
|
180
210
|
* Added support for OAuth 2.0 draft 10
|
181
211
|
|
182
|
-
|
212
|
+
## 0.1.4
|
183
213
|
|
184
214
|
* Added support for a two-legged authorization flow
|
185
215
|
|
186
|
-
|
216
|
+
## 0.1.3
|
187
217
|
|
188
218
|
* Fixed issue with headers passed in as a Hash
|
189
219
|
* Fixed incompatibilities with Ruby 1.8.6
|
190
220
|
|
191
|
-
|
221
|
+
## 0.1.2
|
192
222
|
|
193
223
|
* Fixed bug with overzealous normalization
|
194
224
|
|
195
|
-
|
225
|
+
## 0.1.1
|
196
226
|
|
197
227
|
* Fixed bug with missing StringIO require
|
198
228
|
* Fixed issue with dependency on unreleased features of addressable
|
199
229
|
|
200
|
-
|
230
|
+
## 0.1.0
|
201
231
|
|
202
232
|
* Initial release
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project,
|
4
|
+
and in the interest of fostering an open and welcoming community,
|
5
|
+
we pledge to respect all people who contribute through reporting issues,
|
6
|
+
posting feature requests, updating documentation,
|
7
|
+
submitting pull requests or patches, and other activities.
|
8
|
+
|
9
|
+
We are committed to making participation in this project
|
10
|
+
a harassment-free experience for everyone,
|
11
|
+
regardless of level of experience, gender, gender identity and expression,
|
12
|
+
sexual orientation, disability, personal appearance,
|
13
|
+
body size, race, ethnicity, age, religion, or nationality.
|
14
|
+
|
15
|
+
Examples of unacceptable behavior by participants include:
|
16
|
+
|
17
|
+
* The use of sexualized language or imagery
|
18
|
+
* Personal attacks
|
19
|
+
* Trolling or insulting/derogatory comments
|
20
|
+
* Public or private harassment
|
21
|
+
* Publishing other's private information,
|
22
|
+
such as physical or electronic
|
23
|
+
addresses, without explicit permission
|
24
|
+
* Other unethical or unprofessional conduct.
|
25
|
+
|
26
|
+
Project maintainers have the right and responsibility to remove, edit, or reject
|
27
|
+
comments, commits, code, wiki edits, issues, and other contributions
|
28
|
+
that are not aligned to this Code of Conduct.
|
29
|
+
By adopting this Code of Conduct,
|
30
|
+
project maintainers commit themselves to fairly and consistently
|
31
|
+
applying these principles to every aspect of managing this project.
|
32
|
+
Project maintainers who do not follow or enforce the Code of Conduct
|
33
|
+
may be permanently removed from the project team.
|
34
|
+
|
35
|
+
This code of conduct applies both within project spaces and in public spaces
|
36
|
+
when an individual is representing the project or its community.
|
37
|
+
|
38
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior
|
39
|
+
may be reported by opening an issue
|
40
|
+
or contacting one or more of the project maintainers.
|
41
|
+
|
42
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.2.0,
|
43
|
+
available at [http://contributor-covenant.org/version/1/2/0/](http://contributor-covenant.org/version/1/2/0/)
|
data/README.md
CHANGED
@@ -31,8 +31,8 @@ require 'signet/oauth_2/client'
|
|
31
31
|
client = Signet::OAuth2::Client.new(
|
32
32
|
:authorization_uri => 'https://accounts.google.com/o/oauth2/auth',
|
33
33
|
:token_credential_uri => 'https://oauth2.googleapis.com/token',
|
34
|
-
:client_id =>
|
35
|
-
:client_secret =>
|
34
|
+
:client_id => "#{YOUR_CLIENT_ID}.apps.googleusercontent.com",
|
35
|
+
:client_secret => YOUR_CLIENT_SECRET,
|
36
36
|
:scope => 'email profile',
|
37
37
|
:redirect_uri => 'https://example.client.com/oauth'
|
38
38
|
)
|
@@ -59,8 +59,11 @@ Be sure `https://rubygems.org` is in your gem sources.
|
|
59
59
|
|
60
60
|
## Supported Ruby Versions
|
61
61
|
|
62
|
-
This library
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
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/SECURITY.md
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
# Security Policy
|
2
|
+
|
3
|
+
To report a security issue, please use [g.co/vulnz](https://g.co/vulnz).
|
4
|
+
|
5
|
+
The Google Security Team will respond within 5 working days of your report on g.co/vulnz.
|
6
|
+
|
7
|
+
We use g.co/vulnz for our intake, and do coordination and disclosure here using GitHub Security Advisory to privately discuss and fix the issue.
|
@@ -89,7 +89,7 @@ module Signet
|
|
89
89
|
# @see Signet::OAuth1::Client#initialize
|
90
90
|
def update! options = {}
|
91
91
|
# Normalize key to String to allow indifferent access.
|
92
|
-
options = options.
|
92
|
+
options = options.to_h.transform_keys(&:to_s)
|
93
93
|
self.temporary_credential_uri = options["temporary_credential_uri"]
|
94
94
|
self.authorization_uri = options["authorization_uri"]
|
95
95
|
self.token_credential_uri = options["token_credential_uri"]
|
@@ -128,12 +128,12 @@ module Signet
|
|
128
128
|
# new_temporary_credential_uri
|
129
129
|
# The temporary credentials URI.
|
130
130
|
def temporary_credential_uri= new_temporary_credential_uri
|
131
|
-
if
|
131
|
+
if new_temporary_credential_uri.nil?
|
132
|
+
@temporary_credential_uri = nil
|
133
|
+
else
|
132
134
|
new_temporary_credential_uri =
|
133
135
|
Addressable::URI.parse new_temporary_credential_uri
|
134
136
|
@temporary_credential_uri = new_temporary_credential_uri
|
135
|
-
else
|
136
|
-
@temporary_credential_uri = nil
|
137
137
|
end
|
138
138
|
end
|
139
139
|
alias request_token_uri= temporary_credential_uri=
|
@@ -163,14 +163,14 @@ module Signet
|
|
163
163
|
# @param [Addressable::URI, String, #to_str] new_authorization_uri
|
164
164
|
# The authorization URI.
|
165
165
|
def authorization_uri= new_authorization_uri
|
166
|
-
if
|
166
|
+
if new_authorization_uri.nil?
|
167
|
+
@authorization_uri = nil
|
168
|
+
else
|
167
169
|
new_authorization_uri = Addressable::URI.send(
|
168
170
|
new_authorization_uri.is_a?(Hash) ? :new : :parse,
|
169
171
|
new_authorization_uri
|
170
172
|
)
|
171
173
|
@authorization_uri = new_authorization_uri
|
172
|
-
else
|
173
|
-
@authorization_uri = nil
|
174
174
|
end
|
175
175
|
end
|
176
176
|
|
@@ -189,14 +189,14 @@ module Signet
|
|
189
189
|
# @param [Addressable::URI, Hash, String, #to_str] new_token_credential_uri
|
190
190
|
# The token credential URI.
|
191
191
|
def token_credential_uri= new_token_credential_uri
|
192
|
-
if
|
192
|
+
if new_token_credential_uri.nil?
|
193
|
+
@token_credential_uri = nil
|
194
|
+
else
|
193
195
|
new_token_credential_uri = Addressable::URI.send(
|
194
196
|
new_token_credential_uri.is_a?(Hash) ? :new : :parse,
|
195
197
|
new_token_credential_uri
|
196
198
|
)
|
197
199
|
@token_credential_uri = new_token_credential_uri
|
198
|
-
else
|
199
|
-
@token_credential_uri = nil
|
200
200
|
end
|
201
201
|
end
|
202
202
|
alias access_token_uri= token_credential_uri=
|
@@ -217,8 +217,7 @@ module Signet
|
|
217
217
|
elsif !client_credential_key && !client_credential_secret
|
218
218
|
nil
|
219
219
|
else
|
220
|
-
raise ArgumentError,
|
221
|
-
"The client credential key and secret must be set."
|
220
|
+
raise ArgumentError, "The client credential key and secret must be set."
|
222
221
|
end
|
223
222
|
end
|
224
223
|
alias consumer_token client_credential
|
@@ -229,7 +228,10 @@ module Signet
|
|
229
228
|
# @param [Signet::OAuth1::Credential] new_client_credential
|
230
229
|
# The client credentials.
|
231
230
|
def client_credential= new_client_credential
|
232
|
-
if
|
231
|
+
if new_client_credential.nil?
|
232
|
+
@client_credential_key = nil
|
233
|
+
@client_credential_secret = nil
|
234
|
+
else
|
233
235
|
unless new_client_credential.is_a? ::Signet::OAuth1::Credential
|
234
236
|
raise TypeError,
|
235
237
|
"Expected Signet::OAuth1::Credential, " \
|
@@ -237,9 +239,6 @@ module Signet
|
|
237
239
|
end
|
238
240
|
@client_credential_key = new_client_credential.key
|
239
241
|
@client_credential_secret = new_client_credential.secret
|
240
|
-
else
|
241
|
-
@client_credential_key = nil
|
242
|
-
@client_credential_secret = nil
|
243
242
|
end
|
244
243
|
end
|
245
244
|
alias consumer_token= client_credential=
|
@@ -259,15 +258,15 @@ module Signet
|
|
259
258
|
# @param [String, #to_str] new_client_credential_key
|
260
259
|
# The client credential key.
|
261
260
|
def client_credential_key= new_client_credential_key
|
262
|
-
if
|
261
|
+
if new_client_credential_key.nil?
|
262
|
+
@client_credential_key = nil
|
263
|
+
else
|
263
264
|
unless new_client_credential_key.respond_to? :to_str
|
264
265
|
raise TypeError,
|
265
266
|
"Can't convert #{new_client_credential_key.class} into String."
|
266
267
|
end
|
267
268
|
new_client_credential_key = new_client_credential_key.to_str
|
268
269
|
@client_credential_key = new_client_credential_key
|
269
|
-
else
|
270
|
-
@client_credential_key = nil
|
271
270
|
end
|
272
271
|
end
|
273
272
|
alias consumer_key= client_credential_key=
|
@@ -287,7 +286,9 @@ module Signet
|
|
287
286
|
# @param [String, #to_str] new_client_credential_secret
|
288
287
|
# The client credential secret.
|
289
288
|
def client_credential_secret= new_client_credential_secret
|
290
|
-
if
|
289
|
+
if new_client_credential_secret.nil?
|
290
|
+
@client_credential_secret = nil
|
291
|
+
else
|
291
292
|
unless new_client_credential_secret.respond_to? :to_str
|
292
293
|
raise TypeError,
|
293
294
|
"Can't convert #{new_client_credential_secret.class} " \
|
@@ -295,8 +296,6 @@ module Signet
|
|
295
296
|
end
|
296
297
|
new_client_credential_secret = new_client_credential_secret.to_str
|
297
298
|
@client_credential_secret = new_client_credential_secret
|
298
|
-
else
|
299
|
-
@client_credential_secret = nil
|
300
299
|
end
|
301
300
|
end
|
302
301
|
alias consumer_secret= client_credential_secret=
|
@@ -311,12 +310,10 @@ module Signet
|
|
311
310
|
temporary_credential_key,
|
312
311
|
temporary_credential_secret
|
313
312
|
)
|
314
|
-
elsif !temporary_credential_key &&
|
315
|
-
!temporary_credential_secret
|
313
|
+
elsif !temporary_credential_key && !temporary_credential_secret
|
316
314
|
nil
|
317
315
|
else
|
318
|
-
raise ArgumentError,
|
319
|
-
"The temporary credential key and secret must be set."
|
316
|
+
raise ArgumentError, "The temporary credential key and secret must be set."
|
320
317
|
end
|
321
318
|
end
|
322
319
|
alias request_token temporary_credential
|
@@ -327,7 +324,10 @@ module Signet
|
|
327
324
|
# @param [Signet::OAuth1::Credential] new_temporary_credential
|
328
325
|
# The temporary credentials.
|
329
326
|
def temporary_credential= new_temporary_credential
|
330
|
-
if
|
327
|
+
if new_temporary_credential.nil?
|
328
|
+
@temporary_credential_key = nil
|
329
|
+
@temporary_credential_secret = nil
|
330
|
+
else
|
331
331
|
unless new_temporary_credential.is_a? ::Signet::OAuth1::Credential
|
332
332
|
raise TypeError,
|
333
333
|
"Expected Signet::OAuth1::Credential, " \
|
@@ -335,9 +335,6 @@ module Signet
|
|
335
335
|
end
|
336
336
|
@temporary_credential_key = new_temporary_credential.key
|
337
337
|
@temporary_credential_secret = new_temporary_credential.secret
|
338
|
-
else
|
339
|
-
@temporary_credential_key = nil
|
340
|
-
@temporary_credential_secret = nil
|
341
338
|
end
|
342
339
|
end
|
343
340
|
alias request_token= temporary_credential=
|
@@ -357,7 +354,9 @@ module Signet
|
|
357
354
|
# @param [String, #to_str] new_temporary_credential_key
|
358
355
|
# The temporary credential key.
|
359
356
|
def temporary_credential_key= new_temporary_credential_key
|
360
|
-
if
|
357
|
+
if new_temporary_credential_key.nil?
|
358
|
+
@temporary_credential_key = nil
|
359
|
+
else
|
361
360
|
unless new_temporary_credential_key.respond_to? :to_str
|
362
361
|
raise TypeError,
|
363
362
|
"Can't convert #{new_temporary_credential_key.class} " \
|
@@ -365,8 +364,6 @@ module Signet
|
|
365
364
|
end
|
366
365
|
new_temporary_credential_key = new_temporary_credential_key.to_str
|
367
366
|
@temporary_credential_key = new_temporary_credential_key
|
368
|
-
else
|
369
|
-
@temporary_credential_key = nil
|
370
367
|
end
|
371
368
|
end
|
372
369
|
alias request_token_key= temporary_credential_key=
|
@@ -386,7 +383,9 @@ module Signet
|
|
386
383
|
# @param [String, #to_str] new_temporary_credential_secret
|
387
384
|
# The temporary credential secret.
|
388
385
|
def temporary_credential_secret= new_temporary_credential_secret
|
389
|
-
if
|
386
|
+
if new_temporary_credential_secret.nil?
|
387
|
+
@temporary_credential_secret = nil
|
388
|
+
else
|
390
389
|
unless new_temporary_credential_secret.respond_to? :to_str
|
391
390
|
raise TypeError,
|
392
391
|
"Can't convert #{new_temporary_credential_secret.class} " \
|
@@ -395,8 +394,6 @@ module Signet
|
|
395
394
|
new_temporary_credential_secret =
|
396
395
|
new_temporary_credential_secret.to_str
|
397
396
|
@temporary_credential_secret = new_temporary_credential_secret
|
398
|
-
else
|
399
|
-
@temporary_credential_secret = nil
|
400
397
|
end
|
401
398
|
end
|
402
399
|
alias request_token_secret= temporary_credential_secret=
|
@@ -411,12 +408,10 @@ module Signet
|
|
411
408
|
token_credential_key,
|
412
409
|
token_credential_secret
|
413
410
|
)
|
414
|
-
elsif !token_credential_key &&
|
415
|
-
!token_credential_secret
|
411
|
+
elsif !token_credential_key && !token_credential_secret
|
416
412
|
nil
|
417
413
|
else
|
418
|
-
raise ArgumentError,
|
419
|
-
"The token credential key and secret must be set."
|
414
|
+
raise ArgumentError, "The token credential key and secret must be set."
|
420
415
|
end
|
421
416
|
end
|
422
417
|
alias access_token token_credential
|
@@ -427,7 +422,10 @@ module Signet
|
|
427
422
|
# @param [Signet::OAuth1::Credential] new_token_credential
|
428
423
|
# The token credentials.
|
429
424
|
def token_credential= new_token_credential
|
430
|
-
if
|
425
|
+
if new_token_credential.nil?
|
426
|
+
@token_credential_key = nil
|
427
|
+
@token_credential_secret = nil
|
428
|
+
else
|
431
429
|
unless new_token_credential.is_a? ::Signet::OAuth1::Credential
|
432
430
|
raise TypeError,
|
433
431
|
"Expected Signet::OAuth1::Credential, " \
|
@@ -435,9 +433,6 @@ module Signet
|
|
435
433
|
end
|
436
434
|
@token_credential_key = new_token_credential.key
|
437
435
|
@token_credential_secret = new_token_credential.secret
|
438
|
-
else
|
439
|
-
@token_credential_key = nil
|
440
|
-
@token_credential_secret = nil
|
441
436
|
end
|
442
437
|
end
|
443
438
|
alias access_token= token_credential=
|
@@ -457,7 +452,9 @@ module Signet
|
|
457
452
|
# @param [String, #to_str] new_token_credential_key
|
458
453
|
# The token credential key.
|
459
454
|
def token_credential_key= new_token_credential_key
|
460
|
-
if
|
455
|
+
if new_token_credential_key.nil?
|
456
|
+
@token_credential_key = nil
|
457
|
+
else
|
461
458
|
unless new_token_credential_key.respond_to? :to_str
|
462
459
|
raise TypeError,
|
463
460
|
"Can't convert #{new_token_credential_key.class} " \
|
@@ -465,8 +462,6 @@ module Signet
|
|
465
462
|
end
|
466
463
|
new_token_credential_key = new_token_credential_key.to_str
|
467
464
|
@token_credential_key = new_token_credential_key
|
468
|
-
else
|
469
|
-
@token_credential_key = nil
|
470
465
|
end
|
471
466
|
end
|
472
467
|
alias access_token_key= token_credential_key=
|
@@ -486,7 +481,9 @@ module Signet
|
|
486
481
|
# @param [String, #to_str] new_token_credential_secret
|
487
482
|
# The token credential secret.
|
488
483
|
def token_credential_secret= new_token_credential_secret
|
489
|
-
if
|
484
|
+
if new_token_credential_secret.nil?
|
485
|
+
@token_credential_secret = nil
|
486
|
+
else
|
490
487
|
unless new_token_credential_secret.respond_to? :to_str
|
491
488
|
raise TypeError,
|
492
489
|
"Can't convert #{new_token_credential_secret.class} " \
|
@@ -495,8 +492,6 @@ module Signet
|
|
495
492
|
new_token_credential_secret =
|
496
493
|
new_token_credential_secret.to_str
|
497
494
|
@token_credential_secret = new_token_credential_secret
|
498
|
-
else
|
499
|
-
@token_credential_secret = nil
|
500
495
|
end
|
501
496
|
end
|
502
497
|
alias access_token_secret= token_credential_secret=
|
@@ -515,15 +510,15 @@ module Signet
|
|
515
510
|
# @param [String, #to_str] new_callback
|
516
511
|
# The OAuth callback.
|
517
512
|
def callback= new_callback
|
518
|
-
if
|
513
|
+
if new_callback.nil?
|
514
|
+
@callback = nil
|
515
|
+
else
|
519
516
|
unless new_callback.respond_to? :to_str
|
520
517
|
raise TypeError,
|
521
518
|
"Can't convert #{new_callback.class} into String."
|
522
519
|
end
|
523
520
|
new_callback = new_callback.to_str
|
524
521
|
@callback = new_callback
|
525
|
-
else
|
526
|
-
@callback = nil
|
527
522
|
end
|
528
523
|
end
|
529
524
|
|
@@ -556,7 +551,7 @@ module Signet
|
|
556
551
|
# @note A serialized client contains sensitive information. Persist or transmit with care.
|
557
552
|
#
|
558
553
|
# @return [String] A serialized JSON representation of the client.
|
559
|
-
def to_json
|
554
|
+
def to_json *_args
|
560
555
|
MultiJson.dump(
|
561
556
|
"temporary_credential_uri" => temporary_credential_uri,
|
562
557
|
"authorization_uri" => authorization_uri,
|
@@ -571,8 +566,6 @@ module Signet
|
|
571
566
|
"token_credential_secret" => token_credential_secret
|
572
567
|
)
|
573
568
|
end
|
574
|
-
# rubocop:disable Metrics/AbcSize
|
575
|
-
# rubocop:disable Metrics/MethodLength
|
576
569
|
|
577
570
|
##
|
578
571
|
# Generates a request for temporary credentials.
|
@@ -635,8 +628,6 @@ module Signet
|
|
635
628
|
req.headers = Faraday::Utils::Headers.new headers
|
636
629
|
end
|
637
630
|
end
|
638
|
-
# rubocop:enable Metrics/AbcSize
|
639
|
-
# rubocop:enable Metrics/MethodLength
|
640
631
|
alias generate_request_token_request generate_temporary_credential_request
|
641
632
|
|
642
633
|
##
|
@@ -709,8 +700,6 @@ module Signet
|
|
709
700
|
self.temporary_credential = credential
|
710
701
|
end
|
711
702
|
alias fetch_request_token! fetch_temporary_credential!
|
712
|
-
# rubocop:disable Metrics/AbcSize
|
713
|
-
# rubocop:disable Metrics/MethodLength
|
714
703
|
|
715
704
|
##
|
716
705
|
# Generates a request for token credentials.
|
@@ -776,7 +765,6 @@ module Signet
|
|
776
765
|
req.headers = Faraday::Utils::Headers.new headers
|
777
766
|
end
|
778
767
|
end
|
779
|
-
# rubocop:enable Metrics/MethodLength
|
780
768
|
alias generate_access_token_request generate_token_credential_request
|
781
769
|
|
782
770
|
##
|
@@ -818,7 +806,6 @@ module Signet
|
|
818
806
|
message, request: request, response: response
|
819
807
|
)
|
820
808
|
end
|
821
|
-
# rubocop:enable Metrics/AbcSize
|
822
809
|
alias fetch_access_token fetch_token_credential
|
823
810
|
|
824
811
|
##
|
@@ -846,10 +833,6 @@ module Signet
|
|
846
833
|
self.token_credential = credential
|
847
834
|
end
|
848
835
|
alias fetch_access_token! fetch_token_credential!
|
849
|
-
# rubocop:disable Metrics/AbcSize
|
850
|
-
# rubocop:disable Metrics/CyclomaticComplexity
|
851
|
-
# rubocop:disable Metrics/MethodLength
|
852
|
-
# rubocop:disable Metrics/PerceivedComplexity
|
853
836
|
|
854
837
|
##
|
855
838
|
# Generates an authenticated request for protected resources.
|
@@ -950,7 +933,7 @@ module Signet
|
|
950
933
|
request.body = env[:body]
|
951
934
|
|
952
935
|
post_parameters = Addressable::URI.form_unencode env[:body]
|
953
|
-
parameters
|
936
|
+
parameters.concat post_parameters
|
954
937
|
end
|
955
938
|
|
956
939
|
# No need to attach URI query parameters, the .sign_parameters
|
@@ -970,10 +953,6 @@ module Signet
|
|
970
953
|
request["Cache-Control"] = "no-store"
|
971
954
|
request
|
972
955
|
end
|
973
|
-
# rubocop:enable Metrics/AbcSize
|
974
|
-
# rubocop:enable Metrics/CyclomaticComplexity
|
975
|
-
# rubocop:enable Metrics/MethodLength
|
976
|
-
# rubocop:enable Metrics/PerceivedComplexity
|
977
956
|
|
978
957
|
##
|
979
958
|
# Transmits a request for a protected resource.
|