googleauth 1.16.2 → 1.17.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 +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/googleauth/client_id.rb +6 -2
- data/lib/googleauth/credentials.rb +2 -3
- data/lib/googleauth/credentials_loader.rb +7 -2
- data/lib/googleauth/default_credentials.rb +3 -3
- data/lib/googleauth/external_account/aws_credentials.rb +2 -1
- data/lib/googleauth/external_account/base_credentials.rb +3 -2
- data/lib/googleauth/external_account/external_account_utils.rb +2 -1
- data/lib/googleauth/external_account/identity_pool_credentials.rb +2 -1
- data/lib/googleauth/external_account/pluggable_credentials.rb +3 -2
- data/lib/googleauth/external_account.rb +4 -3
- data/lib/googleauth/iam.rb +1 -1
- data/lib/googleauth/impersonated_service_account.rb +5 -4
- data/lib/googleauth/json_key_reader.rb +6 -1
- data/lib/googleauth/oauth2/sts_client.rb +3 -2
- data/lib/googleauth/scope_util.rb +1 -1
- data/lib/googleauth/service_account.rb +3 -3
- data/lib/googleauth/user_authorizer.rb +3 -3
- data/lib/googleauth/user_refresh.rb +4 -4
- data/lib/googleauth/version.rb +1 -1
- data/lib/googleauth/web_user_authorizer.rb +8 -8
- metadata +15 -15
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: af793408bd622c160b50d6839cea9d58523e1424c05cf5fa52beecd93b52aee9
|
|
4
|
+
data.tar.gz: 0131f0f3459d5e093b1de8fe48d1986a7b51b583be9a3a23383624dea6c5112c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c5ea780b6bc8b2ae699cb5839f8e4dcfdea65133ec0bd90396c6c1383a6ae34a2b71af9027319c67226faa5ec55e55d75b9aae434e37581ef8e9f54337cd8f5c
|
|
7
|
+
data.tar.gz: 972fcf255773491f037a360fb8c1d557594b5413f8024cc1c888f7d18536e4b3ff732ffb5f928291984348bb5e0f87af34b01054b3f5f3cd16262f75d1cb4260
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Release History
|
|
2
2
|
|
|
3
|
+
### 1.17.0 (2026-06-04)
|
|
4
|
+
|
|
5
|
+
#### Features
|
|
6
|
+
|
|
7
|
+
* port googleauth from multi_json to standard lib json ([#575](https://github.com/googleapis/google-auth-library-ruby/issues/575)) ([5fe4ed9](https://github.com/googleapis/google-auth-library-ruby/commit/5fe4ed96a042f36874a609349be5911db1247c8b)), closes [#572](https://github.com/googleapis/google-auth-library-ruby/issues/572)
|
|
8
|
+
|
|
3
9
|
### 1.16.2 (2026-02-26)
|
|
4
10
|
|
|
5
11
|
#### Bug Fixes
|
data/lib/googleauth/client_id.rb
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
-
require "
|
|
15
|
+
require "json"
|
|
16
16
|
require "googleauth/credentials_loader"
|
|
17
17
|
require "googleauth/errors"
|
|
18
18
|
|
|
@@ -85,7 +85,11 @@ module Google
|
|
|
85
85
|
raise InitializationError, "File can not be nil." if file.nil?
|
|
86
86
|
File.open file.to_s do |f|
|
|
87
87
|
json = f.read
|
|
88
|
-
|
|
88
|
+
begin
|
|
89
|
+
config = JSON.parse json
|
|
90
|
+
rescue JSON::ParserError => e
|
|
91
|
+
raise InitializationError, "Invalid Client ID JSON file: #{e.message}"
|
|
92
|
+
end
|
|
89
93
|
from_hash config
|
|
90
94
|
end
|
|
91
95
|
end
|
|
@@ -16,7 +16,6 @@ require "forwardable"
|
|
|
16
16
|
require "json"
|
|
17
17
|
require "pathname"
|
|
18
18
|
require "signet/oauth_2/client"
|
|
19
|
-
require "multi_json"
|
|
20
19
|
|
|
21
20
|
require "googleauth/credentials_loader"
|
|
22
21
|
require "googleauth/errors"
|
|
@@ -514,7 +513,7 @@ module Google
|
|
|
514
513
|
json_key, clz = Google::Auth::DefaultCredentials.determine_creds_class creds_input[:json_key_io]
|
|
515
514
|
|
|
516
515
|
# Re-serialize the parsed JSON and replace the IO stream in creds_input
|
|
517
|
-
creds_input[:json_key_io] = StringIO.new
|
|
516
|
+
creds_input[:json_key_io] = StringIO.new JSON.generate(json_key)
|
|
518
517
|
|
|
519
518
|
client = clz.make_creds creds_input
|
|
520
519
|
options = options.select { |k, _v| k == :logger }
|
|
@@ -531,7 +530,7 @@ module Google
|
|
|
531
530
|
json_key, clz = Google::Auth::DefaultCredentials.determine_creds_class io
|
|
532
531
|
|
|
533
532
|
# Re-serialize the parsed JSON and create a new IO stream.
|
|
534
|
-
new_io = StringIO.new
|
|
533
|
+
new_io = StringIO.new JSON.generate(json_key)
|
|
535
534
|
|
|
536
535
|
clz.make_creds options.merge!(json_key_io: new_io)
|
|
537
536
|
end
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
require "os"
|
|
16
16
|
require "rbconfig"
|
|
17
|
+
require "json"
|
|
17
18
|
|
|
18
19
|
require "googleauth/errors"
|
|
19
20
|
|
|
@@ -152,7 +153,7 @@ module Google
|
|
|
152
153
|
gcloud = GCLOUD_WINDOWS_COMMAND if OS.windows?
|
|
153
154
|
gcloud = GCLOUD_POSIX_COMMAND unless OS.windows?
|
|
154
155
|
gcloud_json = IO.popen("#{gcloud} #{GCLOUD_CONFIG_COMMAND}", err: :close, &:read)
|
|
155
|
-
config =
|
|
156
|
+
config = JSON.parse gcloud_json
|
|
156
157
|
config["configuration"]["properties"]["core"]["project"]
|
|
157
158
|
rescue StandardError
|
|
158
159
|
nil
|
|
@@ -165,7 +166,11 @@ module Google
|
|
|
165
166
|
# @param expected_type [String] The expected credential type name.
|
|
166
167
|
# @raise [Google::Auth::InitializationError] If the JSON key type does not match the expected type.
|
|
167
168
|
def load_and_verify_json_key_type json_key_io, expected_type
|
|
168
|
-
|
|
169
|
+
begin
|
|
170
|
+
json_key = JSON.parse json_key_io.read
|
|
171
|
+
rescue JSON::ParserError => e
|
|
172
|
+
raise Google::Auth::InitializationError, "Invalid JSON keyfile format: #{e.message}"
|
|
173
|
+
end
|
|
169
174
|
json_key_io.rewind # Rewind the stream so it can be read again.
|
|
170
175
|
return if json_key["type"] == expected_type
|
|
171
176
|
raise Google::Auth::InitializationError,
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
-
require "
|
|
15
|
+
require "json"
|
|
16
16
|
require "stringio"
|
|
17
17
|
|
|
18
18
|
require "googleauth/credentials_loader"
|
|
@@ -81,7 +81,7 @@ module Google
|
|
|
81
81
|
json_key_io = options[:json_key_io]
|
|
82
82
|
json_key, clz = determine_creds_class json_key_io
|
|
83
83
|
if json_key
|
|
84
|
-
io = StringIO.new
|
|
84
|
+
io = StringIO.new JSON.generate(json_key)
|
|
85
85
|
clz.make_creds options.merge(json_key_io: io)
|
|
86
86
|
else
|
|
87
87
|
clz.make_creds options
|
|
@@ -97,7 +97,7 @@ module Google
|
|
|
97
97
|
# or if the environment variable is undefined or unsupported.
|
|
98
98
|
def self.determine_creds_class json_key_io = nil
|
|
99
99
|
if json_key_io
|
|
100
|
-
json_key =
|
|
100
|
+
json_key = JSON.parse json_key_io.read
|
|
101
101
|
key = "type"
|
|
102
102
|
raise InitializationError, "the json is missing the '#{key}' field" unless json_key.key? key
|
|
103
103
|
type = json_key[key]
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
15
|
require "time"
|
|
16
|
+
require "json"
|
|
16
17
|
require "googleauth/errors"
|
|
17
18
|
require "googleauth/external_account/base_credentials"
|
|
18
19
|
require "googleauth/external_account/external_account_utils"
|
|
@@ -226,7 +227,7 @@ module Google
|
|
|
226
227
|
# Retrieves the AWS security credentials required for signing AWS requests from the AWS metadata server.
|
|
227
228
|
def fetch_metadata_security_credentials role_name
|
|
228
229
|
response = get_aws_resource "#{@credential_verification_url}/#{role_name}", "credentials"
|
|
229
|
-
|
|
230
|
+
JSON.parse response.body
|
|
230
231
|
end
|
|
231
232
|
|
|
232
233
|
# Reads the name of the AWS region from the environment
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.require "time"
|
|
14
14
|
|
|
15
|
+
require "json"
|
|
15
16
|
require "googleauth/base_client"
|
|
16
17
|
require "googleauth/errors"
|
|
17
18
|
require "googleauth/helpers/connection"
|
|
@@ -190,7 +191,7 @@ module Google
|
|
|
190
191
|
response = connection.post @service_account_impersonation_url do |req|
|
|
191
192
|
req.headers["Authorization"] = "Bearer #{token}"
|
|
192
193
|
req.headers["Content-Type"] = "application/json"
|
|
193
|
-
req.body =
|
|
194
|
+
req.body = JSON.generate({ scope: @scope })
|
|
194
195
|
end
|
|
195
196
|
|
|
196
197
|
if response.status != 200
|
|
@@ -201,7 +202,7 @@ module Google
|
|
|
201
202
|
)
|
|
202
203
|
end
|
|
203
204
|
|
|
204
|
-
|
|
205
|
+
JSON.parse response.body
|
|
205
206
|
end
|
|
206
207
|
|
|
207
208
|
def log_impersonated_token_request original_token
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.require "time"
|
|
14
14
|
|
|
15
|
+
require "json"
|
|
15
16
|
require "googleauth/base_client"
|
|
16
17
|
require "googleauth/errors"
|
|
17
18
|
require "googleauth/helpers/connection"
|
|
@@ -54,7 +55,7 @@ module Google
|
|
|
54
55
|
end
|
|
55
56
|
|
|
56
57
|
if response.status == 200
|
|
57
|
-
response_data =
|
|
58
|
+
response_data = JSON.parse response.body, symbolize_names: true
|
|
58
59
|
@project_id = response_data[:projectId]
|
|
59
60
|
end
|
|
60
61
|
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
15
|
require "time"
|
|
16
|
+
require "json"
|
|
16
17
|
require "googleauth/errors"
|
|
17
18
|
require "googleauth/external_account/base_credentials"
|
|
18
19
|
require "googleauth/external_account/external_account_utils"
|
|
@@ -63,7 +64,7 @@ module Google
|
|
|
63
64
|
token = content
|
|
64
65
|
else
|
|
65
66
|
begin
|
|
66
|
-
response_data =
|
|
67
|
+
response_data = JSON.parse content, symbolize_names: true
|
|
67
68
|
token = response_data[@credential_source_field_name.to_sym]
|
|
68
69
|
rescue StandardError
|
|
69
70
|
raise CredentialsError, "Unable to parse subject_token from JSON resource #{resource_name} " \
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
require "open3"
|
|
16
16
|
require "time"
|
|
17
|
+
require "json"
|
|
17
18
|
require "googleauth/errors"
|
|
18
19
|
require "googleauth/external_account/base_credentials"
|
|
19
20
|
require "googleauth/external_account/external_account_utils"
|
|
@@ -88,7 +89,7 @@ module Google
|
|
|
88
89
|
env = inject_environment_variables
|
|
89
90
|
output = subprocess_with_timeout env, @credential_source_executable_command,
|
|
90
91
|
@credential_source_executable_timeout_millis
|
|
91
|
-
response =
|
|
92
|
+
response = JSON.parse output, symbolize_names: true
|
|
92
93
|
parse_subject_token response
|
|
93
94
|
end
|
|
94
95
|
|
|
@@ -99,7 +100,7 @@ module Google
|
|
|
99
100
|
return nil unless File.exist? @credential_source_executable_output_file
|
|
100
101
|
begin
|
|
101
102
|
content = File.read @credential_source_executable_output_file, encoding: "utf-8"
|
|
102
|
-
response =
|
|
103
|
+
response = JSON.parse content, symbolize_names: true
|
|
103
104
|
rescue StandardError
|
|
104
105
|
return nil
|
|
105
106
|
end
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
require "time"
|
|
16
16
|
require "uri"
|
|
17
|
+
require "json"
|
|
17
18
|
require "googleauth/credentials_loader"
|
|
18
19
|
require "googleauth/errors"
|
|
19
20
|
require "googleauth/external_account/aws_credentials"
|
|
@@ -62,12 +63,12 @@ module Google
|
|
|
62
63
|
json_key_io, scope = options.values_at :json_key_io, :scope
|
|
63
64
|
|
|
64
65
|
raise InitializationError, "A json file is required for external account credentials." unless json_key_io
|
|
65
|
-
json_key =
|
|
66
|
+
json_key = JSON.parse json_key_io.read, symbolize_names: true
|
|
66
67
|
if json_key.key? :type
|
|
67
68
|
json_key_io.rewind
|
|
68
69
|
else # Defaults to class credential 'type' if missing.
|
|
69
70
|
json_key[:type] = CREDENTIAL_TYPE_NAME
|
|
70
|
-
json_key_io = StringIO.new
|
|
71
|
+
json_key_io = StringIO.new JSON.generate(json_key)
|
|
71
72
|
end
|
|
72
73
|
CredentialsLoader.load_and_verify_json_key_type json_key_io, CREDENTIAL_TYPE_NAME
|
|
73
74
|
user_creds = read_json_key json_key_io
|
|
@@ -86,7 +87,7 @@ module Google
|
|
|
86
87
|
# @return [Hash] The parsed JSON key
|
|
87
88
|
# @raise [Google::Auth::InitializationError] If the JSON is missing required fields
|
|
88
89
|
def self.read_json_key json_key_io
|
|
89
|
-
json_key =
|
|
90
|
+
json_key = JSON.parse json_key_io.read, symbolize_names: true
|
|
90
91
|
wanted = [
|
|
91
92
|
:audience, :subject_token_type, :token_url, :credential_source
|
|
92
93
|
]
|
data/lib/googleauth/iam.rb
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
+
require "json"
|
|
15
16
|
require "googleauth/base_client"
|
|
16
17
|
require "googleauth/errors"
|
|
17
18
|
require "googleauth/helpers/connection"
|
|
@@ -117,7 +118,7 @@ module Google
|
|
|
117
118
|
end
|
|
118
119
|
|
|
119
120
|
require "googleauth/default_credentials"
|
|
120
|
-
impersonated_json =
|
|
121
|
+
impersonated_json = JSON.parse json_key_io.read
|
|
121
122
|
source_credentials_info = impersonated_json["source_credentials"]
|
|
122
123
|
|
|
123
124
|
if source_credentials_info["type"] == CREDENTIAL_TYPE_NAME
|
|
@@ -127,7 +128,7 @@ module Google
|
|
|
127
128
|
end
|
|
128
129
|
|
|
129
130
|
source_credentials = DefaultCredentials.make_creds(
|
|
130
|
-
json_key_io: StringIO.new(
|
|
131
|
+
json_key_io: StringIO.new(JSON.generate(source_credentials_info))
|
|
131
132
|
)
|
|
132
133
|
|
|
133
134
|
impersonation_url = impersonated_json["service_account_impersonation_url"]
|
|
@@ -279,7 +280,7 @@ module Google
|
|
|
279
280
|
|
|
280
281
|
case resp.status
|
|
281
282
|
when 200
|
|
282
|
-
response =
|
|
283
|
+
response = JSON.parse resp.body
|
|
283
284
|
self.expires_at = response["expireTime"]
|
|
284
285
|
@access_token = response["accessToken"]
|
|
285
286
|
access_token
|
|
@@ -310,7 +311,7 @@ module Google
|
|
|
310
311
|
connection.post @impersonation_url do |req|
|
|
311
312
|
req.headers.merge! auth_header
|
|
312
313
|
req.headers["Content-Type"] = "application/json"
|
|
313
|
-
req.body =
|
|
314
|
+
req.body = JSON.generate({ scope: @scope })
|
|
314
315
|
end
|
|
315
316
|
end
|
|
316
317
|
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
+
require "json"
|
|
15
16
|
require "googleauth/errors"
|
|
16
17
|
|
|
17
18
|
module Google
|
|
@@ -29,7 +30,11 @@ module Google
|
|
|
29
30
|
# @raise [Google::Auth::InitializationError] If client_email or private_key
|
|
30
31
|
# fields are missing from the JSON
|
|
31
32
|
def read_json_key json_key_io
|
|
32
|
-
|
|
33
|
+
begin
|
|
34
|
+
json_key = JSON.parse json_key_io.read
|
|
35
|
+
rescue JSON::ParserError => e
|
|
36
|
+
raise InitializationError, "Invalid JSON keyfile format: #{e.message}"
|
|
37
|
+
end
|
|
33
38
|
raise InitializationError, "missing client_email" unless json_key.key? "client_email"
|
|
34
39
|
raise InitializationError, "missing private_key" unless json_key.key? "private_key"
|
|
35
40
|
[
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
+
require "json"
|
|
15
16
|
require "googleauth/errors"
|
|
16
17
|
require "googleauth/helpers/connection"
|
|
17
18
|
|
|
@@ -89,7 +90,7 @@ module Google
|
|
|
89
90
|
raise AuthorizationError, "Token exchange failed with status #{response.status}"
|
|
90
91
|
end
|
|
91
92
|
|
|
92
|
-
|
|
93
|
+
JSON.parse response.body
|
|
93
94
|
end
|
|
94
95
|
|
|
95
96
|
private
|
|
@@ -104,7 +105,7 @@ module Google
|
|
|
104
105
|
subject_token_type: options[:subject_token_type]
|
|
105
106
|
}
|
|
106
107
|
unless options[:additional_options].nil?
|
|
107
|
-
request_body[:options] = CGI.escape
|
|
108
|
+
request_body[:options] = CGI.escape JSON.generate(options[:additional_options])
|
|
108
109
|
end
|
|
109
110
|
request_body
|
|
110
111
|
end
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
15
|
require "jwt"
|
|
16
|
-
require "
|
|
16
|
+
require "json"
|
|
17
17
|
require "stringio"
|
|
18
18
|
|
|
19
19
|
require "google/logging/message"
|
|
@@ -66,12 +66,12 @@ module Google
|
|
|
66
66
|
|
|
67
67
|
private_key, client_email, project_id, quota_project_id, universe_domain =
|
|
68
68
|
if json_key_io
|
|
69
|
-
json_key =
|
|
69
|
+
json_key = JSON.parse json_key_io.read
|
|
70
70
|
if json_key.key? "type"
|
|
71
71
|
json_key_io.rewind
|
|
72
72
|
else # Defaults to class credential 'type' if missing.
|
|
73
73
|
json_key["type"] = CREDENTIAL_TYPE_NAME
|
|
74
|
-
json_key_io = StringIO.new
|
|
74
|
+
json_key_io = StringIO.new JSON.generate(json_key)
|
|
75
75
|
end
|
|
76
76
|
CredentialsLoader.load_and_verify_json_key_type json_key_io, CREDENTIAL_TYPE_NAME
|
|
77
77
|
read_json_key json_key_io
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
15
|
require "uri"
|
|
16
|
-
require "
|
|
16
|
+
require "json"
|
|
17
17
|
require "googleauth/signet"
|
|
18
18
|
require "googleauth/user_refresh"
|
|
19
19
|
require "securerandom"
|
|
@@ -140,7 +140,7 @@ module Google
|
|
|
140
140
|
def get_credentials user_id, scope = nil
|
|
141
141
|
saved_token = stored_token user_id
|
|
142
142
|
return nil if saved_token.nil?
|
|
143
|
-
data =
|
|
143
|
+
data = JSON.parse saved_token
|
|
144
144
|
|
|
145
145
|
if data.fetch("client_id", @client_id.id) != @client_id.id
|
|
146
146
|
raise CredentialsError.with_details(
|
|
@@ -250,7 +250,7 @@ module Google
|
|
|
250
250
|
# @return [Google::Auth::UserRefreshCredentials]
|
|
251
251
|
# The stored credentials
|
|
252
252
|
def store_credentials user_id, credentials
|
|
253
|
-
json =
|
|
253
|
+
json = JSON.generate(
|
|
254
254
|
client_id: credentials.client_id,
|
|
255
255
|
access_token: credentials.access_token,
|
|
256
256
|
refresh_token: credentials.refresh_token,
|
|
@@ -16,7 +16,7 @@ require "googleauth/credentials_loader"
|
|
|
16
16
|
require "googleauth/errors"
|
|
17
17
|
require "googleauth/scope_util"
|
|
18
18
|
require "googleauth/signet"
|
|
19
|
-
require "
|
|
19
|
+
require "json"
|
|
20
20
|
|
|
21
21
|
module Google
|
|
22
22
|
# Module Auth provides classes that provide Google-specific authorization
|
|
@@ -50,12 +50,12 @@ module Google
|
|
|
50
50
|
def self.make_creds options = {} # rubocop:disable Metrics/MethodLength
|
|
51
51
|
json_key_io, scope = options.values_at :json_key_io, :scope
|
|
52
52
|
user_creds = if json_key_io
|
|
53
|
-
json_key =
|
|
53
|
+
json_key = JSON.parse json_key_io.read
|
|
54
54
|
if json_key.key? "type"
|
|
55
55
|
json_key_io.rewind
|
|
56
56
|
else # Defaults to class credential 'type' if missing.
|
|
57
57
|
json_key["type"] = CREDENTIAL_TYPE_NAME
|
|
58
|
-
json_key_io = StringIO.new
|
|
58
|
+
json_key_io = StringIO.new JSON.generate(json_key)
|
|
59
59
|
end
|
|
60
60
|
CredentialsLoader.load_and_verify_json_key_type json_key_io, CREDENTIAL_TYPE_NAME
|
|
61
61
|
read_json_key json_key_io
|
|
@@ -86,7 +86,7 @@ module Google
|
|
|
86
86
|
# @return [Hash] The parsed JSON key
|
|
87
87
|
# @raise [Google::Auth::InitializationError] If the JSON is missing required fields
|
|
88
88
|
def self.read_json_key json_key_io
|
|
89
|
-
json_key =
|
|
89
|
+
json_key = JSON.parse json_key_io.read
|
|
90
90
|
wanted = ["client_id", "client_secret", "refresh_token"]
|
|
91
91
|
wanted.each do |key|
|
|
92
92
|
raise InitializationError, "the json is missing the #{key} field" unless json_key.key? key
|
data/lib/googleauth/version.rb
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
-
require "
|
|
15
|
+
require "json"
|
|
16
16
|
require "googleauth/errors"
|
|
17
17
|
require "googleauth/signet"
|
|
18
18
|
require "googleauth/user_authorizer"
|
|
@@ -84,7 +84,7 @@ module Google
|
|
|
84
84
|
# Redirect URI if successfully extracted, nil otherwise
|
|
85
85
|
def self.handle_auth_callback_deferred request
|
|
86
86
|
callback_state, redirect_uri = extract_callback_state request
|
|
87
|
-
request.session[CALLBACK_STATE_KEY] =
|
|
87
|
+
request.session[CALLBACK_STATE_KEY] = JSON.generate callback_state
|
|
88
88
|
redirect_uri
|
|
89
89
|
end
|
|
90
90
|
|
|
@@ -166,10 +166,10 @@ module Google
|
|
|
166
166
|
|
|
167
167
|
redirect_to = options[:redirect_to] || request.url
|
|
168
168
|
request.session[XSRF_KEY] = SecureRandom.base64
|
|
169
|
-
options[:state] =
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
169
|
+
options[:state] = JSON.generate(state.merge(
|
|
170
|
+
SESSION_ID_KEY => request.session[XSRF_KEY],
|
|
171
|
+
CURRENT_URI_KEY => redirect_to
|
|
172
|
+
))
|
|
173
173
|
options[:base_url] = request.url
|
|
174
174
|
super options
|
|
175
175
|
end
|
|
@@ -194,7 +194,7 @@ module Google
|
|
|
194
194
|
# Note - in theory, no need to check required scope as this is
|
|
195
195
|
# expected to be called immediately after a return from authorization
|
|
196
196
|
state_json = request.session.delete CALLBACK_STATE_KEY
|
|
197
|
-
callback_state =
|
|
197
|
+
callback_state = JSON.parse state_json
|
|
198
198
|
WebUserAuthorizer.validate_callback_state callback_state, request
|
|
199
199
|
get_and_store_credentials_from_code(
|
|
200
200
|
user_id: user_id,
|
|
@@ -214,7 +214,7 @@ module Google
|
|
|
214
214
|
# @return [Array<Hash, String>]
|
|
215
215
|
# Callback state and redirect URI
|
|
216
216
|
def self.extract_callback_state request
|
|
217
|
-
state =
|
|
217
|
+
state = JSON.parse(request.params[STATE_PARAM] || "{}")
|
|
218
218
|
redirect_uri = state[CURRENT_URI_KEY]
|
|
219
219
|
callback_state = {
|
|
220
220
|
AUTH_CODE_KEY => request.params[AUTH_CODE_KEY],
|
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.
|
|
4
|
+
version: 1.17.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Google LLC
|
|
@@ -77,20 +77,6 @@ dependencies:
|
|
|
77
77
|
- - "<"
|
|
78
78
|
- !ruby/object:Gem::Version
|
|
79
79
|
version: '4.0'
|
|
80
|
-
- !ruby/object:Gem::Dependency
|
|
81
|
-
name: multi_json
|
|
82
|
-
requirement: !ruby/object:Gem::Requirement
|
|
83
|
-
requirements:
|
|
84
|
-
- - "~>"
|
|
85
|
-
- !ruby/object:Gem::Version
|
|
86
|
-
version: '1.11'
|
|
87
|
-
type: :runtime
|
|
88
|
-
prerelease: false
|
|
89
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
90
|
-
requirements:
|
|
91
|
-
- - "~>"
|
|
92
|
-
- !ruby/object:Gem::Version
|
|
93
|
-
version: '1.11'
|
|
94
80
|
- !ruby/object:Gem::Dependency
|
|
95
81
|
name: os
|
|
96
82
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -111,6 +97,20 @@ dependencies:
|
|
|
111
97
|
- - "<"
|
|
112
98
|
- !ruby/object:Gem::Version
|
|
113
99
|
version: '2.0'
|
|
100
|
+
- !ruby/object:Gem::Dependency
|
|
101
|
+
name: pstore
|
|
102
|
+
requirement: !ruby/object:Gem::Requirement
|
|
103
|
+
requirements:
|
|
104
|
+
- - "~>"
|
|
105
|
+
- !ruby/object:Gem::Version
|
|
106
|
+
version: '0.1'
|
|
107
|
+
type: :runtime
|
|
108
|
+
prerelease: false
|
|
109
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
110
|
+
requirements:
|
|
111
|
+
- - "~>"
|
|
112
|
+
- !ruby/object:Gem::Version
|
|
113
|
+
version: '0.1'
|
|
114
114
|
- !ruby/object:Gem::Dependency
|
|
115
115
|
name: signet
|
|
116
116
|
requirement: !ruby/object:Gem::Requirement
|