googleauth 1.17.1 → 1.17.3

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: 65760a71937d92e7ac7645084b04fa503e9e824ce4cdde626013e1e5b218d1ff
4
- data.tar.gz: 735c54698d8ac9f2419b4b2b5d0525d079d799fb06cdcef10ea8a7bb76f7e5a9
3
+ metadata.gz: 7c73c744b267dbdafe6b4b3366fe629ca7f86774c6c56726b108f38ac3593ee7
4
+ data.tar.gz: 2b5b379d5e8bc653a52d6dccb56b500904368a09955a3fe914efad7cf18147ce
5
5
  SHA512:
6
- metadata.gz: 58a86a3662c68bdabfbb96f12066c6d24ecc8aa1a4927e9be89578269001d5d64010340bb98285e5e6717c30b0d7b118d3b07dd631581db6b668934f6074117f
7
- data.tar.gz: 41e44fdbe1863fe39bed931e07948ddbeaa6c627a7f7d28a4f43591e6b281898d7bf6afdeb76d06ad4668297028a374ba936d29785c0c544ba853fbadc8aaf2c
6
+ metadata.gz: 378ad3d1c7acb1118491dc2896f9983119197f888a8cf610998734cb48495dc2651d4cbb217eee46b10958cc9417cb06db790ca3a8ff52b5dcf9b6ba99fc24ce
7
+ data.tar.gz: a7461765f075d468e2cc4cd8b237c82c3a0a140739bcec81ca452b9d5c633af4c8e7bf21acd099a4d713a20afbaf4ca7468868a16ca1d167939054b903ceca9b
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Release History
2
2
 
3
+ ### 1.17.3 (2026-07-27)
4
+
5
+ #### Bug Fixes
6
+
7
+ * Add option validation and error handling to ServiceAccountCredentials.make_creds ([#588](https://github.com/googleapis/google-auth-library-ruby/issues/588)) ([3da9927](https://github.com/googleapis/google-auth-library-ruby/commit/3da9927091e3ffc4f2d062a404d837de962a6f97)), refs [#482](https://github.com/googleapis/google-auth-library-ruby/issues/482) [#544](https://github.com/googleapis/google-auth-library-ruby/issues/544)
8
+
9
+ ### 1.17.2 (2026-07-23)
10
+
11
+ #### Bug Fixes
12
+
13
+ * return auth header from source_credentials in ImpersonatedServiceAccountCredentials ([#586](https://github.com/googleapis/google-auth-library-ruby/issues/586))
14
+
3
15
  ### 1.17.1 (2026-06-08)
4
16
 
5
17
  #### Bug Fixes
data/README.md CHANGED
@@ -265,7 +265,7 @@ Custom storage implementations can also be used. See
265
265
 
266
266
  ## Supported Ruby Versions
267
267
 
268
- This library is supported on Ruby 3.0+.
268
+ This library is supported on Ruby 3.2+.
269
269
 
270
270
  Google provides official support for Ruby versions that are actively supported
271
271
  by Ruby Core—that is, Ruby versions that are either in normal maintenance or
@@ -135,13 +135,13 @@ module Google
135
135
  rsa_key.public_key
136
136
  end
137
137
 
138
- # @private
139
138
  CURVE_NAME_MAP = {
140
139
  "P-256" => "prime256v1",
141
140
  "P-384" => "secp384r1",
142
141
  "P-521" => "secp521r1",
143
142
  "secp256k1" => "secp256k1"
144
143
  }.freeze
144
+ private_constant :CURVE_NAME_MAP
145
145
 
146
146
  def extract_ec_key jwk
147
147
  begin
@@ -109,13 +109,13 @@ module Google
109
109
  payload["azp"] ||= payload["cid"] if payload.key? "cid"
110
110
 
111
111
  # Payload content validation
112
- if aud && (Array(aud) & Array(payload["aud"])).empty?
112
+ if aud && !Array(aud).intersect?(Array(payload["aud"]))
113
113
  raise AudienceMismatchError, "Token aud mismatch: #{payload['aud']}"
114
114
  end
115
- if azp && (Array(azp) & Array(payload["azp"])).empty?
115
+ if azp && !Array(azp).intersect?(Array(payload["azp"]))
116
116
  raise AuthorizedPartyMismatchError, "Token azp mismatch: #{payload['azp']}"
117
117
  end
118
- if iss && (Array(iss) & Array(payload["iss"])).empty?
118
+ if iss && !Array(iss).intersect?(Array(payload["iss"]))
119
119
  raise IssuerMismatchError, "Token iss mismatch: #{payload['iss']}"
120
120
  end
121
121
 
@@ -297,9 +297,9 @@ module Google
297
297
  # @private
298
298
  # @return [Hash] The authorization header with the source credentials' token
299
299
  def prepare_auth_header
300
- auth_header = {}
301
- @source_credentials.updater_proc.call auth_header
302
- auth_header
300
+ # updater_proc returns a new hash containing authorization headers
301
+ # rather than mutating the passed hash in place.
302
+ @source_credentials.updater_proc.call({})
303
303
  end
304
304
 
305
305
  # Makes the HTTP request to the impersonation endpoint.
@@ -45,6 +45,19 @@ module Google
45
45
  # @type [::String] The type name for this credential.
46
46
  CREDENTIAL_TYPE_NAME = "service_account".freeze
47
47
 
48
+ # @private
49
+ # @type [Array<Symbol>] Allowed option keys for make_creds.
50
+ VALID_MAKE_CREDS_OPTIONS = [
51
+ :json_key_io,
52
+ :scope,
53
+ :enable_self_signed_jwt,
54
+ :target_audience,
55
+ :audience,
56
+ :token_credential_uri,
57
+ :default_connection,
58
+ :connection_builder
59
+ ].freeze
60
+
48
61
  def enable_self_signed_jwt?
49
62
  # Use a self-singed JWT if there's no information that can be used to
50
63
  # obtain an OAuth token, OR if there are scopes but also an assertion
@@ -55,10 +68,20 @@ module Google
55
68
 
56
69
  # Creates a ServiceAccountCredentials.
57
70
  #
58
- # @param json_key_io [IO] An IO object containing the JSON key
59
- # @param scope [string|array|nil] the scope(s) to access
71
+ # @param json_key_io [IO, nil] Optional. An IO object containing the JSON key
72
+ # @param scope [String, Array<String>, nil] Optional. The scope(s) to access
73
+ # @param enable_self_signed_jwt [Boolean, nil] Optional. Whether to use self-signed JWTs
74
+ # @param target_audience [String, nil] Optional. The target audience for ID token requests
75
+ # @param audience [String, nil] Optional. Custom token endpoint audience URI
76
+ # @param token_credential_uri [String, nil] Optional. Custom token credential URI
77
+ # @param default_connection [Faraday::Connection, nil] Optional. The connection object to use
78
+ # @param connection_builder [Proc, nil] Optional. A Proc that returns a Faraday connection
60
79
  # @raise [ArgumentError] If both scope and target_audience are specified
80
+ # @raise [InitializationError] If json_key_io is not an IO object, or
81
+ # if required credential fields (private_key or client_email) are missing
61
82
  def self.make_creds options = {} # rubocop:disable Metrics/MethodLength
83
+ validate_make_creds_options options
84
+
62
85
  json_key_io, scope, enable_self_signed_jwt, target_audience, audience, token_credential_uri =
63
86
  options.values_at :json_key_io, :scope, :enable_self_signed_jwt, :target_audience,
64
87
  :audience, :token_credential_uri
@@ -66,6 +89,9 @@ module Google
66
89
 
67
90
  private_key, client_email, project_id, quota_project_id, universe_domain =
68
91
  if json_key_io
92
+ unless json_key_io.respond_to? :read
93
+ raise InitializationError, "Expected an IO object for json_key_io"
94
+ end
69
95
  json_key = JSON.parse json_key_io.read
70
96
  if json_key.key? "type"
71
97
  json_key_io.rewind
@@ -78,6 +104,10 @@ module Google
78
104
  else
79
105
  creds_from_env
80
106
  end
107
+
108
+ raise InitializationError, "Missing required field: private_key" unless private_key
109
+ raise InitializationError, "Missing required field: client_email" unless client_email
110
+
81
111
  project_id ||= CredentialsLoader.load_gcloud_project_id
82
112
 
83
113
  new(token_credential_uri: token_credential_uri || TOKEN_CRED_URI,
@@ -122,8 +152,9 @@ module Google
122
152
  # enclosing quotes.
123
153
  #
124
154
  # @param str [String] The string to unescape
125
- # @return [String] The unescaped string
155
+ # @return [String, nil] The unescaped string, or nil if input is nil
126
156
  def self.unescape str
157
+ return nil unless str
127
158
  str = str.gsub '\n', "\n"
128
159
  str = str[1..-2] if str.start_with?('"') && str.end_with?('"')
129
160
  str
@@ -212,7 +243,20 @@ module Google
212
243
  [private_key, client_email, project_id, nil, nil]
213
244
  end
214
245
 
215
- private_class_method :creds_from_env
246
+ # @private
247
+ # Validates options passed to make_creds and emits a warning for unrecognized keys.
248
+ #
249
+ # @param options [Hash] The options hash to validate.
250
+ def self.validate_make_creds_options options
251
+ return unless options.is_a? Hash
252
+
253
+ unknown_keys = options.keys - VALID_MAKE_CREDS_OPTIONS
254
+ return if unknown_keys.empty?
255
+
256
+ warn "Unrecognized option(s) for ServiceAccountCredentials.make_creds: #{unknown_keys.map(&:inspect).join ', '}"
257
+ end
258
+
259
+ private_class_method :creds_from_env, :validate_make_creds_options
216
260
  end
217
261
  end
218
262
  end
@@ -16,6 +16,6 @@ module Google
16
16
  # Module Auth provides classes that provide Google-specific authorization
17
17
  # used to access Google APIs.
18
18
  module Auth
19
- VERSION = "1.17.1".freeze
19
+ VERSION = "1.17.3".freeze
20
20
  end
21
21
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: googleauth
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.17.1
4
+ version: 1.17.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Google LLC
@@ -198,7 +198,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
198
198
  requirements:
199
199
  - - ">="
200
200
  - !ruby/object:Gem::Version
201
- version: '3.0'
201
+ version: '3.2'
202
202
  required_rubygems_version: !ruby/object:Gem::Requirement
203
203
  requirements:
204
204
  - - ">="