googleauth 1.17.1 → 1.17.5
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 +24 -0
- data/README.md +19 -16
- data/lib/googleauth/id_tokens/key_sources.rb +1 -1
- data/lib/googleauth/id_tokens/verifier.rb +3 -3
- data/lib/googleauth/impersonated_service_account.rb +3 -3
- data/lib/googleauth/service_account.rb +48 -4
- data/lib/googleauth/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2623eeee7a1c3caa15a693a2324cb3af0680e2e96a5c7ebb8e886b0f575f4b46
|
|
4
|
+
data.tar.gz: 6e0dea85174b34430c4c4088cef587d898adb4784d32dcdade282f8013266296
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8bac89770eb6e181368150fcaac143ec95cb4f6e1a30fd69b44fef705fae56c50fa25c9db39098dd1c3321b47159bea3ddd26aa459505f4456db9e0006c03a69
|
|
7
|
+
data.tar.gz: 8924b3cebc81d2808f7de234299251bbba82d10db48eb84d0a29f7bf7ca8467705bdecf8f849e4d41b2b4d12343ee19669947d75d76cc78551aeb1ed1cc96387
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# Release History
|
|
2
2
|
|
|
3
|
+
### 1.17.5 (2026-10-13)
|
|
4
|
+
|
|
5
|
+
#### Documentation
|
|
6
|
+
|
|
7
|
+
* trigger a release to verify the new publishing pipeline ([#601](https://github.com/googleapis/google-auth-library-ruby/issues/601))
|
|
8
|
+
|
|
9
|
+
### 1.17.4 (2026-08-13)
|
|
10
|
+
|
|
11
|
+
#### Documentation
|
|
12
|
+
|
|
13
|
+
* Update CLI/installed app example to use loopback IP redirect ([#589](https://github.com/googleapis/google-auth-library-ruby/issues/589))
|
|
14
|
+
|
|
15
|
+
### 1.17.3 (2026-07-27)
|
|
16
|
+
|
|
17
|
+
#### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* 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)
|
|
20
|
+
|
|
21
|
+
### 1.17.2 (2026-07-23)
|
|
22
|
+
|
|
23
|
+
#### Bug Fixes
|
|
24
|
+
|
|
25
|
+
* return auth header from source_credentials in ImpersonatedServiceAccountCredentials ([#586](https://github.com/googleapis/google-auth-library-ruby/issues/586))
|
|
26
|
+
|
|
3
27
|
### 1.17.1 (2026-06-08)
|
|
4
28
|
|
|
5
29
|
#### Bug Fixes
|
data/README.md
CHANGED
|
@@ -145,30 +145,32 @@ get('/oauth2callback') do
|
|
|
145
145
|
end
|
|
146
146
|
```
|
|
147
147
|
|
|
148
|
-
### Example (Command Line)
|
|
148
|
+
### Example (Command Line / Installed App)
|
|
149
149
|
|
|
150
|
-
|
|
150
|
+
Command line and desktop applications should use the Loopback IP redirect flow (`http://localhost`) as recommended in the [OOB Migration Guide](https://developers.google.com/identity/protocols/oauth2/resources/oob-migration).
|
|
151
151
|
|
|
152
152
|
```ruby
|
|
153
|
-
require
|
|
154
|
-
require
|
|
153
|
+
require "googleauth"
|
|
154
|
+
require "googleauth/stores/file_token_store"
|
|
155
155
|
|
|
156
|
-
|
|
156
|
+
LOOPBACK_URI = "http://localhost"
|
|
157
157
|
|
|
158
|
-
scope =
|
|
159
|
-
client_id = Google::Auth::ClientId.from_file
|
|
160
|
-
token_store = Google::Auth::Stores::FileTokenStore.new
|
|
161
|
-
|
|
162
|
-
authorizer = Google::Auth::UserAuthorizer.new(client_id, scope, token_store)
|
|
158
|
+
scope = "https://www.googleapis.com/auth/drive"
|
|
159
|
+
client_id = Google::Auth::ClientId.from_file "/path/to/client_secrets.json"
|
|
160
|
+
token_store = Google::Auth::Stores::FileTokenStore.new file: "/path/to/tokens.yaml"
|
|
161
|
+
authorizer = Google::Auth::UserAuthorizer.new client_id, scope, token_store
|
|
163
162
|
|
|
164
|
-
user_id = ENV[
|
|
165
|
-
credentials = authorizer.get_credentials
|
|
163
|
+
user_id = ENV["USER"]
|
|
164
|
+
credentials = authorizer.get_credentials user_id
|
|
166
165
|
if credentials.nil?
|
|
167
|
-
url = authorizer.get_authorization_url
|
|
168
|
-
puts "Open
|
|
166
|
+
url = authorizer.get_authorization_url base_url: LOOPBACK_URI
|
|
167
|
+
puts "Open the following URL in your browser: #{url}"
|
|
168
|
+
puts "After authorizing, your browser will redirect to localhost with an authorization code."
|
|
169
|
+
puts "Enter the authorization code:"
|
|
169
170
|
code = gets
|
|
170
171
|
credentials = authorizer.get_and_store_credentials_from_code(
|
|
171
|
-
user_id: user_id, code: code, base_url:
|
|
172
|
+
user_id: user_id, code: code, base_url: LOOPBACK_URI
|
|
173
|
+
)
|
|
172
174
|
end
|
|
173
175
|
|
|
174
176
|
# OK to use credentials
|
|
@@ -265,7 +267,7 @@ Custom storage implementations can also be used. See
|
|
|
265
267
|
|
|
266
268
|
## Supported Ruby Versions
|
|
267
269
|
|
|
268
|
-
This library is supported on Ruby 3.
|
|
270
|
+
This library is supported on Ruby 3.2+.
|
|
269
271
|
|
|
270
272
|
Google provides official support for Ruby versions that are actively supported
|
|
271
273
|
by Ruby Core—that is, Ruby versions that are either in normal maintenance or
|
|
@@ -293,3 +295,4 @@ about the client or APIs on [StackOverflow](http://stackoverflow.com).
|
|
|
293
295
|
|
|
294
296
|
[application default credentials]: https://cloud.google.com/docs/authentication/provide-credentials-adc
|
|
295
297
|
[license]: https://github.com/googleapis/google-auth-library-ruby/tree/main/LICENSE
|
|
298
|
+
|
|
@@ -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 &&
|
|
112
|
+
if aud && !Array(aud).intersect?(Array(payload["aud"]))
|
|
113
113
|
raise AudienceMismatchError, "Token aud mismatch: #{payload['aud']}"
|
|
114
114
|
end
|
|
115
|
-
if azp &&
|
|
115
|
+
if azp && !Array(azp).intersect?(Array(payload["azp"]))
|
|
116
116
|
raise AuthorizedPartyMismatchError, "Token azp mismatch: #{payload['azp']}"
|
|
117
117
|
end
|
|
118
|
-
if iss &&
|
|
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
|
-
|
|
301
|
-
|
|
302
|
-
|
|
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 [
|
|
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
|
-
|
|
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
|
data/lib/googleauth/version.rb
CHANGED
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.
|
|
4
|
+
version: 1.17.5
|
|
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.
|
|
201
|
+
version: '3.2'
|
|
202
202
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
203
203
|
requirements:
|
|
204
204
|
- - ">="
|