googleauth-extras 0.3.0 → 0.4.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: 56aa20519132423c5f99a9c67fb011bdf44d575ccb60d7109abd0f2f6db17a09
4
- data.tar.gz: 6d63aaa0d4dce0256ee828233640f951af9a203a9bf56dc46640ad2994fbe05a
3
+ metadata.gz: 29ad90b986d4915e183e4592f58eedff84badd6ee70900337981d3173f0c64b2
4
+ data.tar.gz: 0c69256ea700526a9891d9434338954fec778d99b6f3c927654739dd690f03dd
5
5
  SHA512:
6
- metadata.gz: a8c1978e55c6d63353823bf771c49c6c94266963774c2db5b9eef32d23f625f5762b08f30e773f71ef897bf53f07840f9e039a5dada27bc6bf7427b17667e3c1
7
- data.tar.gz: 78b376acc7c4bfd48b0be54127761a4ef40ec02c28029e0de2d90526116a41f43d8cfe7029b5e877480c582fc9bb46b401f3aa2b8520bc8ce8668a866e523065
6
+ metadata.gz: 9b3de1122f1a208f337134b30023fef63eb171c5ad3c888a8cc0cb81bc72aa5ae0d476f1c22ff659d4ce4637795ffff5ae1a5e07eee64dd68f9a5f887e9f02bb
7
+ data.tar.gz: 7eb79ba62b30a7b7a5cc2bab1d00f1079d19f57fd99df98ad52fec2d46d5e77eae781ddb50960c1832e77462e6b2e9d4c729e860db25610b2014432df6505f0d
data/.rubocop.yml CHANGED
@@ -49,6 +49,9 @@ RSpec/MultipleMemoizedHelpers:
49
49
  RSpec/NamedSubject:
50
50
  Enabled: false
51
51
 
52
+ RSpec/NestedGroups:
53
+ Max: 5
54
+
52
55
  Style/ModuleFunction:
53
56
  EnforcedStyle: extend_self
54
57
 
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Release History
2
2
 
3
+ 0.4.0
4
+ ----------
5
+
6
+ - Support setting a quota project. ([#11](https://github.com/persona-id/googleauth-extras/pull/11))
7
+
8
+ - Update gemspec for new RuboCop settings. ([#12](https://github.com/persona-id/googleauth-extras/pull/12))
9
+
3
10
  0.3.0
4
11
  -----
5
12
 
@@ -30,9 +30,9 @@ 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_runtime_dependency 'addressable', '~> 2.8'
34
- spec.add_runtime_dependency 'faraday', '>= 1.0', '< 3.0'
35
- spec.add_runtime_dependency 'google-apis-iamcredentials_v1'
36
- spec.add_runtime_dependency 'googleauth', '~> 1.3'
37
- spec.add_runtime_dependency 'signet', '>= 0.17.0', '< 0.19.0'
33
+ spec.add_dependency 'addressable', '~> 2.8'
34
+ spec.add_dependency 'faraday', '>= 1.0', '< 3.0'
35
+ 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'
38
38
  end
@@ -7,6 +7,8 @@ module Google
7
7
  class ImpersonatedCredential < Signet::OAuth2::Client
8
8
  include IdentityCredentialRefreshPatch
9
9
 
10
+ attr_reader :quota_project_id
11
+
10
12
  # A credential that impersonates a service account.
11
13
  #
12
14
  # The `email_address` of the service account to impersonate may be the exact
@@ -36,6 +38,10 @@ module Google
36
38
  # additional API call.
37
39
  # Only supported when not using a target_audience.
38
40
  #
41
+ # @param quota_project_id [String]
42
+ # The project ID used for quota and billing. This project may be different from
43
+ # the project used to create the credentials.
44
+ #
39
45
  # @param scope [String, Array<String>]
40
46
  # The OAuth 2 scopes to request. Can either be formatted as a comma seperated string or array.
41
47
  # Only supported when not using a target_audience.
@@ -54,6 +60,7 @@ module Google
54
60
  delegate_email_addresses: nil,
55
61
  include_email: nil,
56
62
  lifetime: nil,
63
+ quota_project_id: nil,
57
64
  scope: nil,
58
65
  target_audience: nil
59
66
  )
@@ -90,6 +97,8 @@ module Google
90
97
  end
91
98
 
92
99
  @impersonate_name = transform_email_to_name(email_address)
100
+
101
+ @quota_project_id = quota_project_id
93
102
  end
94
103
 
95
104
  def fetch_access_token(*)
@@ -135,6 +144,7 @@ module Google
135
144
  " @impersonate_delegates=#{@impersonate_delegates.inspect}" \
136
145
  " @impersonate_include_email=#{@impersonate_include_email.inspect}" \
137
146
  " @impersonate_name=#{@impersonate_name.inspect}" \
147
+ " @quota_project_id=#{@quota_project_id.inspect}" \
138
148
  " @target_audience=#{@target_audience.inspect}" \
139
149
  '>'
140
150
  else
@@ -144,6 +154,7 @@ module Google
144
154
  " @impersonate_delegates=#{@impersonate_delegates.inspect}" \
145
155
  " @impersonate_lifetime=#{@impersonate_lifetime.inspect}" \
146
156
  " @impersonate_name=#{@impersonate_name.inspect}" \
157
+ " @quota_project_id=#{@quota_project_id.inspect}" \
147
158
  '>'
148
159
  end
149
160
  end
@@ -7,17 +7,25 @@ module Google
7
7
  class StaticCredential < Signet::OAuth2::Client
8
8
  class AuthorizationExpired < StandardError; end
9
9
 
10
+ attr_reader :quota_project_id
11
+
10
12
  # A credential using a static access token.
11
13
  #
12
14
  # @param access_token [String]
13
15
  # The access token to use.
14
16
  #
15
- def initialize(access_token:)
17
+ # @param quota_project_id [String]
18
+ # The project ID used for quota and billing. This project may be different from
19
+ # the project used to create the credentials.
20
+ #
21
+ def initialize(access_token:, quota_project_id: nil)
16
22
  super(
17
23
  access_token: access_token,
18
24
  expires_at: TokenInfo.lookup_access_token(access_token).fetch('exp'),
19
25
  issued_at: nil,
20
26
  )
27
+
28
+ @quota_project_id = quota_project_id
21
29
  end
22
30
 
23
31
  def fetch_access_token(*)
@@ -28,7 +36,11 @@ module Google
28
36
  end
29
37
 
30
38
  def inspect
31
- "#<#{self.class.name} @access_token=[REDACTED] @expires_at=#{expires_at.inspect}>"
39
+ "#<#{self.class.name}" \
40
+ ' @access_token=[REDACTED]' \
41
+ " @expires_at=#{expires_at.inspect}" \
42
+ " @quota_project_id=#{@quota_project_id.inspect}" \
43
+ '>'
32
44
  end
33
45
  end
34
46
  end
@@ -3,7 +3,7 @@
3
3
  module Google
4
4
  module Auth
5
5
  module Extras
6
- VERSION = '0.3.0'
6
+ VERSION = '0.4.0'
7
7
  end
8
8
  end
9
9
  end
@@ -50,6 +50,10 @@ module Google
50
50
  # additional API call.
51
51
  # Only supported when not using a target_audience.
52
52
  #
53
+ # @param quota_project_id [String]
54
+ # The project ID used for quota and billing. This project may be different from
55
+ # the project used to create the credentials.
56
+ #
53
57
  # @param scope [String, Array<String>]
54
58
  # The OAuth 2 scopes to request. Can either be formatted as a comma seperated string or array.
55
59
  # Only supported when not using a target_audience.
@@ -67,6 +71,7 @@ module Google
67
71
  delegate_email_addresses: nil,
68
72
  include_email: nil,
69
73
  lifetime: nil,
74
+ quota_project_id: nil,
70
75
  scope: nil,
71
76
  target_audience: nil
72
77
  )
@@ -76,6 +81,7 @@ module Google
76
81
  email_address: email_address,
77
82
  include_email: include_email,
78
83
  lifetime: lifetime,
84
+ quota_project_id: quota_project_id,
79
85
  scope: scope,
80
86
  target_audience: target_audience,
81
87
  )
@@ -106,6 +112,10 @@ module Google
106
112
  # additional API call.
107
113
  # Only supported when not using a target_audience.
108
114
  #
115
+ # @param quota_project_id [String]
116
+ # The project ID used for quota and billing. This project may be different from
117
+ # the project used to create the credentials.
118
+ #
109
119
  # @param scope [String, Array<String>]
110
120
  # The OAuth 2 scopes to request. Can either be formatted as a comma seperated string or array.
111
121
  # Only supported when not using a target_audience.
@@ -123,6 +133,7 @@ module Google
123
133
  delegate_email_addresses: nil,
124
134
  include_email: nil,
125
135
  lifetime: nil,
136
+ quota_project_id: nil,
126
137
  scope: nil,
127
138
  target_audience: nil
128
139
  )
@@ -133,6 +144,7 @@ module Google
133
144
  email_address: email_address,
134
145
  include_email: include_email,
135
146
  lifetime: lifetime,
147
+ quota_project_id: quota_project_id,
136
148
  scope: scope,
137
149
  target_audience: target_audience,
138
150
  ),
@@ -145,10 +157,15 @@ module Google
145
157
  # @param token [String]
146
158
  # The access token to use.
147
159
  #
160
+ # @param quota_project_id [String]
161
+ # The project ID used for quota and billing. This project may be different from
162
+ # the project used to create the credentials.
163
+ #
164
+ #
148
165
  # @return [Google::Auth::Extras::StaticCredential]
149
166
  #
150
- def static_authorization(token)
151
- StaticCredential.new(access_token: token)
167
+ def static_authorization(token, quota_project_id: nil)
168
+ StaticCredential.new(access_token: token, quota_project_id: quota_project_id)
152
169
  end
153
170
 
154
171
  # A credential using a static access token. For usage with the newer
@@ -157,10 +174,14 @@ module Google
157
174
  # @param token [String]
158
175
  # The access token to use.
159
176
  #
177
+ # @param quota_project_id [String]
178
+ # The project ID used for quota and billing. This project may be different from
179
+ # the project used to create the credentials.
180
+ #
160
181
  # @return [Google::Auth::Credential<Google::Auth::Extras::StaticCredential>]
161
182
  #
162
- def static_credential(token)
163
- wrap_authorization(static_authorization(token))
183
+ def static_credential(token, quota_project_id: nil)
184
+ wrap_authorization(static_authorization(token, quota_project_id: quota_project_id))
164
185
  end
165
186
 
166
187
  # Take an authorization and turn it into a credential, primarily used
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: googleauth-extras
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Persona Identities
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-07-09 00:00:00.000000000 Z
11
+ date: 2024-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable