signet 0.16.1 → 0.18.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 +58 -54
- data/README.md +6 -6
- data/lib/signet/oauth_1/credential.rb +1 -1
- data/lib/signet/oauth_1/server.rb +1 -1
- data/lib/signet/oauth_1.rb +1 -1
- data/lib/signet/oauth_2/client.rb +88 -50
- data/lib/signet/oauth_2.rb +1 -1
- data/lib/signet/version.rb +1 -1
- metadata +9 -23
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 430b4ec8945e95be77f454a8103b93cbaf6ec2e2ff5d8ea875a96686e5c877d0
|
|
4
|
+
data.tar.gz: 672370d6c1769532dc02b34f4c89a8c2aac7613bd5aab71e1f182e0ceba2ea0c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cdd439206b52e37418e88c8010df6943f3d826277e222c4444f2bf351d1787040cc14192346125d8935d7ff8ac167b2f93d849aa32bda81524be9c041196e857
|
|
7
|
+
data.tar.gz: 9fc07647d3c15cfbd6526baaa589ec7f6e09083c92a0a299e47b2e07937e593dec6df78638796160a110a68a30c453064d86e0fac0dba349807ac3316618dbef
|
data/CHANGELOG.md
CHANGED
|
@@ -1,87 +1,91 @@
|
|
|
1
1
|
# Release History
|
|
2
2
|
|
|
3
|
-
###
|
|
3
|
+
### 0.18.0 (2023-09-01)
|
|
4
4
|
|
|
5
|
+
#### Features
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
* Expose Granted Scopes while fetching credentials ([#230](https://github.com/googleapis/signet/issues/230))
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
### 0.17.0 (2022-06-23)
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
* Updated minimum Ruby version to 2.6
|
|
11
12
|
|
|
13
|
+
### 0.16.1 (2022-02-24)
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
#### Bug Fixes
|
|
14
16
|
|
|
15
|
-
* Support
|
|
17
|
+
* Support Faraday 2
|
|
16
18
|
|
|
19
|
+
### 0.16.0 (2021-09-03)
|
|
17
20
|
|
|
18
|
-
|
|
21
|
+
#### Features
|
|
19
22
|
|
|
20
|
-
*
|
|
21
|
-
* Require addressable 2.8 to remediate vulnerability ([9a2f899](https://www.github.com/googleapis/signet/commit/9a2f8996f522538c4bb7998535e2a50331d564fc))
|
|
23
|
+
* Support for fetching an access token with basic auth
|
|
22
24
|
|
|
23
|
-
|
|
25
|
+
#### Bug Fixes
|
|
24
26
|
|
|
27
|
+
* Remove extraneous files from the gem
|
|
28
|
+
* Require addressable 2.8 to remediate vulnerability
|
|
25
29
|
|
|
26
|
-
###
|
|
30
|
+
### 0.15.0 (2021-03-04)
|
|
27
31
|
|
|
28
|
-
* Drop support for Ruby 2.4 and add support for Ruby 3.0
|
|
32
|
+
* Drop support for Ruby 2.4 and add support for Ruby 3.0
|
|
29
33
|
|
|
30
|
-
|
|
34
|
+
### 0.14.1 / 2021-01-27
|
|
31
35
|
|
|
32
36
|
* Fix OAuth1 signature with duplicate query param names
|
|
33
37
|
|
|
34
|
-
|
|
38
|
+
### 0.14.0 / 2020-03-31
|
|
35
39
|
|
|
36
40
|
* Support for fetching ID tokens from google oauth2 endpoint.
|
|
37
41
|
|
|
38
|
-
|
|
42
|
+
### 0.13.2 / 2020-03-25
|
|
39
43
|
|
|
40
44
|
Rerelease of 0.13.1.
|
|
41
45
|
|
|
42
|
-
|
|
46
|
+
### 0.13.1 / 2020-03-24
|
|
43
47
|
|
|
44
48
|
* Update github url
|
|
45
49
|
|
|
46
|
-
|
|
50
|
+
### 0.13.0 / 2020-02-24
|
|
47
51
|
|
|
48
52
|
* Support Faraday 1.x
|
|
49
53
|
|
|
50
|
-
|
|
54
|
+
### 0.12.0 / 2019-10-08
|
|
51
55
|
|
|
52
56
|
* This version now requires Ruby 2.4.
|
|
53
57
|
* Support array values of the "aud" field.
|
|
54
58
|
* Normalize the version constant to match related gems.
|
|
55
59
|
|
|
56
|
-
|
|
60
|
+
### 0.11.0 / 2018-10-08
|
|
57
61
|
|
|
58
62
|
* Add constant time comparison for oauth signatures.
|
|
59
63
|
|
|
60
|
-
|
|
64
|
+
### 0.10.0 / 2018-09-21
|
|
61
65
|
|
|
62
66
|
* Add UnexpectedStatusError class for http status errors that are not handled.
|
|
63
67
|
|
|
64
|
-
|
|
68
|
+
### 0.9.2 / 2018-09-12
|
|
65
69
|
|
|
66
70
|
* Update issued_at correctly when it is set simultaneously with expires_in.
|
|
67
71
|
|
|
68
|
-
|
|
72
|
+
### 0.9.1 / 2018-08-29
|
|
69
73
|
|
|
70
74
|
* Warn on EOL ruby versions.
|
|
71
75
|
* Fix DateTime normalization.
|
|
72
76
|
|
|
73
|
-
|
|
77
|
+
### 0.9.0 / 2018-08-20
|
|
74
78
|
|
|
75
79
|
* Add RemoteServerError class for 5xx level errors.
|
|
76
80
|
* Allow to_json to be called with arguments
|
|
77
81
|
* Expires_in now sets and reflects current expires_at value
|
|
78
82
|
* Expires_within(0) now returns false when expires_at is nil.
|
|
79
83
|
|
|
80
|
-
|
|
84
|
+
### 0.8.1 / 2017-10-13
|
|
81
85
|
|
|
82
86
|
* Restore support for Ruby 1.9.3
|
|
83
87
|
|
|
84
|
-
|
|
88
|
+
### 0.8.0 / 2017-10-12
|
|
85
89
|
|
|
86
90
|
* Ensure the "expires_at" attribute is recalculated on refresh (chutzimir)
|
|
87
91
|
* Fix warnings on Ruby 2.4 (koic)
|
|
@@ -89,20 +93,20 @@ Rerelease of 0.13.1.
|
|
|
89
93
|
* Provide signature verification algorithm for compatibility with ruby-jwt 2.0 (jurriaan)
|
|
90
94
|
* Signet::OAuth2::Client#decoded_id_token can take a keyfinder block (mvastola)
|
|
91
95
|
|
|
92
|
-
|
|
96
|
+
### 0.7.3 / 2016-06-20
|
|
93
97
|
|
|
94
98
|
* Fix timestamp parsing on 32-bit systems
|
|
95
99
|
* Fix expiration check when issue/expiry times are nil
|
|
96
100
|
|
|
97
|
-
|
|
101
|
+
### 0.7.2 / 2015-12-21
|
|
98
102
|
|
|
99
103
|
* Don't assume Faraday form encoding middleware is present
|
|
100
104
|
|
|
101
|
-
|
|
105
|
+
### 0.7.1 / 2015-12-17
|
|
102
106
|
|
|
103
107
|
* Fix an issue with date parsing
|
|
104
108
|
|
|
105
|
-
|
|
109
|
+
### 0.7 / 2015-12-06
|
|
106
110
|
|
|
107
111
|
* No longer overwrite SSL environment variables.
|
|
108
112
|
* Tighten up date & URL (de)serialization for OAuth2 client
|
|
@@ -111,7 +115,7 @@ Rerelease of 0.13.1.
|
|
|
111
115
|
* Add expires_within(sec) method to oauth2 client to facilitate proactive
|
|
112
116
|
refreshes
|
|
113
117
|
|
|
114
|
-
|
|
118
|
+
### 0.6.1 / 2015-06-08
|
|
115
119
|
|
|
116
120
|
* Fix language warnings for unused & shadowed variables ((@blowmage)[])
|
|
117
121
|
* Update SSL cert path for OSX ((@gambaroff)[])
|
|
@@ -119,14 +123,14 @@ Rerelease of 0.13.1.
|
|
|
119
123
|
* Fix incorrect parameter name in OAuth2 client docs ((@samuelreh)[])
|
|
120
124
|
* Fix symbolization of URL parameter keys ((@swifthand)[])
|
|
121
125
|
|
|
122
|
-
|
|
126
|
+
### 0.6.0 / 2014-12-05
|
|
123
127
|
|
|
124
128
|
* Drop support for ruby versions < 1.9.3
|
|
125
129
|
* Update gem dependencies and lock down versions tighter
|
|
126
130
|
* Allow form encoded responses when exchanging OAuth 2 authorization codes
|
|
127
131
|
* Normalize options keys for indifferent access
|
|
128
132
|
|
|
129
|
-
|
|
133
|
+
### 0.5.1 / 2014-06-08
|
|
130
134
|
|
|
131
135
|
* Allow Hash objects to be used to initialize authorization URI
|
|
132
136
|
* Added PLAINTEXT and RSA-SHA1 signature methods to OAuth 1 support
|
|
@@ -134,53 +138,53 @@ Rerelease of 0.13.1.
|
|
|
134
138
|
* The `approval_prompt` option no longer defaults to `:force`
|
|
135
139
|
* The `approval_prompt` and `prompt` are now mutually exclusive.
|
|
136
140
|
|
|
137
|
-
|
|
141
|
+
### 0.5.0 / 2013-05-31
|
|
138
142
|
|
|
139
143
|
* Switched to faraday 0.9.0
|
|
140
144
|
* Added `expires_at` option
|
|
141
145
|
|
|
142
|
-
|
|
146
|
+
### 0.4.5
|
|
143
147
|
|
|
144
148
|
* Minor documentation fixes
|
|
145
149
|
* Allow postmessage as a valid redirect_uri in OAuth 2
|
|
146
150
|
|
|
147
|
-
|
|
151
|
+
### 0.4.4
|
|
148
152
|
|
|
149
153
|
* Add support for assertion profile
|
|
150
154
|
|
|
151
|
-
|
|
155
|
+
### 0.4.3
|
|
152
156
|
|
|
153
157
|
* Added method to clear credentials
|
|
154
158
|
|
|
155
|
-
|
|
159
|
+
### 0.4.2
|
|
156
160
|
|
|
157
161
|
* Backwards compatibility for MultiJson
|
|
158
162
|
|
|
159
|
-
|
|
163
|
+
### 0.4.1
|
|
160
164
|
|
|
161
165
|
* Updated Launchy dependency
|
|
162
166
|
|
|
163
|
-
|
|
167
|
+
### 0.4.0
|
|
164
168
|
|
|
165
169
|
* Added OAuth 1 server implementation
|
|
166
170
|
* Updated Faraday dependency
|
|
167
171
|
|
|
168
|
-
|
|
172
|
+
### 0.3.4
|
|
169
173
|
|
|
170
174
|
* Attempts to auto-detect CA cert location
|
|
171
175
|
|
|
172
|
-
|
|
176
|
+
### 0.3.3
|
|
173
177
|
|
|
174
178
|
* Request objects no longer recreated during processing
|
|
175
179
|
* Faraday middleware now supported
|
|
176
180
|
* Streamed requests now supported
|
|
177
181
|
* Fixed assertion profiles; client ID/secret omission no longer an error
|
|
178
182
|
|
|
179
|
-
|
|
183
|
+
### 0.3.2
|
|
180
184
|
|
|
181
185
|
* Added audience security check for ID tokens
|
|
182
186
|
|
|
183
|
-
|
|
187
|
+
### 0.3.1
|
|
184
188
|
|
|
185
189
|
* Fixed a warning while determining grant type
|
|
186
190
|
* Removed requirement that a connection be supplied when authorizing requests
|
|
@@ -188,52 +192,52 @@ Rerelease of 0.13.1.
|
|
|
188
192
|
* Fixed some documentation stuff around markdown formatting
|
|
189
193
|
* Added support for Google Code wiki format output when generating docs
|
|
190
194
|
|
|
191
|
-
|
|
195
|
+
### 0.3.0
|
|
192
196
|
|
|
193
197
|
* Replaced httpadapter gem dependency with faraday
|
|
194
198
|
* Replaced json gem dependency with multi_json
|
|
195
199
|
* Updated to OAuth 2.0 draft 22
|
|
196
200
|
* Complete test coverage
|
|
197
201
|
|
|
198
|
-
|
|
202
|
+
### 0.2.4
|
|
199
203
|
|
|
200
204
|
* Updated to incorporate changes to the Google OAuth endpoints
|
|
201
205
|
|
|
202
|
-
|
|
206
|
+
### 0.2.3
|
|
203
207
|
|
|
204
208
|
* Added support for JWT-formatted ID tokens.
|
|
205
209
|
* Added :issued_at option to #update_token! method.
|
|
206
210
|
|
|
207
|
-
|
|
211
|
+
### 0.2.2
|
|
208
212
|
|
|
209
213
|
* Lowered requirements for json gem
|
|
210
214
|
|
|
211
|
-
|
|
215
|
+
### 0.2.1
|
|
212
216
|
|
|
213
217
|
* Updated to keep in sync with the new httpadapter changes
|
|
214
218
|
|
|
215
|
-
|
|
219
|
+
### 0.2.0
|
|
216
220
|
|
|
217
221
|
* Added support for OAuth 2.0 draft 10
|
|
218
222
|
|
|
219
|
-
|
|
223
|
+
### 0.1.4
|
|
220
224
|
|
|
221
225
|
* Added support for a two-legged authorization flow
|
|
222
226
|
|
|
223
|
-
|
|
227
|
+
### 0.1.3
|
|
224
228
|
|
|
225
229
|
* Fixed issue with headers passed in as a Hash
|
|
226
230
|
* Fixed incompatibilities with Ruby 1.8.6
|
|
227
231
|
|
|
228
|
-
|
|
232
|
+
### 0.1.2
|
|
229
233
|
|
|
230
234
|
* Fixed bug with overzealous normalization
|
|
231
235
|
|
|
232
|
-
|
|
236
|
+
### 0.1.1
|
|
233
237
|
|
|
234
238
|
* Fixed bug with missing StringIO require
|
|
235
239
|
* Fixed issue with dependency on unreleased features of addressable
|
|
236
240
|
|
|
237
|
-
|
|
241
|
+
### 0.1.0
|
|
238
242
|
|
|
239
243
|
* Initial release
|
data/README.md
CHANGED
|
@@ -59,11 +59,11 @@ Be sure `https://rubygems.org` is in your gem sources.
|
|
|
59
59
|
|
|
60
60
|
## Supported Ruby Versions
|
|
61
61
|
|
|
62
|
-
This library is supported on Ruby 2.
|
|
62
|
+
This library is supported on Ruby 2.6+.
|
|
63
63
|
|
|
64
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
|
|
66
|
-
security maintenance, and not end of life.
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
65
|
+
by Ruby Core—that is, Ruby versions that are either in normal maintenance or
|
|
66
|
+
in security maintenance, and not end of life. Older versions of Ruby _may_
|
|
67
|
+
still work, but are unsupported and not recommended. See
|
|
68
|
+
https://www.ruby-lang.org/en/downloads/branches/ for details about the Ruby
|
|
69
|
+
support schedule.
|
|
@@ -75,7 +75,7 @@ module Signet # :nodoc:
|
|
|
75
75
|
args = args.first.to_ary
|
|
76
76
|
end
|
|
77
77
|
if args.all? { |value| value.is_a? Array }
|
|
78
|
-
parameters = args.each_with_object({}) { |(k, v), h| h[k] = v
|
|
78
|
+
parameters = args.each_with_object({}) { |(k, v), h| h[k] = v }
|
|
79
79
|
@key = key_from_hash.call parameters
|
|
80
80
|
@secret = secret_from_hash.call parameters
|
|
81
81
|
elsif args.size == 2
|
|
@@ -458,7 +458,7 @@ module Signet
|
|
|
458
458
|
# can't have been signed correctly(5849#3.4.1.3)
|
|
459
459
|
unless post_parameters.sort == auth_hash.reject { |k, _v| k.index "oauth_" }.to_a.sort
|
|
460
460
|
raise MalformedAuthorizationError, "Request is of type application/x-www-form-urlencoded " \
|
|
461
|
-
|
|
461
|
+
"but Authentication header did not include form values"
|
|
462
462
|
end
|
|
463
463
|
end
|
|
464
464
|
|
data/lib/signet/oauth_1.rb
CHANGED
|
@@ -350,7 +350,7 @@ module Signet # :nodoc:
|
|
|
350
350
|
query_values = parsed_uri.query_values || {}
|
|
351
351
|
if options[:additional_parameters]
|
|
352
352
|
query_values = query_values.merge(
|
|
353
|
-
options[:additional_parameters].each_with_object({}) { |(k, v), h| h[k] = v
|
|
353
|
+
options[:additional_parameters].each_with_object({}) { |(k, v), h| h[k] = v }
|
|
354
354
|
)
|
|
355
355
|
end
|
|
356
356
|
query_values["oauth_token"] = temporary_credential_key if temporary_credential_key
|
|
@@ -20,6 +20,7 @@ require "signet/errors"
|
|
|
20
20
|
require "signet/oauth_2"
|
|
21
21
|
require "jwt"
|
|
22
22
|
require "date"
|
|
23
|
+
require "time"
|
|
23
24
|
|
|
24
25
|
module Signet
|
|
25
26
|
module OAuth2
|
|
@@ -31,52 +32,54 @@ module Signet
|
|
|
31
32
|
#
|
|
32
33
|
# @param [Hash] options
|
|
33
34
|
# The configuration parameters for the client.
|
|
34
|
-
# -
|
|
35
|
+
# - `:authorization_uri` -
|
|
35
36
|
# The authorization server's HTTP endpoint capable of
|
|
36
37
|
# authenticating the end-user and obtaining authorization.
|
|
37
|
-
# -
|
|
38
|
+
# - `:token_credential_uri` -
|
|
38
39
|
# The authorization server's HTTP endpoint capable of issuing
|
|
39
40
|
# tokens and refreshing expired tokens.
|
|
40
|
-
# -
|
|
41
|
+
# - `:client_id` -
|
|
41
42
|
# A unique identifier issued to the client to identify itself to the
|
|
42
43
|
# authorization server.
|
|
43
|
-
# -
|
|
44
|
+
# - `:client_secret` -
|
|
44
45
|
# A shared symmetric secret issued by the authorization server,
|
|
45
46
|
# which is used to authenticate the client.
|
|
46
|
-
# -
|
|
47
|
+
# - `:scope` -
|
|
47
48
|
# The scope of the access request, expressed either as an Array
|
|
48
49
|
# or as a space-delimited String.
|
|
49
|
-
# -
|
|
50
|
+
# - `:target_audience` -
|
|
50
51
|
# The final target audience for ID tokens fetched by this client,
|
|
51
52
|
# as a String.
|
|
52
|
-
# -
|
|
53
|
+
# - `:state` -
|
|
53
54
|
# An arbitrary string designed to allow the client to maintain state.
|
|
54
|
-
# -
|
|
55
|
+
# - `:code` -
|
|
55
56
|
# The authorization code received from the authorization server.
|
|
56
|
-
# -
|
|
57
|
+
# - `:redirect_uri` -
|
|
57
58
|
# The redirection URI used in the initial request.
|
|
58
|
-
# -
|
|
59
|
+
# - `:username` -
|
|
59
60
|
# The resource owner's username.
|
|
60
|
-
# -
|
|
61
|
+
# - `:password` -
|
|
61
62
|
# The resource owner's password.
|
|
62
|
-
# -
|
|
63
|
+
# - `:issuer` -
|
|
63
64
|
# Issuer ID when using assertion profile
|
|
64
|
-
# -
|
|
65
|
+
# - `:person` -
|
|
65
66
|
# Target user for assertions
|
|
66
|
-
# -
|
|
67
|
+
# - `:expiry` -
|
|
67
68
|
# Number of seconds assertions are valid for
|
|
68
|
-
# -
|
|
69
|
+
# - `:signing_key` -
|
|
69
70
|
# Signing key when using assertion profile
|
|
70
|
-
# -
|
|
71
|
+
# - `:refresh_token` -
|
|
71
72
|
# The refresh token associated with the access token
|
|
72
73
|
# to be refreshed.
|
|
73
|
-
# -
|
|
74
|
+
# - `:access_token` -
|
|
74
75
|
# The current access token for this client.
|
|
75
|
-
# -
|
|
76
|
+
# - `:id_token` -
|
|
76
77
|
# The current ID token for this client.
|
|
77
|
-
# -
|
|
78
|
+
# - `:extension_parameters` -
|
|
78
79
|
# When using an extension grant type, this the set of parameters used
|
|
79
80
|
# by that extension.
|
|
81
|
+
# - `:granted_scopes` -
|
|
82
|
+
# All scopes granted by authorization server.
|
|
80
83
|
#
|
|
81
84
|
# @example
|
|
82
85
|
# client = Signet::OAuth2::Client.new(
|
|
@@ -108,6 +111,7 @@ module Signet
|
|
|
108
111
|
@state = nil
|
|
109
112
|
@username = nil
|
|
110
113
|
@access_type = nil
|
|
114
|
+
@granted_scopes = nil
|
|
111
115
|
update! options
|
|
112
116
|
end
|
|
113
117
|
|
|
@@ -116,56 +120,58 @@ module Signet
|
|
|
116
120
|
#
|
|
117
121
|
# @param [Hash] options
|
|
118
122
|
# The configuration parameters for the client.
|
|
119
|
-
# -
|
|
123
|
+
# - `:authorization_uri` -
|
|
120
124
|
# The authorization server's HTTP endpoint capable of
|
|
121
125
|
# authenticating the end-user and obtaining authorization.
|
|
122
|
-
# -
|
|
126
|
+
# - `:token_credential_uri` -
|
|
123
127
|
# The authorization server's HTTP endpoint capable of issuing
|
|
124
128
|
# tokens and refreshing expired tokens.
|
|
125
|
-
# -
|
|
129
|
+
# - `:client_id` -
|
|
126
130
|
# A unique identifier issued to the client to identify itself to the
|
|
127
131
|
# authorization server.
|
|
128
|
-
# -
|
|
132
|
+
# - `:client_secret` -
|
|
129
133
|
# A shared symmetric secret issued by the authorization server,
|
|
130
134
|
# which is used to authenticate the client.
|
|
131
|
-
# -
|
|
135
|
+
# - `:scope` -
|
|
132
136
|
# The scope of the access request, expressed either as an Array
|
|
133
137
|
# or as a space-delimited String.
|
|
134
|
-
# -
|
|
138
|
+
# - `:target_audience` -
|
|
135
139
|
# The final target audience for ID tokens fetched by this client,
|
|
136
140
|
# as a String.
|
|
137
|
-
# -
|
|
141
|
+
# - `:state` -
|
|
138
142
|
# An arbitrary string designed to allow the client to maintain state.
|
|
139
|
-
# -
|
|
143
|
+
# - `:code` -
|
|
140
144
|
# The authorization code received from the authorization server.
|
|
141
|
-
# -
|
|
145
|
+
# - `:redirect_uri` -
|
|
142
146
|
# The redirection URI used in the initial request.
|
|
143
|
-
# -
|
|
147
|
+
# - `:username` -
|
|
144
148
|
# The resource owner's username.
|
|
145
|
-
# -
|
|
149
|
+
# - `:password` -
|
|
146
150
|
# The resource owner's password.
|
|
147
|
-
# -
|
|
151
|
+
# - `:issuer` -
|
|
148
152
|
# Issuer ID when using assertion profile
|
|
149
|
-
# -
|
|
153
|
+
# - `:audience` -
|
|
150
154
|
# Target audience for assertions
|
|
151
|
-
# -
|
|
155
|
+
# - `:person` -
|
|
152
156
|
# Target user for assertions
|
|
153
|
-
# -
|
|
157
|
+
# - `:expiry` -
|
|
154
158
|
# Number of seconds assertions are valid for
|
|
155
|
-
# -
|
|
159
|
+
# - `:signing_key` -
|
|
156
160
|
# Signing key when using assertion profile
|
|
157
|
-
# -
|
|
161
|
+
# - `:refresh_token` -
|
|
158
162
|
# The refresh token associated with the access token
|
|
159
163
|
# to be refreshed.
|
|
160
|
-
# -
|
|
164
|
+
# - `:access_token` -
|
|
161
165
|
# The current access token for this client.
|
|
162
|
-
# -
|
|
166
|
+
# - `:access_type` -
|
|
163
167
|
# The current access type parameter for #authorization_uri.
|
|
164
|
-
# -
|
|
168
|
+
# - `:id_token` -
|
|
165
169
|
# The current ID token for this client.
|
|
166
|
-
# -
|
|
170
|
+
# - `:extension_parameters` -
|
|
167
171
|
# When using an extension grant type, this is the set of parameters used
|
|
168
172
|
# by that extension.
|
|
173
|
+
# - `:granted_scopes` -
|
|
174
|
+
# All scopes granted by authorization server.
|
|
169
175
|
#
|
|
170
176
|
# @example
|
|
171
177
|
# client.update!(
|
|
@@ -252,7 +258,7 @@ module Signet
|
|
|
252
258
|
self.access_token = options[:access_token] if options.key? :access_token
|
|
253
259
|
self.refresh_token = options[:refresh_token] if options.key? :refresh_token
|
|
254
260
|
self.id_token = options[:id_token] if options.key? :id_token
|
|
255
|
-
|
|
261
|
+
self.granted_scopes = options[:granted_scopes] if options.key? :granted_scopes
|
|
256
262
|
self
|
|
257
263
|
end
|
|
258
264
|
|
|
@@ -610,7 +616,7 @@ module Signet
|
|
|
610
616
|
# @param [Integer, String] new_expiry
|
|
611
617
|
# Assertion expiry, in seconds
|
|
612
618
|
def expiry= new_expiry
|
|
613
|
-
@expiry = new_expiry
|
|
619
|
+
@expiry = new_expiry&.to_i
|
|
614
620
|
end
|
|
615
621
|
|
|
616
622
|
##
|
|
@@ -822,6 +828,33 @@ module Signet
|
|
|
822
828
|
@expires_at = normalize_timestamp new_expires_at
|
|
823
829
|
end
|
|
824
830
|
|
|
831
|
+
##
|
|
832
|
+
# Returns the scopes granted by the authorization server.
|
|
833
|
+
#
|
|
834
|
+
# @return [Array, nil] The scope of access returned by the authorization server.
|
|
835
|
+
def granted_scopes
|
|
836
|
+
@granted_scopes
|
|
837
|
+
end
|
|
838
|
+
|
|
839
|
+
##
|
|
840
|
+
# Sets the scopes returned by authorization server for this client.
|
|
841
|
+
#
|
|
842
|
+
# @param [String, Array, nil] new_granted_scopes
|
|
843
|
+
# The scope of access returned by authorization server. This will
|
|
844
|
+
# ideally be expressed as space-delimited String.
|
|
845
|
+
def granted_scopes= new_granted_scopes
|
|
846
|
+
case new_granted_scopes
|
|
847
|
+
when Array
|
|
848
|
+
@granted_scopes = new_granted_scopes
|
|
849
|
+
when String
|
|
850
|
+
@granted_scopes = new_granted_scopes.split
|
|
851
|
+
when nil
|
|
852
|
+
@granted_scopes = nil
|
|
853
|
+
else
|
|
854
|
+
raise TypeError, "Expected Array or String, got #{new_granted_scopes.class}"
|
|
855
|
+
end
|
|
856
|
+
end
|
|
857
|
+
|
|
825
858
|
##
|
|
826
859
|
# Returns true if the access token has expired.
|
|
827
860
|
# Returns false if the token has not expired or has an nil @expires_at.
|
|
@@ -856,6 +889,7 @@ module Signet
|
|
|
856
889
|
@code = nil
|
|
857
890
|
@issued_at = nil
|
|
858
891
|
@expires_at = nil
|
|
892
|
+
@granted_scopes = nil
|
|
859
893
|
end
|
|
860
894
|
|
|
861
895
|
##
|
|
@@ -915,27 +949,28 @@ module Signet
|
|
|
915
949
|
# @return [String] A serialized JSON representation of the client.
|
|
916
950
|
def to_json *_args
|
|
917
951
|
MultiJson.dump(
|
|
918
|
-
"authorization_uri" => authorization_uri
|
|
919
|
-
"token_credential_uri" => token_credential_uri
|
|
952
|
+
"authorization_uri" => authorization_uri&.to_s,
|
|
953
|
+
"token_credential_uri" => token_credential_uri&.to_s,
|
|
920
954
|
"client_id" => client_id,
|
|
921
955
|
"client_secret" => client_secret,
|
|
922
956
|
"scope" => scope,
|
|
923
957
|
"target_audience" => target_audience,
|
|
924
958
|
"state" => state,
|
|
925
959
|
"code" => code,
|
|
926
|
-
"redirect_uri" => redirect_uri
|
|
960
|
+
"redirect_uri" => redirect_uri&.to_s,
|
|
927
961
|
"username" => username,
|
|
928
962
|
"password" => password,
|
|
929
963
|
"issuer" => issuer,
|
|
930
964
|
"audience" => audience,
|
|
931
965
|
"person" => person,
|
|
932
966
|
"expiry" => expiry,
|
|
933
|
-
"expires_at" => expires_at
|
|
967
|
+
"expires_at" => expires_at&.to_i,
|
|
934
968
|
"signing_key" => signing_key,
|
|
935
969
|
"refresh_token" => refresh_token,
|
|
936
970
|
"access_token" => access_token,
|
|
937
971
|
"id_token" => id_token,
|
|
938
|
-
"extension_parameters" => extension_parameters
|
|
972
|
+
"extension_parameters" => extension_parameters,
|
|
973
|
+
"granted_scopes" => granted_scopes
|
|
939
974
|
)
|
|
940
975
|
end
|
|
941
976
|
|
|
@@ -1019,19 +1054,22 @@ module Signet
|
|
|
1019
1054
|
content_type = response.header[:content_type]
|
|
1020
1055
|
end
|
|
1021
1056
|
|
|
1022
|
-
return ::Signet::OAuth2.parse_credentials body, content_type if status == 200
|
|
1023
|
-
|
|
1024
1057
|
message = " Server message:\n#{response.body.to_s.strip}" unless body.to_s.strip.empty?
|
|
1058
|
+
|
|
1025
1059
|
if [400, 401, 403].include? status
|
|
1026
1060
|
message = "Authorization failed.#{message}"
|
|
1027
1061
|
raise ::Signet::AuthorizationError.new message, response: response
|
|
1028
1062
|
elsif status.to_s[0] == "5"
|
|
1029
1063
|
message = "Remote server error.#{message}"
|
|
1030
1064
|
raise ::Signet::RemoteServerError, message
|
|
1031
|
-
|
|
1065
|
+
elsif status != 200
|
|
1032
1066
|
message = "Unexpected status code: #{response.status}.#{message}"
|
|
1033
1067
|
raise ::Signet::UnexpectedStatusError, message
|
|
1034
1068
|
end
|
|
1069
|
+
# status == 200
|
|
1070
|
+
parsed_response = ::Signet::OAuth2.parse_credentials body, content_type
|
|
1071
|
+
parsed_response["granted_scopes"] = parsed_response.delete("scope") if parsed_response
|
|
1072
|
+
parsed_response
|
|
1035
1073
|
end
|
|
1036
1074
|
|
|
1037
1075
|
def fetch_access_token! options = {}
|
data/lib/signet/oauth_2.rb
CHANGED
|
@@ -78,7 +78,7 @@ module Signet # :nodoc:
|
|
|
78
78
|
when %r{^application/json.*}
|
|
79
79
|
MultiJson.load body
|
|
80
80
|
when %r{^application/x-www-form-urlencoded.*}
|
|
81
|
-
|
|
81
|
+
Addressable::URI.form_unencode(body).to_h
|
|
82
82
|
else
|
|
83
83
|
raise ArgumentError, "Invalid content type '#{content_type}'"
|
|
84
84
|
end
|
data/lib/signet/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: signet
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.18.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Bob Aman
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date:
|
|
12
|
+
date: 2023-09-06 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: addressable
|
|
@@ -34,7 +34,7 @@ dependencies:
|
|
|
34
34
|
version: 0.17.5
|
|
35
35
|
- - "<"
|
|
36
36
|
- !ruby/object:Gem::Version
|
|
37
|
-
version:
|
|
37
|
+
version: 3.a
|
|
38
38
|
type: :runtime
|
|
39
39
|
prerelease: false
|
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -44,7 +44,7 @@ dependencies:
|
|
|
44
44
|
version: 0.17.5
|
|
45
45
|
- - "<"
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
|
-
version:
|
|
47
|
+
version: 3.a
|
|
48
48
|
- !ruby/object:Gem::Dependency
|
|
49
49
|
name: jwt
|
|
50
50
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -85,14 +85,14 @@ dependencies:
|
|
|
85
85
|
requirements:
|
|
86
86
|
- - "~>"
|
|
87
87
|
- !ruby/object:Gem::Version
|
|
88
|
-
version: 1.
|
|
88
|
+
version: 1.26.1
|
|
89
89
|
type: :development
|
|
90
90
|
prerelease: false
|
|
91
91
|
version_requirements: !ruby/object:Gem::Requirement
|
|
92
92
|
requirements:
|
|
93
93
|
- - "~>"
|
|
94
94
|
- !ruby/object:Gem::Version
|
|
95
|
-
version: 1.
|
|
95
|
+
version: 1.26.1
|
|
96
96
|
- !ruby/object:Gem::Dependency
|
|
97
97
|
name: kramdown
|
|
98
98
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -163,20 +163,6 @@ dependencies:
|
|
|
163
163
|
- - "~>"
|
|
164
164
|
- !ruby/object:Gem::Version
|
|
165
165
|
version: '3.1'
|
|
166
|
-
- !ruby/object:Gem::Dependency
|
|
167
|
-
name: simplecov
|
|
168
|
-
requirement: !ruby/object:Gem::Requirement
|
|
169
|
-
requirements:
|
|
170
|
-
- - "~>"
|
|
171
|
-
- !ruby/object:Gem::Version
|
|
172
|
-
version: '0.9'
|
|
173
|
-
type: :development
|
|
174
|
-
prerelease: false
|
|
175
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
176
|
-
requirements:
|
|
177
|
-
- - "~>"
|
|
178
|
-
- !ruby/object:Gem::Version
|
|
179
|
-
version: '0.9'
|
|
180
166
|
- !ruby/object:Gem::Dependency
|
|
181
167
|
name: yard
|
|
182
168
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -199,7 +185,7 @@ dependencies:
|
|
|
199
185
|
version: 0.9.12
|
|
200
186
|
description: 'Signet is an OAuth 1.0 / OAuth 2.0 implementation.
|
|
201
187
|
|
|
202
|
-
'
|
|
188
|
+
'
|
|
203
189
|
email: sbazyl@google.com
|
|
204
190
|
executables: []
|
|
205
191
|
extensions: []
|
|
@@ -241,14 +227,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
241
227
|
requirements:
|
|
242
228
|
- - ">="
|
|
243
229
|
- !ruby/object:Gem::Version
|
|
244
|
-
version: '2.
|
|
230
|
+
version: '2.6'
|
|
245
231
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
246
232
|
requirements:
|
|
247
233
|
- - ">="
|
|
248
234
|
- !ruby/object:Gem::Version
|
|
249
235
|
version: 1.3.5
|
|
250
236
|
requirements: []
|
|
251
|
-
rubygems_version: 3.
|
|
237
|
+
rubygems_version: 3.4.19
|
|
252
238
|
signing_key:
|
|
253
239
|
specification_version: 4
|
|
254
240
|
summary: Signet is an OAuth 1.0 / OAuth 2.0 implementation.
|