signet 0.19.0 → 0.22.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 13fbdf2ef81b9b3fd51060e1a41624ad6bac62c6980eca00905cd88e8f053be8
4
- data.tar.gz: 3b04aaebc576451c9de4e3661eb441cd6d0bd6d3a7bdf63493eeaecdd819ede4
3
+ metadata.gz: ce6c9d2f280312b96e689ba3d798219759b1a6186cb426b34fa27c9e424dd9d1
4
+ data.tar.gz: 58e009354222673d4df31c473cc25a370d9cedccadf93438e0b4f1fc8d8f0515
5
5
  SHA512:
6
- metadata.gz: 9c11f05eb845cd94228ab7e10b656bd9ea9c7d63ebc7dc4fb2413a12901d3803b2bd6de48dfa77fb68fb842effb42bf65c5ca1ce5ff90bdbd1a0ac6806630a15
7
- data.tar.gz: 46097fea3a8a754b9b8e31476f50270fb8d6c48df3ff69f537546bfd6437de3ef58dff3f0d1ff355d378d54e82a05c6a4b6509dd647ba912705abe252b182d62
6
+ metadata.gz: fd298adfd9dd0d552e998ae4c14f870f5b57c60cfb6e42345a9e5f89cb07d2bfb7560af727ac60c7335f8d25eb6a21391f460de3e36b72285970a94a2591956d
7
+ data.tar.gz: 03ca2ed4b43b1c8e5e3cc7c53c4c882d2ebef7f42b3b6c4886d8ec3ea15dc62db4ed8705a30751f8ad3af693e6f847785936f8024cbf9aa4ce28b908afb0a3c7
data/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # Release History
2
2
 
3
+ ### 0.22.0 (2026-06-04)
4
+
5
+ #### Features
6
+
7
+ * migrate from multi_json to standard json ([#273](https://github.com/googleapis/signet/issues/273)) ([bd067b2](https://github.com/googleapis/signet/commit/bd067b2a54442fbc9a1d084c3c78dc913bd3be86)), closes [#272](https://github.com/googleapis/signet/issues/272)
8
+
9
+ ### 0.21.0 (2025-08-25)
10
+
11
+ #### Features
12
+
13
+ * support for JWT 3.x ([#259](https://github.com/googleapis/signet/issues/259))
14
+
15
+ ### 0.20.0 (2025-04-30)
16
+
17
+ #### Features
18
+
19
+ * Updated minimum Ruby version to 3.1 ([#253](https://github.com/googleapis/signet/issues/253))
20
+
3
21
  ### 0.19.0 (2024-02-01)
4
22
 
5
23
  #### Features
data/README.md CHANGED
@@ -59,7 +59,7 @@ 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.7+.
62
+ This library is supported on Ruby 3.2+.
63
63
 
64
64
  Google provides official support for Ruby versions that are actively supported
65
65
  by Ruby Core—that is, Ruby versions that are either in normal maintenance or
@@ -21,6 +21,7 @@ require "signet"
21
21
  require "signet/errors"
22
22
  require "signet/oauth_1"
23
23
  require "signet/oauth_1/credential"
24
+ require "json"
24
25
 
25
26
  module Signet
26
27
  module OAuth1
@@ -552,7 +553,7 @@ module Signet
552
553
  #
553
554
  # @return [String] A serialized JSON representation of the client.
554
555
  def to_json *_args
555
- MultiJson.dump(
556
+ JSON.generate(
556
557
  "temporary_credential_uri" => temporary_credential_uri,
557
558
  "authorization_uri" => authorization_uri,
558
559
  "token_credential_uri" => token_credential_uri,
@@ -75,7 +75,7 @@ module Signet
75
75
  nonce =
76
76
  @nonce_timestamp.call nonce, timestamp
77
77
  end
78
- nonce ? true : false
78
+ !!nonce
79
79
  end
80
80
 
81
81
  ##
@@ -112,9 +112,9 @@ module Signet
112
112
  # Call a credential lookup, and cast the result to a proper Credential.
113
113
  #
114
114
  # @param [Proc] credential to call.
115
- # @param [String] key provided to the Proc in <code>credential</code>
115
+ # @param [String] key provided to the Proc in `credential`
116
116
  # @return [Signet::OAuth1::Credential] credential provided by
117
- # <code>credential</code> (if any).
117
+ # `credential` (if any).
118
118
  def call_credential_lookup credential, key
119
119
  cred = credential.call key if
120
120
  credential.respond_to? :call
@@ -134,17 +134,17 @@ module Signet
134
134
  #
135
135
  # @param [String] verifier Key provided to the {#verifier} Proc.
136
136
  # @return [Boolean] if the verifier Proc returns anything other than
137
- # <code>nil</code> or <code>false</code>.
137
+ # `nil` or `false`
138
138
  def find_verifier verifier
139
139
  verified = @verifier.call verifier if @verifier.respond_to? :call
140
- verified ? true : false
140
+ !!verified
141
141
  end
142
142
 
143
143
  ##
144
144
  # Validate and normalize the components from an HTTP request.
145
145
  # @overload verify_request_components(options)
146
146
  # @param [Faraday::Request] request A pre-constructed request to verify.
147
- # @param [String] method the HTTP method , defaults to <code>GET</code>
147
+ # @param [String] method the HTTP method , defaults to `GET`
148
148
  # @param [Addressable::URI, String] uri the URI .
149
149
  # @param [Hash, Array] headers the HTTP headers.
150
150
  # @param [StringIO, String] body The HTTP body.
@@ -199,7 +199,7 @@ module Signet
199
199
  ##
200
200
  # @overload request_realm(options)
201
201
  # @param [Hash] request A pre-constructed request to verify.
202
- # @param [String] method the HTTP method , defaults to <code>GET</code>
202
+ # @param [String] method the HTTP method , defaults to `GET`
203
203
  # @param [Addressable::URI, String] uri the URI .
204
204
  # @param [Hash, Array] headers the HTTP headers.
205
205
  # @param [StringIO, String] body The HTTP body.
@@ -228,16 +228,16 @@ module Signet
228
228
 
229
229
  ##
230
230
  # Authenticates a temporary credential request. If no oauth_callback is
231
- # present in the request, <code>oob</code> will be returned.
231
+ # present in the request, `oob` will be returned.
232
232
  #
233
233
  # @overload authenticate_temporary_credential_request(options)
234
234
  # @param [Hash] request The configuration parameters for the request.
235
- # @param [String] method the HTTP method , defaults to <code>GET</code>
235
+ # @param [String] method the HTTP method , defaults to `GET`
236
236
  # @param [Addressable::URI, String] uri the URI .
237
237
  # @param [Hash, Array] headers the HTTP headers.
238
238
  # @param [StringIO, String] body The HTTP body.
239
239
  # @param [HTTPAdapter] adapter The HTTP adapter(optional).
240
- # @return [String] The oauth_callback value, or <code>false</code> if not valid.
240
+ # @return [String] The oauth_callback value, or `false` if not valid.
241
241
  def authenticate_temporary_credential_request options = {}
242
242
  verifications = {
243
243
  client_credential: lambda { |_x|
@@ -279,7 +279,7 @@ module Signet
279
279
  method,
280
280
  uri,
281
281
  # Realm isn't used, and will throw the signature off.
282
- auth_hash.reject { |k, _v| k == "realm" }.to_a,
282
+ auth_hash.except("realm").to_a,
283
283
  client_credential_secret,
284
284
  nil
285
285
  )
@@ -298,13 +298,13 @@ module Signet
298
298
  # Authenticates a token credential request.
299
299
  # @overload authenticate_token_credential_request(options)
300
300
  # @param [Hash] request The configuration parameters for the request.
301
- # @param [String] method the HTTP method , defaults to <code>GET</code>
301
+ # @param [String] method the HTTP method , defaults to `GET`
302
302
  # @param [Addressable::URI, String] uri the URI .
303
303
  # @param [Hash, Array] headers the HTTP headers.
304
304
  # @param [StringIO, String] body The HTTP body.
305
305
  # @param [HTTPAdapter] adapter The HTTP adapter(optional).
306
306
  # @return [Hash] A hash of credentials and realm for a valid request,
307
- # or <code>nil</code> if not valid.
307
+ # or `nil` if not valid.
308
308
  def authenticate_token_credential_request options = {}
309
309
  verifications = {
310
310
  client_credential: lambda { |_x|
@@ -353,7 +353,7 @@ module Signet
353
353
  method,
354
354
  uri,
355
355
  # Realm isn't used, and will throw the signature off.
356
- auth_hash.reject { |k, _v| k == "realm" }.to_a,
356
+ auth_hash.except("realm").to_a,
357
357
  client_credential.secret,
358
358
  temporary_credential.secret
359
359
  )
@@ -368,7 +368,7 @@ module Signet
368
368
  # Authenticates a request for a protected resource.
369
369
  # @overload authenticate_resource_request(options)
370
370
  # @param [Hash] request The configuration parameters for the request.
371
- # @param [String] method the HTTP method , defaults to <code>GET</code>
371
+ # @param [String] method the HTTP method , defaults to `GET`
372
372
  # @param [Addressable::URI, String] uri the URI .
373
373
  # @param [Hash, Array] headers the HTTP headers.
374
374
  # @param [StringIO, String] body The HTTP body.
@@ -376,7 +376,7 @@ module Signet
376
376
  # @param [HTTPAdapter] adapter The HTTP adapter(optional).
377
377
  #
378
378
  # @return [Hash] A hash of the credentials and realm for a valid request,
379
- # or <code>nil</code> if not valid.
379
+ # or `nil` if not valid.
380
380
  def authenticate_resource_request options = {}
381
381
  verifications = {
382
382
  client_credential: lambda do |_x|
@@ -468,7 +468,7 @@ module Signet
468
468
  method,
469
469
  uri,
470
470
  # Realm isn't used, and will throw the signature off.
471
- auth_hash.reject { |k, _v| k == "realm" }.to_a,
471
+ auth_hash.except("realm").to_a,
472
472
  client_credential_secret,
473
473
  token_credential_secret
474
474
  )
@@ -4,9 +4,7 @@ require "signet"
4
4
  module Signet # :nodoc:
5
5
  module OAuth1
6
6
  module HMACSHA1
7
- def self.generate_signature \
8
- base_string, client_credential_secret, token_credential_secret
9
-
7
+ def self.generate_signature base_string, client_credential_secret, token_credential_secret
10
8
  # Both the client secret and token secret must be escaped
11
9
  client_credential_secret =
12
10
  Signet::OAuth1.encode client_credential_secret
@@ -3,9 +3,7 @@ require "signet"
3
3
  module Signet # :nodoc:
4
4
  module OAuth1
5
5
  module PLAINTEXT
6
- def self.generate_signature \
7
- _base_string, client_credential_secret, token_credential_secret
8
-
6
+ def self.generate_signature _base_string, client_credential_secret, token_credential_secret
9
7
  # Both the client secret and token secret must be escaped
10
8
  client_credential_secret =
11
9
  Signet::OAuth1.encode client_credential_secret
@@ -6,10 +6,7 @@ require "signet"
6
6
  module Signet # :nodoc:
7
7
  module OAuth1
8
8
  module RSASHA1
9
- def self.generate_signature \
10
- base_string, client_credential_secret, _token_credential_secret
11
-
12
-
9
+ def self.generate_signature base_string, client_credential_secret, _token_credential_secret
13
10
  private_key = OpenSSL::PKey::RSA.new client_credential_secret
14
11
  signature = private_key.sign OpenSSL::Digest.new("SHA1"), base_string
15
12
  # using strict_encode64 because the encode64 method adds newline characters after ever 60 chars
@@ -19,6 +19,7 @@ require "signet"
19
19
  require "signet/errors"
20
20
  require "signet/oauth_2"
21
21
  require "jwt"
22
+ require "json"
22
23
  require "date"
23
24
  require "time"
24
25
 
@@ -750,10 +751,10 @@ module Signet
750
751
  # omitted.
751
752
  #
752
753
  # @return [String] The decoded ID token.
753
- def decoded_id_token public_key = nil, options = {}, &keyfinder
754
+ def decoded_id_token(public_key = nil, options = {}, &)
754
755
  options[:algorithm] ||= signing_algorithm
755
756
  verify = !public_key.nil? || block_given?
756
- payload, _header = JWT.decode(id_token, public_key, verify, options, &keyfinder)
757
+ payload, _header = JWT.decode(id_token, public_key, verify, options, &)
757
758
  raise Signet::UnsafeOperationError, "No ID token audience declared." unless payload.key? "aud"
758
759
  unless Array(payload["aud"]).include?(client_id)
759
760
  raise Signet::UnsafeOperationError,
@@ -948,7 +949,7 @@ module Signet
948
949
  #
949
950
  # @return [String] A serialized JSON representation of the client.
950
951
  def to_json *_args
951
- MultiJson.dump(
952
+ JSON.generate(
952
953
  "authorization_uri" => authorization_uri&.to_s,
953
954
  "token_credential_uri" => token_credential_uri&.to_s,
954
955
  "client_id" => client_id,
@@ -14,7 +14,7 @@
14
14
 
15
15
  require "base64"
16
16
  require "signet"
17
- require "multi_json"
17
+ require "json"
18
18
 
19
19
  module Signet # :nodoc:
20
20
  ##
@@ -76,7 +76,11 @@ module Signet # :nodoc:
76
76
  raise TypeError, "Expected String, got #{body.class}." unless body.is_a? String
77
77
  case content_type
78
78
  when %r{^application/json.*}
79
- MultiJson.load body
79
+ begin
80
+ JSON.parse body
81
+ rescue JSON::ParserError => e
82
+ raise Signet::ParseError, e.message
83
+ end
80
84
  when %r{^application/x-www-form-urlencoded.*}
81
85
  Addressable::URI.form_unencode(body).to_h
82
86
  else
@@ -114,9 +118,7 @@ module Signet # :nodoc:
114
118
  #
115
119
  # @return [String]
116
120
  # The value for the HTTP Basic Authorization header.
117
- def self.generate_bearer_authorization_header \
118
- access_token, auth_params = nil
119
-
121
+ def self.generate_bearer_authorization_header access_token, auth_params = nil
120
122
  # TODO: escaping?
121
123
  header = "Bearer #{access_token}"
122
124
  if auth_params && !auth_params.empty?
@@ -13,5 +13,5 @@
13
13
  # limitations under the License.
14
14
 
15
15
  module Signet
16
- VERSION = "0.19.0".freeze
16
+ VERSION = "0.22.0".freeze
17
17
  end
metadata CHANGED
@@ -1,15 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: signet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.19.0
4
+ version: 0.22.0
5
5
  platform: ruby
6
6
  authors:
7
- - Bob Aman
8
- - Steven Bazyl
9
- autorequire:
7
+ - Google LLC
10
8
  bindir: bin
11
9
  cert_chain: []
12
- date: 2024-02-13 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
13
11
  dependencies:
14
12
  - !ruby/object:Gem::Dependency
15
13
  name: addressable
@@ -54,7 +52,7 @@ dependencies:
54
52
  version: '1.5'
55
53
  - - "<"
56
54
  - !ruby/object:Gem::Version
57
- version: '3.0'
55
+ version: '4.0'
58
56
  type: :runtime
59
57
  prerelease: false
60
58
  version_requirements: !ruby/object:Gem::Requirement
@@ -64,129 +62,12 @@ dependencies:
64
62
  version: '1.5'
65
63
  - - "<"
66
64
  - !ruby/object:Gem::Version
67
- version: '3.0'
68
- - !ruby/object:Gem::Dependency
69
- name: multi_json
70
- requirement: !ruby/object:Gem::Requirement
71
- requirements:
72
- - - "~>"
73
- - !ruby/object:Gem::Version
74
- version: '1.10'
75
- type: :runtime
76
- prerelease: false
77
- version_requirements: !ruby/object:Gem::Requirement
78
- requirements:
79
- - - "~>"
80
- - !ruby/object:Gem::Version
81
- version: '1.10'
82
- - !ruby/object:Gem::Dependency
83
- name: google-style
84
- requirement: !ruby/object:Gem::Requirement
85
- requirements:
86
- - - "~>"
87
- - !ruby/object:Gem::Version
88
- version: 1.27.1
89
- type: :development
90
- prerelease: false
91
- version_requirements: !ruby/object:Gem::Requirement
92
- requirements:
93
- - - "~>"
94
- - !ruby/object:Gem::Version
95
- version: 1.27.1
96
- - !ruby/object:Gem::Dependency
97
- name: kramdown
98
- requirement: !ruby/object:Gem::Requirement
99
- requirements:
100
- - - "~>"
101
- - !ruby/object:Gem::Version
102
- version: '1.5'
103
- type: :development
104
- prerelease: false
105
- version_requirements: !ruby/object:Gem::Requirement
106
- requirements:
107
- - - "~>"
108
- - !ruby/object:Gem::Version
109
- version: '1.5'
110
- - !ruby/object:Gem::Dependency
111
- name: launchy
112
- requirement: !ruby/object:Gem::Requirement
113
- requirements:
114
- - - "~>"
115
- - !ruby/object:Gem::Version
116
- version: '2.4'
117
- type: :development
118
- prerelease: false
119
- version_requirements: !ruby/object:Gem::Requirement
120
- requirements:
121
- - - "~>"
122
- - !ruby/object:Gem::Version
123
- version: '2.4'
124
- - !ruby/object:Gem::Dependency
125
- name: rake
126
- requirement: !ruby/object:Gem::Requirement
127
- requirements:
128
- - - "~>"
129
- - !ruby/object:Gem::Version
130
- version: '13.0'
131
- type: :development
132
- prerelease: false
133
- version_requirements: !ruby/object:Gem::Requirement
134
- requirements:
135
- - - "~>"
136
- - !ruby/object:Gem::Version
137
- version: '13.0'
138
- - !ruby/object:Gem::Dependency
139
- name: redcarpet
140
- requirement: !ruby/object:Gem::Requirement
141
- requirements:
142
- - - "~>"
143
- - !ruby/object:Gem::Version
144
- version: '3.0'
145
- type: :development
146
- prerelease: false
147
- version_requirements: !ruby/object:Gem::Requirement
148
- requirements:
149
- - - "~>"
150
- - !ruby/object:Gem::Version
151
- version: '3.0'
152
- - !ruby/object:Gem::Dependency
153
- name: rspec
154
- requirement: !ruby/object:Gem::Requirement
155
- requirements:
156
- - - "~>"
157
- - !ruby/object:Gem::Version
158
- version: '3.1'
159
- type: :development
160
- prerelease: false
161
- version_requirements: !ruby/object:Gem::Requirement
162
- requirements:
163
- - - "~>"
164
- - !ruby/object:Gem::Version
165
- version: '3.1'
166
- - !ruby/object:Gem::Dependency
167
- name: yard
168
- requirement: !ruby/object:Gem::Requirement
169
- requirements:
170
- - - "~>"
171
- - !ruby/object:Gem::Version
172
- version: '0.9'
173
- - - ">="
174
- - !ruby/object:Gem::Version
175
- version: 0.9.12
176
- type: :development
177
- prerelease: false
178
- version_requirements: !ruby/object:Gem::Requirement
179
- requirements:
180
- - - "~>"
181
- - !ruby/object:Gem::Version
182
- version: '0.9'
183
- - - ">="
184
- - !ruby/object:Gem::Version
185
- version: 0.9.12
65
+ version: '4.0'
186
66
  description: 'Signet is an OAuth 1.0 / OAuth 2.0 implementation.
187
67
 
188
68
  '
189
- email: sbazyl@google.com
69
+ email:
70
+ - googleapis-packages@google.com
190
71
  executables: []
191
72
  extensions: []
192
73
  extra_rdoc_files:
@@ -217,7 +98,6 @@ metadata:
217
98
  changelog_uri: https://github.com/googleapis/signet/blob/main/CHANGELOG.md
218
99
  source_code_uri: https://github.com/googleapis/signet
219
100
  bug_tracker_uri: https://github.com/googleapis/signet/issues
220
- post_install_message:
221
101
  rdoc_options:
222
102
  - "--main"
223
103
  - README.md
@@ -227,15 +107,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
227
107
  requirements:
228
108
  - - ">="
229
109
  - !ruby/object:Gem::Version
230
- version: '2.7'
110
+ version: '3.2'
231
111
  required_rubygems_version: !ruby/object:Gem::Requirement
232
112
  requirements:
233
113
  - - ">="
234
114
  - !ruby/object:Gem::Version
235
115
  version: 1.3.5
236
116
  requirements: []
237
- rubygems_version: 3.5.3
238
- signing_key:
117
+ rubygems_version: 3.6.9
239
118
  specification_version: 4
240
119
  summary: Signet is an OAuth 1.0 / OAuth 2.0 implementation.
241
120
  test_files: []