googleauth-extras 0.4.0 → 0.6.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: 29ad90b986d4915e183e4592f58eedff84badd6ee70900337981d3173f0c64b2
4
- data.tar.gz: 0c69256ea700526a9891d9434338954fec778d99b6f3c927654739dd690f03dd
3
+ metadata.gz: 29022ef0b3431bad2d9e5833e3af8a5333307a60610b176d92e571d5aee59aeb
4
+ data.tar.gz: ce7ee1a8121b2b6781879bef17908190575fb3f3d0ce7e7eda8023d3a29a3463
5
5
  SHA512:
6
- metadata.gz: 9b3de1122f1a208f337134b30023fef63eb171c5ad3c888a8cc0cb81bc72aa5ae0d476f1c22ff659d4ce4637795ffff5ae1a5e07eee64dd68f9a5f887e9f02bb
7
- data.tar.gz: 7eb79ba62b30a7b7a5cc2bab1d00f1079d19f57fd99df98ad52fec2d46d5e77eae781ddb50960c1832e77462e6b2e9d4c729e860db25610b2014432df6505f0d
6
+ metadata.gz: 3cc8272a821cd99f51d2cc4de7f9979c42078aad8ddcaeafbec4523987aeebacd77947c86758851b6e1cfb18b13c6393cdffefe27dd629ae7c587c993f22e8cb
7
+ data.tar.gz: 3c6a26d85df2064d473f8ec8847f638a669ece26aeff38d7ad6f5ee918b5746da7882afd3331f3bb4686cafc88c3b2d5f38742008caa3df7c40992b9cc133b20
@@ -14,10 +14,10 @@ jobs:
14
14
  fail-fast: false
15
15
  matrix:
16
16
  ruby:
17
- - '2.7'
18
- - '3.0'
19
17
  - '3.1'
20
18
  - '3.2'
19
+ - '3.3'
20
+ - '3.4'
21
21
  runs-on: ubuntu-latest
22
22
  steps:
23
23
  - uses: actions/checkout@v3
data/.rubocop.yml CHANGED
@@ -25,6 +25,9 @@ Metrics/CyclomaticComplexity:
25
25
  Metrics/MethodLength:
26
26
  Max: 30
27
27
 
28
+ Metrics/ModuleLength:
29
+ Max: 125
30
+
28
31
  Metrics/ParameterLists:
29
32
  Enabled: false
30
33
 
data/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # Release History
2
2
 
3
+ 0.6.0
4
+ ----------
5
+
6
+ - Support setting the universe domain (defaults to googleapis.com) so gRPC google-cloud clients don't raise Gapic::UniverseDomainMismatch.
7
+ - drop `addressable` as a transitive dependency, replace with stdlib `uri`.
8
+ - drop `faraday` as a transitive dependency, replace with stdlib `net-http`.
9
+ - Bump minimum supported `googleauth` version which allows removing the identity credentials refresh patch (which has been fixed upstream).
10
+ - Clamp supported `signet` to `< 1` instead (no API regressions expected).
11
+
12
+ 0.5.0
13
+ ----------
14
+
15
+ - Support signed JWT credentials. ([#14](https://github.com/persona-id/googleauth-extras/pull/14))
16
+
17
+ - Drop support for Ruby 2.7 & 3.0, update test dependencies. ([#15](https://github.com/persona-id/googleauth-extras/pull/15))
18
+
3
19
  0.4.0
4
20
  ----------
5
21
 
data/Gemfile CHANGED
@@ -5,12 +5,12 @@ source 'https://rubygems.org'
5
5
  # Specify your gem's dependencies in googleauth-extras.gemspec
6
6
  gemspec
7
7
 
8
- gem 'google-cloud-storage', '~> 1.44'
8
+ gem 'google-cloud-storage', '~> 1.55'
9
9
 
10
- gem 'pry-byebug', '~> 3.10'
11
- gem 'rake', '~> 12.0'
12
- gem 'rspec', '~> 3.0'
13
- gem 'rubocop', '~> 1.45'
14
- gem 'rubocop-rspec', '~> 2.18'
15
- gem 'timecop', '~> 0.9.6'
16
- gem 'webmock', '~> 3.18'
10
+ gem 'pry-byebug', '~> 3.11'
11
+ gem 'rake', '~> 13.2'
12
+ gem 'rspec', '~> 3.13'
13
+ gem 'rubocop', '~> 1.75'
14
+ gem 'rubocop-rspec', '~> 3.5'
15
+ gem 'timecop', '~> 0.9.10'
16
+ gem 'webmock', '~> 3.25'
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
12
12
  spec.homepage = 'https://github.com/persona-id/googleauth-extras'
13
13
  spec.license = 'MIT'
14
14
 
15
- spec.required_ruby_version = Gem::Requirement.new('>= 2.7.0')
15
+ spec.required_ruby_version = Gem::Requirement.new('>= 3.1.0')
16
16
 
17
17
  spec.metadata['allowed_push_host'] = 'https://rubygems.org'
18
18
  spec.metadata['rubygems_mfa_required'] = 'true'
@@ -30,9 +30,7 @@ Gem::Specification.new do |spec|
30
30
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
31
  spec.require_paths = ['lib']
32
32
 
33
- spec.add_dependency 'addressable', '~> 2.8'
34
- spec.add_dependency 'faraday', '>= 1.0', '< 3.0'
35
33
  spec.add_dependency 'google-apis-iamcredentials_v1'
36
- spec.add_dependency 'googleauth', '~> 1.3'
37
- spec.add_dependency 'signet', '>= 0.17.0', '< 0.19.0'
34
+ spec.add_dependency 'googleauth', '~> 1.11', '>= 1.11.1'
35
+ spec.add_dependency 'signet', '>= 0.17.0', '< 1'
38
36
  end
@@ -5,8 +5,6 @@ module Google
5
5
  module Extras
6
6
  # This credential impersonates a service account.
7
7
  class ImpersonatedCredential < Signet::OAuth2::Client
8
- include IdentityCredentialRefreshPatch
9
-
10
8
  attr_reader :quota_project_id
11
9
 
12
10
  # A credential that impersonates a service account.
@@ -49,6 +47,10 @@ module Google
49
47
  # @param target_audience [String]
50
48
  # The audience for the token, such as the API or account that this token grants access to.
51
49
  #
50
+ # @param universe_domain [String]
51
+ # The universe domain of the credential, reported to gRPC google-cloud clients so they
52
+ # don't raise Gapic::UniverseDomainMismatch. Defaults to googleapis.com.
53
+ #
52
54
  # @see https://cloud.google.com/iam/docs/reference/credentials/rest/v1/projects.serviceAccounts/generateAccessToken
53
55
  # @see https://cloud.google.com/iam/docs/reference/credentials/rest/v1/projects.serviceAccounts/generateIdToken
54
56
  # @see https://cloud.google.com/iam/docs/create-short-lived-credentials-delegated#sa-credentials-permissions
@@ -62,9 +64,15 @@ module Google
62
64
  lifetime: nil,
63
65
  quota_project_id: nil,
64
66
  scope: nil,
65
- target_audience: nil
67
+ target_audience: nil,
68
+ universe_domain: 'googleapis.com'
66
69
  )
67
- super(client_id: target_audience, scope: scope, target_audience: target_audience)
70
+ super(
71
+ client_id: target_audience,
72
+ scope: scope,
73
+ target_audience: target_audience,
74
+ universe_domain: base_credentials&.universe_domain || universe_domain,
75
+ )
68
76
 
69
77
  if self.target_audience.nil? || self.target_audience.empty?
70
78
  raise(ArgumentError, 'Must provide scope or target_audience') if self.scope.nil? || self.scope.empty?
@@ -0,0 +1,117 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Google
4
+ module Auth
5
+ module Extras
6
+ # This credential issues JWTs signed a service account.
7
+ class ServiceAccountJWTCredential < Signet::OAuth2::Client
8
+ # A credential that obtains a signed JWT from Google for a service account.
9
+ #
10
+ # @param base_credentials [Hash, String, Signet::OAuth2::Client]
11
+ # Credentials to use to sign the JWTs.
12
+ #
13
+ # @param delegate_email_addresses [String, Array<String>]
14
+ # The email addresses (if any) of intermediate service accounts to reach
15
+ # the +email_address+ from +base_credentials+.
16
+ #
17
+ # @param email_address [String]
18
+ # Email of the service account to sign the JWT.
19
+ #
20
+ # @param issuer [String]
21
+ # The desired value of the iss field on the issued JWT. Defaults to the email_address.
22
+ #
23
+ # @param lifetime [Integers]
24
+ # The desired lifetime (in seconds) of the JWT before needing to be refreshed.
25
+ # Defaults to 3600 (1h), adjust as needed given a refresh is automatically
26
+ # performed when the token less than 60s of remaining life and refresh requires
27
+ # an additional API call.
28
+ #
29
+ # @param subject [String]
30
+ # The desired value of the sub field on the issued JWT. Defaults to the email_address.
31
+ #
32
+ # @param target_audience [String]
33
+ # The audience for the token, such as the API or account that this token grants access to.
34
+ #
35
+ # @param universe_domain [String]
36
+ # The universe domain of the credential, reported to gRPC google-cloud clients so they
37
+ # don't raise Gapic::UniverseDomainMismatch. Defaults to googleapis.com.
38
+ #
39
+ # @see https://cloud.google.com/iam/docs/reference/credentials/rest/v1/projects.serviceAccounts/signJwt
40
+ # @see https://cloud.google.com/iam/docs/create-short-lived-credentials-delegated#sa-credentials-permissions
41
+ #
42
+ def initialize(
43
+ email_address:,
44
+ target_audience:,
45
+ base_credentials: nil,
46
+ delegate_email_addresses: nil,
47
+ issuer: nil,
48
+ lifetime: 3600,
49
+ subject: nil,
50
+ universe_domain: 'googleapis.com'
51
+ )
52
+ super(
53
+ client_id: target_audience,
54
+ target_audience: target_audience,
55
+ universe_domain: base_credentials&.universe_domain || universe_domain,
56
+ )
57
+
58
+ @iam_credentials_service = Google::Apis::IamcredentialsV1::IAMCredentialsService.new.tap do |ics|
59
+ ics.authorization = base_credentials if base_credentials
60
+ end
61
+
62
+ @jwt_issuer = issuer || email_address
63
+ @jwt_lifetime = lifetime
64
+ @jwt_subject = subject || email_address
65
+
66
+ @sa_delegates = Array(delegate_email_addresses).map do |email|
67
+ transform_email_to_name(email)
68
+ end
69
+
70
+ @sa_name = transform_email_to_name(email_address)
71
+ end
72
+
73
+ def fetch_access_token(*)
74
+ now = Time.now.to_i
75
+
76
+ request = Google::Apis::IamcredentialsV1::SignJwtRequest.new(
77
+ payload: JSON.dump(
78
+ aud: target_audience,
79
+ exp: now + @jwt_lifetime,
80
+ iat: now,
81
+ iss: @jwt_issuer,
82
+ sub: @jwt_subject,
83
+ ),
84
+ )
85
+
86
+ # The Google SDK doesn't like nil repeated values, but be careful with others as well.
87
+ request.delegates = @sa_delegates unless @sa_delegates.empty?
88
+
89
+ response = @iam_credentials_service.sign_service_account_jwt(@sa_name, request)
90
+
91
+ {
92
+ id_token: response.signed_jwt,
93
+ }
94
+ end
95
+
96
+ def inspect
97
+ "#<#{self.class.name}" \
98
+ " @expires_at=#{expires_at.inspect}" \
99
+ " @id_token=#{@id_token ? '[REDACTED]' : 'nil'}" \
100
+ " @jwt_issuer=#{@jwt_issuer.inspect}" \
101
+ " @jwt_lifetime=#{@jwt_lifetime.inspect}" \
102
+ " @jwt_subject=#{@jwt_subject.inspect}" \
103
+ " @sa_delegates=#{@sa_delegates.inspect}" \
104
+ " @sa_name=#{@sa_name.inspect}" \
105
+ " @target_audience=#{@target_audience.inspect}" \
106
+ '>'
107
+ end
108
+
109
+ private
110
+
111
+ def transform_email_to_name(email)
112
+ "projects/-/serviceAccounts/#{email}"
113
+ end
114
+ end
115
+ end
116
+ end
117
+ end
@@ -18,11 +18,16 @@ module Google
18
18
  # The project ID used for quota and billing. This project may be different from
19
19
  # the project used to create the credentials.
20
20
  #
21
- def initialize(access_token:, quota_project_id: nil)
21
+ # @param universe_domain [String]
22
+ # The universe domain of the credential, reported to gRPC google-cloud clients so they
23
+ # don't raise Gapic::UniverseDomainMismatch. Defaults to googleapis.com.
24
+ #
25
+ def initialize(access_token:, quota_project_id: nil, universe_domain: 'googleapis.com')
22
26
  super(
23
27
  access_token: access_token,
24
28
  expires_at: TokenInfo.lookup_access_token(access_token).fetch('exp'),
25
29
  issued_at: nil,
30
+ universe_domain: universe_domain,
26
31
  )
27
32
 
28
33
  @quota_project_id = quota_project_id
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'uri'
4
+
3
5
  module Google
4
6
  module Auth
5
7
  module Extras
@@ -11,7 +13,7 @@ module Google
11
13
  class LookupFailed < StandardError; end
12
14
  class LookupMalformed < LookupFailed; end
13
15
 
14
- TOKEN_INFO_URI = 'https://oauth2.googleapis.com/tokeninfo'
16
+ TOKEN_INFO_URI = URI('https://oauth2.googleapis.com/tokeninfo')
15
17
  private_constant :TOKEN_INFO_URI
16
18
 
17
19
  # Lookup the details for a valid access token, including it's expiration.
@@ -30,14 +32,14 @@ module Google
30
32
  private
31
33
 
32
34
  def lookup(query)
33
- url = Addressable::URI.parse(TOKEN_INFO_URI)
34
- url.query_values = query
35
+ query_string = URI.encode_www_form(query)
36
+ uri = TOKEN_INFO_URI.merge("?#{query_string}")
35
37
 
36
- response = Faraday.default_connection.get(url.normalize.to_s)
38
+ response = Net::HTTP.get_response(uri)
37
39
 
38
- raise LookupFailed, response.body.to_s unless response.status == 200
40
+ raise LookupFailed, response.body unless response.is_a?(Net::HTTPSuccess)
39
41
 
40
- credentials = Signet::OAuth2.parse_credentials(response.body, response.headers['Content-Type'])
42
+ credentials = Signet::OAuth2.parse_credentials(response.body, response['Content-Type'])
41
43
 
42
44
  raise LookupMalformed, 'Missing token expiry' unless credentials['exp']
43
45
 
@@ -3,7 +3,7 @@
3
3
  module Google
4
4
  module Auth
5
5
  module Extras
6
- VERSION = '0.4.0'
6
+ VERSION = '0.6.0'
7
7
  end
8
8
  end
9
9
  end
@@ -4,8 +4,8 @@ require 'date'
4
4
  require 'google/apis/iamcredentials_v1'
5
5
  require 'signet/oauth_2/client'
6
6
 
7
- require 'google/auth/extras/identity_credential_refresh_patch'
8
7
  require 'google/auth/extras/impersonated_credential'
8
+ require 'google/auth/extras/service_account_jwt_credential'
9
9
  require 'google/auth/extras/static_credential'
10
10
  require 'google/auth/extras/token_info'
11
11
  require 'google/auth/extras/version'
@@ -58,6 +58,10 @@ module Google
58
58
  # The OAuth 2 scopes to request. Can either be formatted as a comma seperated string or array.
59
59
  # Only supported when not using a target_audience.
60
60
  #
61
+ # @param universe_domain [String]
62
+ # The universe domain of the credential, reported to gRPC google-cloud clients so they
63
+ # don't raise Gapic::UniverseDomainMismatch. Defaults to googleapis.com.
64
+ #
61
65
  # @return [Google::Auth::Extras::ImpersonatedCredential]
62
66
  #
63
67
  # @see https://cloud.google.com/iam/docs/reference/credentials/rest/v1/projects.serviceAccounts/generateAccessToken
@@ -73,7 +77,8 @@ module Google
73
77
  lifetime: nil,
74
78
  quota_project_id: nil,
75
79
  scope: nil,
76
- target_audience: nil
80
+ target_audience: nil,
81
+ universe_domain: 'googleapis.com'
77
82
  )
78
83
  ImpersonatedCredential.new(
79
84
  base_credentials: base_credentials,
@@ -84,6 +89,7 @@ module Google
84
89
  quota_project_id: quota_project_id,
85
90
  scope: scope,
86
91
  target_audience: target_audience,
92
+ universe_domain: universe_domain,
87
93
  )
88
94
  end
89
95
 
@@ -120,6 +126,10 @@ module Google
120
126
  # The OAuth 2 scopes to request. Can either be formatted as a comma seperated string or array.
121
127
  # Only supported when not using a target_audience.
122
128
  #
129
+ # @param universe_domain [String]
130
+ # The universe domain of the credential, reported to gRPC google-cloud clients so they
131
+ # don't raise Gapic::UniverseDomainMismatch. Defaults to googleapis.com.
132
+ #
123
133
  # @return [Google::Auth::Credential<Google::Auth::Extras::ImpersonatedCredential>]
124
134
  #
125
135
  # @see https://cloud.google.com/iam/docs/reference/credentials/rest/v1/projects.serviceAccounts/generateAccessToken
@@ -135,7 +145,8 @@ module Google
135
145
  lifetime: nil,
136
146
  quota_project_id: nil,
137
147
  scope: nil,
138
- target_audience: nil
148
+ target_audience: nil,
149
+ universe_domain: 'googleapis.com'
139
150
  )
140
151
  wrap_authorization(
141
152
  impersonated_authorization(
@@ -147,6 +158,129 @@ module Google
147
158
  quota_project_id: quota_project_id,
148
159
  scope: scope,
149
160
  target_audience: target_audience,
161
+ universe_domain: universe_domain,
162
+ ),
163
+ )
164
+ end
165
+
166
+ # A credential that obtains a signed JWT from Google for a service account.
167
+ # For usage with the older style GCP Ruby SDKs from the google-apis-* gems.
168
+ # Also useful for calling IAP-protected endpoints using the Google-managed
169
+ # OAuth client.
170
+ #
171
+ # @param base_credentials [Hash, String, Signet::OAuth2::Client]
172
+ # Credentials to use to sign the JWTs.
173
+ #
174
+ # @param delegate_email_addresses [String, Array<String>]
175
+ # The email addresses (if any) of intermediate service accounts to reach
176
+ # the +email_address+ from +base_credentials+.
177
+ #
178
+ # @param email_address [String]
179
+ # Email of the service account to sign the JWT.
180
+ #
181
+ # @param issuer [String]
182
+ # The desired value of the iss field on the issued JWT. Defaults to the email_address.
183
+ #
184
+ # @param lifetime [Integers]
185
+ # The desired lifetime (in seconds) of the JWT before needing to be refreshed.
186
+ # Defaults to 3600 (1h), adjust as needed given a refresh is automatically
187
+ # performed when the token less than 60s of remaining life and refresh requires
188
+ # an additional API call.
189
+ #
190
+ # @param subject [String]
191
+ # The desired value of the sub field on the issued JWT. Defaults to the email_address.
192
+ #
193
+ # @param target_audience [String]
194
+ # The audience for the token, such as the API or account that this token grants access to.
195
+ #
196
+ # @param universe_domain [String]
197
+ # The universe domain of the credential, reported to gRPC google-cloud clients so they
198
+ # don't raise Gapic::UniverseDomainMismatch. Defaults to googleapis.com.
199
+ #
200
+ # @return [Google::Auth::Extras::ServiceAccountJWTCredential]
201
+ #
202
+ # @see https://cloud.google.com/iam/docs/reference/credentials/rest/v1/projects.serviceAccounts/signJwt
203
+ # @see https://cloud.google.com/iam/docs/create-short-lived-credentials-delegated#sa-credentials-permissions
204
+ #
205
+ def service_account_jwt_authorization(
206
+ email_address:,
207
+ target_audience:,
208
+ base_credentials: nil,
209
+ delegate_email_addresses: nil,
210
+ issuer: nil,
211
+ lifetime: 3600,
212
+ subject: nil,
213
+ universe_domain: 'googleapis.com'
214
+ )
215
+ ServiceAccountJWTCredential.new(
216
+ base_credentials: base_credentials,
217
+ delegate_email_addresses: delegate_email_addresses,
218
+ email_address: email_address,
219
+ issuer: issuer,
220
+ lifetime: lifetime,
221
+ subject: subject,
222
+ target_audience: target_audience,
223
+ universe_domain: universe_domain,
224
+ )
225
+ end
226
+
227
+ # A credential that obtains a signed JWT from Google for a service account.
228
+ # For usage with the newer style GCP Ruby SDKs from the google-cloud-* gems.
229
+ #
230
+ # @param base_credentials [Hash, String, Signet::OAuth2::Client]
231
+ # Credentials to use to sign the JWTs.
232
+ #
233
+ # @param delegate_email_addresses [String, Array<String>]
234
+ # The email addresses (if any) of intermediate service accounts to reach
235
+ # the +email_address+ from +base_credentials+.
236
+ #
237
+ # @param email_address [String]
238
+ # Email of the service account to sign the JWT.
239
+ #
240
+ # @param issuer [String]
241
+ # The desired value of the iss field on the issued JWT. Defaults to the email_address.
242
+ #
243
+ # @param lifetime [Integers]
244
+ # The desired lifetime (in seconds) of the JWT before needing to be refreshed.
245
+ # Defaults to 3600 (1h), adjust as needed given a refresh is automatically
246
+ # performed when the token less than 60s of remaining life and refresh requires
247
+ # an additional API call.
248
+ #
249
+ # @param subject [String]
250
+ # The desired value of the sub field on the issued JWT. Defaults to the email_address.
251
+ #
252
+ # @param target_audience [String]
253
+ # The audience for the token, such as the API or account that this token grants access to.
254
+ #
255
+ # @param universe_domain [String]
256
+ # The universe domain of the credential, reported to gRPC google-cloud clients so they
257
+ # don't raise Gapic::UniverseDomainMismatch. Defaults to googleapis.com.
258
+ #
259
+ # @return [Google::Auth::Extras::ServiceAccountJWTCredential]
260
+ #
261
+ # @see https://cloud.google.com/iam/docs/reference/credentials/rest/v1/projects.serviceAccounts/signJwt
262
+ # @see https://cloud.google.com/iam/docs/create-short-lived-credentials-delegated#sa-credentials-permissions
263
+ #
264
+ def service_account_jwt_credential(
265
+ email_address:,
266
+ target_audience:,
267
+ base_credentials: nil,
268
+ delegate_email_addresses: nil,
269
+ issuer: nil,
270
+ lifetime: 3600,
271
+ subject: nil,
272
+ universe_domain: 'googleapis.com'
273
+ )
274
+ wrap_authorization(
275
+ service_account_jwt_authorization(
276
+ base_credentials: base_credentials,
277
+ delegate_email_addresses: delegate_email_addresses,
278
+ email_address: email_address,
279
+ issuer: issuer,
280
+ lifetime: lifetime,
281
+ subject: subject,
282
+ target_audience: target_audience,
283
+ universe_domain: universe_domain,
150
284
  ),
151
285
  )
152
286
  end
@@ -161,11 +295,14 @@ module Google
161
295
  # The project ID used for quota and billing. This project may be different from
162
296
  # the project used to create the credentials.
163
297
  #
298
+ # @param universe_domain [String]
299
+ # The universe domain of the credential, reported to gRPC google-cloud clients so they
300
+ # don't raise Gapic::UniverseDomainMismatch. Defaults to googleapis.com.
164
301
  #
165
302
  # @return [Google::Auth::Extras::StaticCredential]
166
303
  #
167
- def static_authorization(token, quota_project_id: nil)
168
- StaticCredential.new(access_token: token, quota_project_id: quota_project_id)
304
+ def static_authorization(token, quota_project_id: nil, universe_domain: 'googleapis.com')
305
+ StaticCredential.new(access_token: token, quota_project_id: quota_project_id, universe_domain: universe_domain)
169
306
  end
170
307
 
171
308
  # A credential using a static access token. For usage with the newer
@@ -178,17 +315,25 @@ module Google
178
315
  # The project ID used for quota and billing. This project may be different from
179
316
  # the project used to create the credentials.
180
317
  #
318
+ # @param universe_domain [String]
319
+ # The universe domain of the credential, reported to gRPC google-cloud clients so they
320
+ # don't raise Gapic::UniverseDomainMismatch. Defaults to googleapis.com.
321
+ #
181
322
  # @return [Google::Auth::Credential<Google::Auth::Extras::StaticCredential>]
182
323
  #
183
- def static_credential(token, quota_project_id: nil)
184
- wrap_authorization(static_authorization(token, quota_project_id: quota_project_id))
324
+ def static_credential(token, quota_project_id: nil, universe_domain: 'googleapis.com')
325
+ wrap_authorization(
326
+ static_authorization(token, quota_project_id: quota_project_id, universe_domain: universe_domain),
327
+ )
185
328
  end
186
329
 
187
330
  # Take an authorization and turn it into a credential, primarily used
188
331
  # for setting up both the old and new style SDKs.
189
332
  #
190
333
  # @param client [Signet::OAuth2::Client]
191
- # Authorization credential to wrap.
334
+ # Authorization credential to wrap. The universe domain reported to gRPC google-cloud
335
+ # clients (so they don't raise Gapic::UniverseDomainMismatch) is taken from the client
336
+ # as-is; set it on the client before wrapping if needed.
192
337
  #
193
338
  # @return [Google::Auth::Credential]
194
339
  #
metadata CHANGED
@@ -1,49 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: googleauth-extras
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Persona Identities
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-08-06 00:00:00.000000000 Z
11
+ date: 2026-07-23 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: addressable
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '2.8'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '2.8'
27
- - !ruby/object:Gem::Dependency
28
- name: faraday
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '1.0'
34
- - - "<"
35
- - !ruby/object:Gem::Version
36
- version: '3.0'
37
- type: :runtime
38
- prerelease: false
39
- version_requirements: !ruby/object:Gem::Requirement
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- version: '1.0'
44
- - - "<"
45
- - !ruby/object:Gem::Version
46
- version: '3.0'
47
13
  - !ruby/object:Gem::Dependency
48
14
  name: google-apis-iamcredentials_v1
49
15
  requirement: !ruby/object:Gem::Requirement
@@ -64,14 +30,20 @@ dependencies:
64
30
  requirements:
65
31
  - - "~>"
66
32
  - !ruby/object:Gem::Version
67
- version: '1.3'
33
+ version: '1.11'
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: 1.11.1
68
37
  type: :runtime
69
38
  prerelease: false
70
39
  version_requirements: !ruby/object:Gem::Requirement
71
40
  requirements:
72
41
  - - "~>"
73
42
  - !ruby/object:Gem::Version
74
- version: '1.3'
43
+ version: '1.11'
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 1.11.1
75
47
  - !ruby/object:Gem::Dependency
76
48
  name: signet
77
49
  requirement: !ruby/object:Gem::Requirement
@@ -81,7 +53,7 @@ dependencies:
81
53
  version: 0.17.0
82
54
  - - "<"
83
55
  - !ruby/object:Gem::Version
84
- version: 0.19.0
56
+ version: '1'
85
57
  type: :runtime
86
58
  prerelease: false
87
59
  version_requirements: !ruby/object:Gem::Requirement
@@ -91,8 +63,8 @@ dependencies:
91
63
  version: 0.17.0
92
64
  - - "<"
93
65
  - !ruby/object:Gem::Version
94
- version: 0.19.0
95
- description:
66
+ version: '1'
67
+ description:
96
68
  email:
97
69
  - alex.coomans@withpersona.com
98
70
  executables: []
@@ -113,8 +85,8 @@ files:
113
85
  - bin/setup
114
86
  - googleauth-extras.gemspec
115
87
  - lib/google/auth/extras.rb
116
- - lib/google/auth/extras/identity_credential_refresh_patch.rb
117
88
  - lib/google/auth/extras/impersonated_credential.rb
89
+ - lib/google/auth/extras/service_account_jwt_credential.rb
118
90
  - lib/google/auth/extras/static_credential.rb
119
91
  - lib/google/auth/extras/token_info.rb
120
92
  - lib/google/auth/extras/version.rb
@@ -128,7 +100,7 @@ metadata:
128
100
  homepage_uri: https://github.com/persona-id/googleauth-extras
129
101
  source_code_uri: https://github.com/persona-id/googleauth-extras
130
102
  changelog_uri: https://github.com/persona-id/googleauth-extras/blob/main/CHANGELOG.md
131
- post_install_message:
103
+ post_install_message:
132
104
  rdoc_options: []
133
105
  require_paths:
134
106
  - lib
@@ -136,15 +108,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
136
108
  requirements:
137
109
  - - ">="
138
110
  - !ruby/object:Gem::Version
139
- version: 2.7.0
111
+ version: 3.1.0
140
112
  required_rubygems_version: !ruby/object:Gem::Requirement
141
113
  requirements:
142
114
  - - ">="
143
115
  - !ruby/object:Gem::Version
144
116
  version: '0'
145
117
  requirements: []
146
- rubygems_version: 3.4.10
147
- signing_key:
118
+ rubygems_version: 3.3.27
119
+ signing_key:
148
120
  specification_version: 4
149
121
  summary: Additions to the googleauth gem for unsupported authentication schemes.
150
122
  test_files: []
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Google
4
- module Auth
5
- module Extras
6
- # This module fixes an issue with ID tokens not automatically refreshing
7
- # because their expiration is encoded in the JWT.
8
- module IdentityCredentialRefreshPatch
9
- def update_token!(*)
10
- super.tap do
11
- self.expires_at = decoded_id_token['exp'] if id_token
12
- end
13
- end
14
- end
15
- end
16
- end
17
- end