googleauth 0.9.0 → 0.10.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/.kokoro/continuous/linux.cfg +10 -0
- data/.kokoro/continuous/osx.cfg +5 -0
- data/.kokoro/continuous/windows.cfg +10 -0
- data/.kokoro/presubmit/linux.cfg +10 -0
- data/.kokoro/presubmit/osx.cfg +5 -0
- data/.kokoro/presubmit/windows.cfg +10 -0
- data/.kokoro/release.cfg +41 -0
- data/.rubocop.yml +10 -34
- data/CHANGELOG.md +10 -0
- data/Gemfile +3 -1
- data/README.md +3 -6
- data/Rakefile +5 -4
- data/googleauth.gemspec +3 -2
- data/lib/googleauth/application_default.rb +7 -7
- data/lib/googleauth/compute_engine.rb +16 -22
- data/lib/googleauth/credentials.rb +3 -0
- data/lib/googleauth/credentials_loader.rb +14 -15
- data/lib/googleauth/signet.rb +5 -4
- data/lib/googleauth/user_authorizer.rb +2 -2
- data/lib/googleauth/version.rb +1 -1
- data/lib/googleauth/web_user_authorizer.rb +1 -1
- data/spec/googleauth/compute_engine_spec.rb +3 -0
- data/spec/googleauth/credentials_spec.rb +8 -0
- metadata +6 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: db5eb8767a7eae3ca209e8a6eeebc6e8e3b0b8724ce456734fbb4f10fc62319a
|
|
4
|
+
data.tar.gz: 36501fbb7a1963cde692f1122d40fcbc02d6f98d517736ffd11745c42649dcef
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fd87ff90b92d1906310f9bebeffa84a692b11bd54c114d597e19c02968955922c0202b87cf6fb6b6e172804234ffb5f4b642ac1415b562013cbd789b942025a0
|
|
7
|
+
data.tar.gz: 444ce4532265ff0b8ecdd384653384579c0d99730fa0c415c957c8a956d603fdc1667e2dd2c112efa062b7c11c55285d783a85894e84c440c74f5c6923140c10
|
data/.kokoro/continuous/osx.cfg
CHANGED
|
@@ -13,7 +13,17 @@ env_vars: {
|
|
|
13
13
|
value: "github/google-auth-library-ruby/.kokoro/build.bat"
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
env_vars: {
|
|
17
|
+
key: "TRAMPOLINE_SCRIPT"
|
|
18
|
+
value: "trampoline_windows.py"
|
|
19
|
+
}
|
|
20
|
+
|
|
16
21
|
env_vars: {
|
|
17
22
|
key: "REPO_DIR"
|
|
18
23
|
value: "google-auth-library-ruby"
|
|
19
24
|
}
|
|
25
|
+
|
|
26
|
+
env_vars: {
|
|
27
|
+
key: "OS"
|
|
28
|
+
value: "windows"
|
|
29
|
+
}
|
data/.kokoro/presubmit/linux.cfg
CHANGED
data/.kokoro/presubmit/osx.cfg
CHANGED
|
@@ -13,7 +13,17 @@ env_vars: {
|
|
|
13
13
|
value: "github/google-auth-library-ruby/.kokoro/build.bat"
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
env_vars: {
|
|
17
|
+
key: "TRAMPOLINE_SCRIPT"
|
|
18
|
+
value: "trampoline_windows.py"
|
|
19
|
+
}
|
|
20
|
+
|
|
16
21
|
env_vars: {
|
|
17
22
|
key: "REPO_DIR"
|
|
18
23
|
value: "google-auth-library-ruby"
|
|
19
24
|
}
|
|
25
|
+
|
|
26
|
+
env_vars: {
|
|
27
|
+
key: "OS"
|
|
28
|
+
value: "windows"
|
|
29
|
+
}
|
data/.kokoro/release.cfg
CHANGED
|
@@ -17,6 +17,37 @@ before_action {
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
# Fetch magictoken to use with Magic Github Proxy
|
|
21
|
+
before_action {
|
|
22
|
+
fetch_keystore {
|
|
23
|
+
keystore_resource {
|
|
24
|
+
keystore_config_id: 73713
|
|
25
|
+
keyname: "releasetool-magictoken"
|
|
26
|
+
backend_type: FASTCONFIGPUSH
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
# Fetch api key to use with Magic Github Proxy
|
|
32
|
+
before_action {
|
|
33
|
+
fetch_keystore {
|
|
34
|
+
keystore_resource {
|
|
35
|
+
keystore_config_id: 73713
|
|
36
|
+
keyname: "magic-github-proxy-api-key"
|
|
37
|
+
backend_type: FASTCONFIGPUSH
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
before_action {
|
|
43
|
+
fetch_keystore {
|
|
44
|
+
keystore_resource {
|
|
45
|
+
keystore_config_id: 73713
|
|
46
|
+
keyname: "docuploader_service_account"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
20
51
|
# Download resources for system tests (service account key, etc.)
|
|
21
52
|
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/google-cloud-ruby"
|
|
22
53
|
|
|
@@ -37,6 +68,11 @@ env_vars: {
|
|
|
37
68
|
value: "github/google-auth-library-ruby/.kokoro/build.sh"
|
|
38
69
|
}
|
|
39
70
|
|
|
71
|
+
env_vars: {
|
|
72
|
+
key: "TRAMPOLINE_SCRIPT"
|
|
73
|
+
value: "trampoline_v1.py"
|
|
74
|
+
}
|
|
75
|
+
|
|
40
76
|
env_vars: {
|
|
41
77
|
key: "JOB_TYPE"
|
|
42
78
|
value: "release"
|
|
@@ -51,3 +87,8 @@ env_vars: {
|
|
|
51
87
|
key: "REPO_DIR"
|
|
52
88
|
value: "github/google-auth-library-ruby"
|
|
53
89
|
}
|
|
90
|
+
|
|
91
|
+
env_vars: {
|
|
92
|
+
key: "PACKAGE"
|
|
93
|
+
value: "googleauth"
|
|
94
|
+
}
|
data/.rubocop.yml
CHANGED
|
@@ -1,42 +1,18 @@
|
|
|
1
|
+
inherit_gem:
|
|
2
|
+
google-style: google-style.yml
|
|
3
|
+
|
|
1
4
|
AllCops:
|
|
2
5
|
Exclude:
|
|
3
6
|
- "spec/**/*"
|
|
4
7
|
- "Rakefile"
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
Metrics/ClassLength:
|
|
9
|
+
Max: 110
|
|
10
|
+
Exclude:
|
|
11
|
+
- "lib/googleauth/credentials.rb"
|
|
12
|
+
Metrics/ModuleLength:
|
|
13
|
+
Max: 110
|
|
8
14
|
Metrics/BlockLength:
|
|
9
15
|
Exclude:
|
|
10
16
|
- "googleauth.gemspec"
|
|
11
|
-
|
|
12
|
-
Max: 8
|
|
13
|
-
Metrics/PerceivedComplexity:
|
|
14
|
-
Max: 8
|
|
15
|
-
Metrics/LineLength:
|
|
16
|
-
Max: 120
|
|
17
|
-
Metrics/MethodLength:
|
|
18
|
-
Max: 21
|
|
19
|
-
Metrics/ModuleLength:
|
|
20
|
-
Max: 150
|
|
21
|
-
Metrics/ClassLength:
|
|
22
|
-
Enabled: false
|
|
23
|
-
Layout/IndentHeredoc:
|
|
24
|
-
Enabled: false
|
|
25
|
-
Style/FormatString:
|
|
26
|
-
Enabled: false
|
|
27
|
-
Style/GuardClause:
|
|
28
|
-
Enabled: false
|
|
29
|
-
Style/PercentLiteralDelimiters: # Contradicting rule
|
|
30
|
-
Enabled: false
|
|
31
|
-
Style/StringLiterals:
|
|
32
|
-
EnforcedStyle: double_quotes
|
|
33
|
-
Style/SymbolArray: # Undefined syntax in Ruby 1.9.3
|
|
34
|
-
Enabled: false
|
|
35
|
-
Style/MethodDefParentheses:
|
|
36
|
-
Enabled: false
|
|
37
|
-
Style/WordArray:
|
|
38
|
-
Enabled: false
|
|
39
|
-
Style/TrivialAccessors:
|
|
40
|
-
Enabled: false
|
|
41
|
-
Style/RescueModifier:
|
|
17
|
+
Style/SafeNavigation:
|
|
42
18
|
Enabled: false
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
### 0.10.0 / 2019-10-09
|
|
2
|
+
|
|
3
|
+
Note: This release now requires Ruby 2.4 or later
|
|
4
|
+
|
|
5
|
+
* Increase metadata timeout to improve reliability in some hosting environments
|
|
6
|
+
* Support an environment variable to suppress Cloud SDK credentials warnings
|
|
7
|
+
* Make the header check case insensitive
|
|
8
|
+
* Set instance variables at initialization to avoid spamming warnings
|
|
9
|
+
* Pass "Metadata-Flavor" header to metadata server when checking for GCE
|
|
10
|
+
|
|
1
11
|
### 0.9.0 / 2019-08-05
|
|
2
12
|
|
|
3
13
|
* Restore compatibility with Ruby 2.0. This is the last release that will work on end-of-lifed versions of Ruby. The 0.10 release will require Ruby 2.4 or later.
|
data/Gemfile
CHANGED
|
@@ -8,12 +8,12 @@ group :development do
|
|
|
8
8
|
gem "coveralls", "~> 0.7"
|
|
9
9
|
gem "fakefs", "~> 0.6"
|
|
10
10
|
gem "fakeredis", "~> 0.5"
|
|
11
|
+
gem "google-style", "~> 1.24.0"
|
|
11
12
|
gem "logging", "~> 2.0"
|
|
12
13
|
gem "rack-test", "~> 0.6"
|
|
13
14
|
gem "rake", "~> 10.0"
|
|
14
15
|
gem "redis", "~> 3.2"
|
|
15
16
|
gem "rspec", "~> 3.0"
|
|
16
|
-
gem "rubocop", ">= 0.41", "< 0.50"
|
|
17
17
|
gem "simplecov", "~> 0.9"
|
|
18
18
|
gem "sinatra"
|
|
19
19
|
gem "webmock", "~> 1.21"
|
|
@@ -23,3 +23,5 @@ platforms :jruby do
|
|
|
23
23
|
group :development do
|
|
24
24
|
end
|
|
25
25
|
end
|
|
26
|
+
|
|
27
|
+
gem "gems", "~> 1.2"
|
data/README.md
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
# Google Auth Library for Ruby
|
|
2
2
|
|
|
3
3
|
<dl>
|
|
4
|
-
<dt>Homepage</dt><dd><a href="http://www.github.com/
|
|
4
|
+
<dt>Homepage</dt><dd><a href="http://www.github.com/googleapis/google-auth-library-ruby">http://www.github.com/googleapis/google-auth-library-ruby</a></dd>
|
|
5
5
|
<dt>Authors</dt><dd><a href="mailto:temiola@google.com">Tim Emiola</a></dd>
|
|
6
6
|
<dt>Copyright</dt><dd>Copyright © 2015 Google, Inc.</dd>
|
|
7
7
|
<dt>License</dt><dd>Apache 2.0</dd>
|
|
8
8
|
</dl>
|
|
9
9
|
|
|
10
10
|
[](http://badge.fury.io/rb/googleauth)
|
|
11
|
-
[](https://coveralls.io/r/google/google-auth-library-ruby)
|
|
12
11
|
|
|
13
12
|
## Description
|
|
14
13
|
|
|
@@ -183,11 +182,9 @@ Custom storage implementations can also be used. See
|
|
|
183
182
|
|
|
184
183
|
## Supported Ruby Versions
|
|
185
184
|
|
|
186
|
-
This library
|
|
185
|
+
This library requires Ruby 2.4 or later.
|
|
187
186
|
|
|
188
|
-
|
|
189
|
-
reached or are nearing end-of-life. After March 31, 2019, Google will provide
|
|
190
|
-
official support only for Ruby versions that are considered current and
|
|
187
|
+
In general, this library supports Ruby versions that are considered current and
|
|
191
188
|
supported by Ruby Core (that is, Ruby versions that are either in normal
|
|
192
189
|
maintenance or in security maintenance).
|
|
193
190
|
See https://www.ruby-lang.org/en/downloads/branches/ for further details.
|
data/Rakefile
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# -*- ruby -*-
|
|
2
|
+
require "json"
|
|
2
3
|
require "bundler/gem_tasks"
|
|
3
4
|
|
|
4
5
|
task :ci do
|
|
@@ -7,12 +8,12 @@ task :ci do
|
|
|
7
8
|
sh "bundle exec rspec"
|
|
8
9
|
end
|
|
9
10
|
|
|
10
|
-
task :
|
|
11
|
+
task :release_gem, :tag do |_t, args|
|
|
11
12
|
tag = args[:tag]
|
|
12
13
|
raise "You must provide a tag to release." if tag.nil?
|
|
13
14
|
|
|
14
15
|
# Verify the tag format "vVERSION"
|
|
15
|
-
m = tag.match(/v(?<version>\S*)/)
|
|
16
|
+
m = tag.match(/google-auth-library-ruby\/v(?<version>\S*)/)
|
|
16
17
|
raise "Tag #{tag} does not match the expected format." if m.nil?
|
|
17
18
|
|
|
18
19
|
version = m[:version]
|
|
@@ -33,7 +34,7 @@ task :release, :tag do |_t, args|
|
|
|
33
34
|
sh "bundle exec rake build"
|
|
34
35
|
end
|
|
35
36
|
|
|
36
|
-
path_to_be_pushed = "pkg
|
|
37
|
+
path_to_be_pushed = "pkg/googleauth-#{version}.gem"
|
|
37
38
|
if File.file? path_to_be_pushed
|
|
38
39
|
begin
|
|
39
40
|
::Gems.push File.new(path_to_be_pushed)
|
|
@@ -75,7 +76,7 @@ namespace :kokoro do
|
|
|
75
76
|
.first.split("(").last.split(")").first || "0.1.0"
|
|
76
77
|
end
|
|
77
78
|
Rake::Task["kokoro:load_env_vars"].invoke
|
|
78
|
-
Rake::Task["
|
|
79
|
+
Rake::Task["release_gem"].invoke "google-auth-library-ruby/v#{version}"
|
|
79
80
|
end
|
|
80
81
|
end
|
|
81
82
|
|
data/googleauth.gemspec
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# -*- ruby -*-
|
|
2
2
|
# encoding: utf-8
|
|
3
3
|
|
|
4
|
-
$LOAD_PATH.push File.expand_path("
|
|
4
|
+
$LOAD_PATH.push File.expand_path("lib", __dir__)
|
|
5
5
|
require "googleauth/version"
|
|
6
6
|
|
|
7
7
|
Gem::Specification.new do |gem|
|
|
@@ -25,11 +25,12 @@ Gem::Specification.new do |gem|
|
|
|
25
25
|
end
|
|
26
26
|
gem.require_paths = ["lib"]
|
|
27
27
|
gem.platform = Gem::Platform::RUBY
|
|
28
|
+
gem.required_ruby_version = ">= 2.4.0"
|
|
28
29
|
|
|
29
30
|
gem.add_dependency "faraday", "~> 0.12"
|
|
30
31
|
gem.add_dependency "jwt", ">= 1.4", "< 3.0"
|
|
31
32
|
gem.add_dependency "memoist", "~> 0.16"
|
|
32
33
|
gem.add_dependency "multi_json", "~> 1.11"
|
|
33
34
|
gem.add_dependency "os", ">= 0.9", "< 2.0"
|
|
34
|
-
gem.add_dependency "signet", "~> 0.
|
|
35
|
+
gem.add_dependency "signet", "~> 0.12"
|
|
35
36
|
end
|
|
@@ -34,11 +34,13 @@ module Google
|
|
|
34
34
|
# Module Auth provides classes that provide Google-specific authorization
|
|
35
35
|
# used to access Google APIs.
|
|
36
36
|
module Auth
|
|
37
|
-
NOT_FOUND_ERROR =
|
|
38
|
-
Could not load the default credentials. Browse to
|
|
39
|
-
https://developers.google.com/accounts/docs/application-default-credentials
|
|
40
|
-
for more information
|
|
41
|
-
ERROR_MESSAGE
|
|
37
|
+
NOT_FOUND_ERROR = <<~ERROR_MESSAGE.freeze
|
|
38
|
+
Could not load the default credentials. Browse to
|
|
39
|
+
https://developers.google.com/accounts/docs/application-default-credentials
|
|
40
|
+
for more information
|
|
41
|
+
ERROR_MESSAGE
|
|
42
|
+
|
|
43
|
+
module_function
|
|
42
44
|
|
|
43
45
|
# Obtains the default credentials implementation to use in this
|
|
44
46
|
# environment.
|
|
@@ -75,7 +77,5 @@ ERROR_MESSAGE
|
|
|
75
77
|
end
|
|
76
78
|
GCECredentials.new
|
|
77
79
|
end
|
|
78
|
-
|
|
79
|
-
module_function :get_application_default
|
|
80
80
|
end
|
|
81
81
|
end
|
|
@@ -35,16 +35,16 @@ module Google
|
|
|
35
35
|
# Module Auth provides classes that provide Google-specific authorization
|
|
36
36
|
# used to access Google APIs.
|
|
37
37
|
module Auth
|
|
38
|
-
NO_METADATA_SERVER_ERROR =
|
|
39
|
-
Error code 404 trying to get security access token
|
|
40
|
-
from Compute Engine metadata for the default service account. This
|
|
41
|
-
may be because the virtual machine instance does not have permission
|
|
42
|
-
scopes specified.
|
|
43
|
-
ERROR
|
|
44
|
-
UNEXPECTED_ERROR_SUFFIX =
|
|
45
|
-
trying to get security access token from Compute Engine metadata for
|
|
46
|
-
the default service account
|
|
47
|
-
ERROR
|
|
38
|
+
NO_METADATA_SERVER_ERROR = <<~ERROR.freeze
|
|
39
|
+
Error code 404 trying to get security access token
|
|
40
|
+
from Compute Engine metadata for the default service account. This
|
|
41
|
+
may be because the virtual machine instance does not have permission
|
|
42
|
+
scopes specified.
|
|
43
|
+
ERROR
|
|
44
|
+
UNEXPECTED_ERROR_SUFFIX = <<~ERROR.freeze
|
|
45
|
+
trying to get security access token from Compute Engine metadata for
|
|
46
|
+
the default service account
|
|
47
|
+
ERROR
|
|
48
48
|
|
|
49
49
|
# Extends Signet::OAuth2::Client so that the auth token is obtained from
|
|
50
50
|
# the GCE metadata server.
|
|
@@ -59,22 +59,16 @@ ERROR
|
|
|
59
59
|
extend Memoist
|
|
60
60
|
|
|
61
61
|
# Detect if this appear to be a GCE instance, by checking if metadata
|
|
62
|
-
# is available
|
|
62
|
+
# is available.
|
|
63
63
|
def on_gce? options = {}
|
|
64
|
+
# TODO: This should use google-cloud-env instead.
|
|
64
65
|
c = options[:connection] || Faraday.default_connection
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
# issue is that resolving an unknown host on some networks will take
|
|
70
|
-
# 20-30 seconds; making this timeout short fixes the issue, but
|
|
71
|
-
# could lead to false negatives in the event that we are on GCE, but
|
|
72
|
-
# the metadata resolution was particularly slow. The latter case is
|
|
73
|
-
# "unlikely".
|
|
74
|
-
req.options.timeout = 0.1
|
|
66
|
+
headers = { "Metadata-Flavor" => "Google" }
|
|
67
|
+
resp = c.get COMPUTE_CHECK_URI, nil, headers do |req|
|
|
68
|
+
req.options.timeout = 1.0
|
|
69
|
+
req.options.open_timeout = 0.1
|
|
75
70
|
end
|
|
76
71
|
return false unless resp.status == 200
|
|
77
|
-
return false unless resp.headers.key? "Metadata-Flavor"
|
|
78
72
|
resp.headers["Metadata-Flavor"] == "Google"
|
|
79
73
|
rescue Faraday::TimeoutError, Faraday::ConnectionFailed
|
|
80
74
|
false
|
|
@@ -257,6 +257,9 @@ module Google
|
|
|
257
257
|
CredentialsLoader.warn_if_cloud_sdk_credentials @client.client_id
|
|
258
258
|
@project_id ||= CredentialsLoader.load_gcloud_project_id
|
|
259
259
|
@client.fetch_access_token!
|
|
260
|
+
@env_vars = nil
|
|
261
|
+
@paths = nil
|
|
262
|
+
@scope = nil
|
|
260
263
|
end
|
|
261
264
|
# rubocop:enable Metrics/AbcSize
|
|
262
265
|
|
|
@@ -64,13 +64,13 @@ module Google
|
|
|
64
64
|
CLOUD_SDK_CLIENT_ID = "764086051850-6qr4p6gpi6hn506pt8ejuq83di341hur.app"\
|
|
65
65
|
"s.googleusercontent.com".freeze
|
|
66
66
|
|
|
67
|
-
CLOUD_SDK_CREDENTIALS_WARNING = "Your application has authenticated "\
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
"
|
|
73
|
-
"
|
|
67
|
+
CLOUD_SDK_CREDENTIALS_WARNING = "Your application has authenticated using end user "\
|
|
68
|
+
"credentials from Google Cloud SDK. We recommend that most server applications use "\
|
|
69
|
+
"service accounts instead. If your application continues to use end user credentials "\
|
|
70
|
+
'from Cloud SDK, you might receive a "quota exceeded" or "API not enabled" error. For '\
|
|
71
|
+
"more information about service accounts, see "\
|
|
72
|
+
"https://cloud.google.com/docs/authentication/. To suppress this message, set the "\
|
|
73
|
+
"GOOGLE_AUTH_SUPPRESS_CREDENTIALS_WARNINGS environment variable.".freeze
|
|
74
74
|
|
|
75
75
|
# make_creds proxies the construction of a credentials instance
|
|
76
76
|
#
|
|
@@ -163,11 +163,13 @@ module Google
|
|
|
163
163
|
raise "#{SYSTEM_DEFAULT_ERROR}: #{e}"
|
|
164
164
|
end
|
|
165
165
|
|
|
166
|
+
module_function
|
|
167
|
+
|
|
166
168
|
# Issues warning if cloud sdk client id is used
|
|
167
169
|
def warn_if_cloud_sdk_credentials client_id
|
|
170
|
+
return if ENV["GOOGLE_AUTH_SUPPRESS_CREDENTIALS_WARNINGS"]
|
|
168
171
|
warn CLOUD_SDK_CREDENTIALS_WARNING if client_id == CLOUD_SDK_CLIENT_ID
|
|
169
172
|
end
|
|
170
|
-
module_function :warn_if_cloud_sdk_credentials
|
|
171
173
|
|
|
172
174
|
# Finds project_id from gcloud CLI configuration
|
|
173
175
|
def load_gcloud_project_id
|
|
@@ -179,7 +181,6 @@ module Google
|
|
|
179
181
|
rescue StandardError
|
|
180
182
|
nil
|
|
181
183
|
end
|
|
182
|
-
module_function :load_gcloud_project_id
|
|
183
184
|
|
|
184
185
|
private
|
|
185
186
|
|
|
@@ -193,15 +194,13 @@ module Google
|
|
|
193
194
|
end
|
|
194
195
|
|
|
195
196
|
def service_account_env_vars?
|
|
196
|
-
[PRIVATE_KEY_VAR, CLIENT_EMAIL_VAR].
|
|
197
|
-
ENV
|
|
198
|
-
end
|
|
197
|
+
([PRIVATE_KEY_VAR, CLIENT_EMAIL_VAR] - ENV.keys).empty? &&
|
|
198
|
+
!ENV.to_h.fetch_values(PRIVATE_KEY_VAR, CLIENT_EMAIL_VAR).join(" ").empty?
|
|
199
199
|
end
|
|
200
200
|
|
|
201
201
|
def authorized_user_env_vars?
|
|
202
|
-
[CLIENT_ID_VAR, CLIENT_SECRET_VAR, REFRESH_TOKEN_VAR].
|
|
203
|
-
ENV
|
|
204
|
-
end
|
|
202
|
+
([CLIENT_ID_VAR, CLIENT_SECRET_VAR, REFRESH_TOKEN_VAR] - ENV.keys).empty? &&
|
|
203
|
+
!ENV.to_h.fetch_values(CLIENT_ID_VAR, CLIENT_SECRET_VAR, REFRESH_TOKEN_VAR).join(" ").empty?
|
|
205
204
|
end
|
|
206
205
|
end
|
|
207
206
|
end
|
data/lib/googleauth/signet.rb
CHANGED
|
@@ -66,7 +66,7 @@ module Signet
|
|
|
66
66
|
end
|
|
67
67
|
|
|
68
68
|
def on_refresh &block
|
|
69
|
-
@refresh_listeners
|
|
69
|
+
@refresh_listeners = [] unless defined? @refresh_listeners
|
|
70
70
|
@refresh_listeners << block
|
|
71
71
|
end
|
|
72
72
|
|
|
@@ -84,15 +84,16 @@ module Signet
|
|
|
84
84
|
end
|
|
85
85
|
|
|
86
86
|
def notify_refresh_listeners
|
|
87
|
-
listeners = @refresh_listeners
|
|
87
|
+
listeners = defined?(@refresh_listeners) ? @refresh_listeners : []
|
|
88
88
|
listeners.each do |block|
|
|
89
89
|
block.call self
|
|
90
90
|
end
|
|
91
91
|
end
|
|
92
92
|
|
|
93
93
|
def build_default_connection
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
if !defined?(@connection_info)
|
|
95
|
+
nil
|
|
96
|
+
elsif @connection_info.respond_to? :call
|
|
96
97
|
@connection_info.call
|
|
97
98
|
else
|
|
98
99
|
@connection_info
|
|
@@ -129,8 +129,8 @@ module Google
|
|
|
129
129
|
data = MultiJson.load saved_token
|
|
130
130
|
|
|
131
131
|
if data.fetch("client_id", @client_id.id) != @client_id.id
|
|
132
|
-
raise
|
|
133
|
-
|
|
132
|
+
raise format(MISMATCHED_CLIENT_ID_ERROR,
|
|
133
|
+
data["client_id"], @client_id.id)
|
|
134
134
|
end
|
|
135
135
|
|
|
136
136
|
credentials = UserRefreshCredentials.new(
|
data/lib/googleauth/version.rb
CHANGED
|
@@ -97,6 +97,7 @@ describe Google::Auth::GCECredentials do
|
|
|
97
97
|
describe "#on_gce?" do
|
|
98
98
|
it "should be true when Metadata-Flavor is Google" do
|
|
99
99
|
stub = stub_request(:get, "http://169.254.169.254")
|
|
100
|
+
.with(headers: { "Metadata-Flavor" => "Google" })
|
|
100
101
|
.to_return(status: 200,
|
|
101
102
|
headers: { "Metadata-Flavor" => "Google" })
|
|
102
103
|
expect(GCECredentials.on_gce?({}, true)).to eq(true)
|
|
@@ -105,6 +106,7 @@ describe Google::Auth::GCECredentials do
|
|
|
105
106
|
|
|
106
107
|
it "should be false when Metadata-Flavor is not Google" do
|
|
107
108
|
stub = stub_request(:get, "http://169.254.169.254")
|
|
109
|
+
.with(headers: { "Metadata-Flavor" => "Google" })
|
|
108
110
|
.to_return(status: 200,
|
|
109
111
|
headers: { "Metadata-Flavor" => "NotGoogle" })
|
|
110
112
|
expect(GCECredentials.on_gce?({}, true)).to eq(false)
|
|
@@ -113,6 +115,7 @@ describe Google::Auth::GCECredentials do
|
|
|
113
115
|
|
|
114
116
|
it "should be false if the response is not 200" do
|
|
115
117
|
stub = stub_request(:get, "http://169.254.169.254")
|
|
118
|
+
.with(headers: { "Metadata-Flavor" => "Google" })
|
|
116
119
|
.to_return(status: 404,
|
|
117
120
|
headers: { "Metadata-Flavor" => "NotGoogle" })
|
|
118
121
|
expect(GCECredentials.on_gce?({}, true)).to eq(false)
|
|
@@ -128,6 +128,7 @@ describe Google::Auth::Credentials, :private do
|
|
|
128
128
|
DEFAULT_PATHS = ["~/default/path/to/file.txt"].freeze
|
|
129
129
|
end
|
|
130
130
|
|
|
131
|
+
allow(::ENV).to receive(:[]).with("GOOGLE_AUTH_SUPPRESS_CREDENTIALS_WARNINGS") { "true" }
|
|
131
132
|
allow(::ENV).to receive(:[]).with("PATH_ENV_DUMMY") { "/fake/path/to/file.txt" }
|
|
132
133
|
allow(::File).to receive(:file?).with("/fake/path/to/file.txt") { false }
|
|
133
134
|
allow(::ENV).to receive(:[]).with("PATH_ENV_TEST") { "/unknown/path/to/file.txt" }
|
|
@@ -164,6 +165,7 @@ describe Google::Auth::Credentials, :private do
|
|
|
164
165
|
DEFAULT_PATHS = ["~/default/path/to/file.txt"].freeze
|
|
165
166
|
end
|
|
166
167
|
|
|
168
|
+
allow(::ENV).to receive(:[]).with("GOOGLE_AUTH_SUPPRESS_CREDENTIALS_WARNINGS") { "true" }
|
|
167
169
|
allow(::ENV).to receive(:[]).with("PATH_ENV_DUMMY") { "/fake/path/to/file.txt" }
|
|
168
170
|
allow(::File).to receive(:file?).with("/fake/path/to/file.txt") { false }
|
|
169
171
|
allow(::File).to receive(:file?).with(test_json_env_val) { false }
|
|
@@ -198,6 +200,7 @@ describe Google::Auth::Credentials, :private do
|
|
|
198
200
|
DEFAULT_PATHS = ["~/default/path/to/file.txt"].freeze
|
|
199
201
|
end
|
|
200
202
|
|
|
203
|
+
allow(::ENV).to receive(:[]).with("GOOGLE_AUTH_SUPPRESS_CREDENTIALS_WARNINGS") { "true" }
|
|
201
204
|
allow(::ENV).to receive(:[]).with("PATH_ENV_DUMMY") { "/fake/path/to/file.txt" }
|
|
202
205
|
allow(::File).to receive(:file?).with("/fake/path/to/file.txt") { false }
|
|
203
206
|
allow(::ENV).to receive(:[]).with("JSON_ENV_DUMMY") { nil }
|
|
@@ -232,6 +235,7 @@ describe Google::Auth::Credentials, :private do
|
|
|
232
235
|
DEFAULT_PATHS = ["~/default/path/to/file.txt"].freeze
|
|
233
236
|
end
|
|
234
237
|
|
|
238
|
+
allow(::ENV).to receive(:[]).with("GOOGLE_AUTH_SUPPRESS_CREDENTIALS_WARNINGS") { "true" }
|
|
235
239
|
allow(::ENV).to receive(:[]).with("PATH_ENV_DUMMY") { "/fake/path/to/file.txt" }
|
|
236
240
|
allow(::File).to receive(:file?).with("/fake/path/to/file.txt") { false }
|
|
237
241
|
allow(::ENV).to receive(:[]).with("JSON_ENV_DUMMY") { nil }
|
|
@@ -310,6 +314,7 @@ describe Google::Auth::Credentials, :private do
|
|
|
310
314
|
self.paths = ["~/default/path/to/file.txt"]
|
|
311
315
|
end
|
|
312
316
|
|
|
317
|
+
allow(::ENV).to receive(:[]).with("GOOGLE_AUTH_SUPPRESS_CREDENTIALS_WARNINGS") { "true" }
|
|
313
318
|
allow(::ENV).to receive(:[]).with("PATH_ENV_DUMMY") { "/fake/path/to/file.txt" }
|
|
314
319
|
allow(::File).to receive(:file?).with("/fake/path/to/file.txt") { false }
|
|
315
320
|
allow(::ENV).to receive(:[]).with("PATH_ENV_TEST") { "/unknown/path/to/file.txt" }
|
|
@@ -345,6 +350,7 @@ describe Google::Auth::Credentials, :private do
|
|
|
345
350
|
self.paths = ["~/default/path/to/file.txt"]
|
|
346
351
|
end
|
|
347
352
|
|
|
353
|
+
allow(::ENV).to receive(:[]).with("GOOGLE_AUTH_SUPPRESS_CREDENTIALS_WARNINGS") { "true" }
|
|
348
354
|
allow(::ENV).to receive(:[]).with("PATH_ENV_DUMMY") { "/fake/path/to/file.txt" }
|
|
349
355
|
allow(::File).to receive(:file?).with("/fake/path/to/file.txt") { false }
|
|
350
356
|
allow(::File).to receive(:file?).with(test_json_env_val) { false }
|
|
@@ -378,6 +384,7 @@ describe Google::Auth::Credentials, :private do
|
|
|
378
384
|
self.paths = ["~/default/path/to/file.txt"]
|
|
379
385
|
end
|
|
380
386
|
|
|
387
|
+
allow(::ENV).to receive(:[]).with("GOOGLE_AUTH_SUPPRESS_CREDENTIALS_WARNINGS") { "true" }
|
|
381
388
|
allow(::ENV).to receive(:[]).with("PATH_ENV_DUMMY") { "/fake/path/to/file.txt" }
|
|
382
389
|
allow(::File).to receive(:file?).with("/fake/path/to/file.txt") { false }
|
|
383
390
|
allow(::ENV).to receive(:[]).with("JSON_ENV_DUMMY") { nil }
|
|
@@ -411,6 +418,7 @@ describe Google::Auth::Credentials, :private do
|
|
|
411
418
|
self.paths = ["~/default/path/to/file.txt"]
|
|
412
419
|
end
|
|
413
420
|
|
|
421
|
+
allow(::ENV).to receive(:[]).with("GOOGLE_AUTH_SUPPRESS_CREDENTIALS_WARNINGS") { "true" }
|
|
414
422
|
allow(::ENV).to receive(:[]).with("PATH_ENV_DUMMY") { "/fake/path/to/file.txt" }
|
|
415
423
|
allow(::File).to receive(:file?).with("/fake/path/to/file.txt") { false }
|
|
416
424
|
allow(::ENV).to receive(:[]).with("JSON_ENV_DUMMY") { nil }
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: googleauth
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.10.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tim Emiola
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2019-
|
|
11
|
+
date: 2019-10-09 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|
|
@@ -98,14 +98,14 @@ dependencies:
|
|
|
98
98
|
requirements:
|
|
99
99
|
- - "~>"
|
|
100
100
|
- !ruby/object:Gem::Version
|
|
101
|
-
version: '0.
|
|
101
|
+
version: '0.12'
|
|
102
102
|
type: :runtime
|
|
103
103
|
prerelease: false
|
|
104
104
|
version_requirements: !ruby/object:Gem::Requirement
|
|
105
105
|
requirements:
|
|
106
106
|
- - "~>"
|
|
107
107
|
- !ruby/object:Gem::Version
|
|
108
|
-
version: '0.
|
|
108
|
+
version: '0.12'
|
|
109
109
|
description: |2
|
|
110
110
|
Allows simple authorization for accessing Google APIs.
|
|
111
111
|
Provide support for Application Default Credentials, as described at
|
|
@@ -190,7 +190,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
190
190
|
requirements:
|
|
191
191
|
- - ">="
|
|
192
192
|
- !ruby/object:Gem::Version
|
|
193
|
-
version:
|
|
193
|
+
version: 2.4.0
|
|
194
194
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
195
195
|
requirements:
|
|
196
196
|
- - ">="
|
|
@@ -198,7 +198,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
198
198
|
version: '0'
|
|
199
199
|
requirements: []
|
|
200
200
|
rubyforge_project:
|
|
201
|
-
rubygems_version: 2.7.6
|
|
201
|
+
rubygems_version: 2.7.6
|
|
202
202
|
signing_key:
|
|
203
203
|
specification_version: 4
|
|
204
204
|
summary: Google Auth Library for Ruby
|