googleauth 0.9.0 → 0.13.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/.kokoro/continuous/linux.cfg +12 -2
  3. data/.kokoro/continuous/osx.cfg +5 -0
  4. data/.kokoro/continuous/post.cfg +30 -0
  5. data/.kokoro/continuous/windows.cfg +10 -0
  6. data/.kokoro/presubmit/linux.cfg +11 -1
  7. data/.kokoro/presubmit/osx.cfg +5 -0
  8. data/.kokoro/presubmit/windows.cfg +10 -0
  9. data/.kokoro/release.cfg +42 -1
  10. data/.repo-metadata.json +5 -0
  11. data/.rubocop.yml +12 -35
  12. data/CHANGELOG.md +32 -0
  13. data/Gemfile +8 -3
  14. data/README.md +7 -11
  15. data/Rakefile +48 -5
  16. data/googleauth.gemspec +7 -4
  17. data/integration/helper.rb +31 -0
  18. data/integration/id_tokens/key_source_test.rb +74 -0
  19. data/lib/googleauth.rb +1 -0
  20. data/lib/googleauth/application_default.rb +9 -9
  21. data/lib/googleauth/compute_engine.rb +30 -27
  22. data/lib/googleauth/credentials.rb +92 -22
  23. data/lib/googleauth/credentials_loader.rb +14 -15
  24. data/lib/googleauth/id_tokens.rb +233 -0
  25. data/lib/googleauth/id_tokens/errors.rb +71 -0
  26. data/lib/googleauth/id_tokens/key_sources.rb +394 -0
  27. data/lib/googleauth/id_tokens/verifier.rb +144 -0
  28. data/lib/googleauth/json_key_reader.rb +6 -2
  29. data/lib/googleauth/service_account.rb +16 -7
  30. data/lib/googleauth/signet.rb +8 -6
  31. data/lib/googleauth/user_authorizer.rb +8 -3
  32. data/lib/googleauth/user_refresh.rb +1 -1
  33. data/lib/googleauth/version.rb +1 -1
  34. data/lib/googleauth/web_user_authorizer.rb +1 -1
  35. data/rakelib/devsite_builder.rb +45 -0
  36. data/rakelib/link_checker.rb +64 -0
  37. data/rakelib/repo_metadata.rb +59 -0
  38. data/spec/googleauth/apply_auth_examples.rb +28 -5
  39. data/spec/googleauth/compute_engine_spec.rb +37 -13
  40. data/spec/googleauth/credentials_spec.rb +25 -6
  41. data/spec/googleauth/service_account_spec.rb +23 -16
  42. data/spec/googleauth/signet_spec.rb +15 -7
  43. data/spec/googleauth/user_authorizer_spec.rb +21 -1
  44. data/spec/googleauth/user_refresh_spec.rb +1 -1
  45. data/test/helper.rb +33 -0
  46. data/test/id_tokens/key_sources_test.rb +240 -0
  47. data/test/id_tokens/verifier_test.rb +269 -0
  48. metadata +45 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e97bb2d3af353d706c6b608e1743fb3f571e62530201ffa3bebcae2c7e6460bb
4
- data.tar.gz: 3c06cad2ea956d09a37783516292c61f754706366a2b8bf03ef7928769762070
3
+ metadata.gz: ed0edf45ba52552808e13667185f0277233c77e8d0e377d7b1924dc0fb9c1d1a
4
+ data.tar.gz: db8eaf43c99d362dae906b0c1c488652201940a8b4f70ca589846a7ecf869dfa
5
5
  SHA512:
6
- metadata.gz: 68ad7978f7d5abcc14fbd4ca668ba24f69e4bef2c184427b1a70a8c57e2d742b636d5c0b8da10f4d62f8762adb0075d20c1eb75a76302f9f9b6e61cd1b989685
7
- data.tar.gz: 25333a0a26181c8f8f0464642eccfe0340ed591a4c11f9fe3ed4b85179524c37100431f686a16a75f2985ade010e3b488aeb60a6c1a06e0109db46efa9e1d620
6
+ metadata.gz: 62c088c7997002f68a820b928ae2f1898f6efdd32d5850413d9894995fee3dce0689908427547a971884ab1673f2218e3526b20bdbea3d280995bee3fcdef202
7
+ data.tar.gz: d45554051877a0cb282db279cf45df0462dcda88562cd54cf640c554d95eb43adb254821366e0b12529dc5768cbe9bf3fbbf1cb612a72b6a400b619b3ed6fbfc
@@ -3,13 +3,23 @@
3
3
  build_file: "google-auth-library-ruby/.kokoro/trampoline.sh"
4
4
 
5
5
  # Configure the docker image for kokoro-trampoline.
6
- # Dockerfile is maintained at https://github.com/googleapis/google-cloud-ruby/tree/master/.kokoro/docker/ruby-multi
6
+ # Dockerfile is maintained at https://github.com/googleapis/google-cloud-ruby/tree/master/.kokoro/docker/multi
7
7
  env_vars: {
8
8
  key: "TRAMPOLINE_IMAGE"
9
- value: "gcr.io/cloud-devrel-kokoro-resources/yoshi-ruby/ruby-multi"
9
+ value: "gcr.io/cloud-devrel-kokoro-resources/yoshi-ruby/multi"
10
10
  }
11
11
 
12
12
  env_vars: {
13
13
  key: "TRAMPOLINE_BUILD_FILE"
14
14
  value: "github/google-auth-library-ruby/.kokoro/build.sh"
15
15
  }
16
+
17
+ env_vars: {
18
+ key: "TRAMPOLINE_SCRIPT"
19
+ value: "trampoline_v1.py"
20
+ }
21
+
22
+ env_vars: {
23
+ key: "OS"
24
+ value: "linux"
25
+ }
@@ -1,3 +1,8 @@
1
1
  # Format: //devtools/kokoro/config/proto/build.proto
2
2
 
3
3
  build_file: "google-auth-library-ruby/.kokoro/osx.sh"
4
+
5
+ env_vars: {
6
+ key: "OS"
7
+ value: "osx"
8
+ }
@@ -0,0 +1,30 @@
1
+ # Format: //devtools/kokoro/config/proto/build.proto
2
+
3
+ build_file: "google-auth-library-ruby/.kokoro/trampoline.sh"
4
+
5
+ # Configure the docker image for kokoro-trampoline.
6
+ # Dockerfile is maintained at https://github.com/googleapis/google-cloud-ruby/tree/master/.kokoro/docker/multi-node
7
+ env_vars: {
8
+ key: "TRAMPOLINE_IMAGE"
9
+ value: "gcr.io/cloud-devrel-kokoro-resources/yoshi-ruby/multi-node"
10
+ }
11
+
12
+ env_vars: {
13
+ key: "TRAMPOLINE_BUILD_FILE"
14
+ value: "github/google-auth-library-ruby/.kokoro/build.sh"
15
+ }
16
+
17
+ env_vars: {
18
+ key: "TRAMPOLINE_SCRIPT"
19
+ value: "trampoline_v1.py"
20
+ }
21
+
22
+ env_vars: {
23
+ key: "OS"
24
+ value: "linux"
25
+ }
26
+
27
+ env_vars: {
28
+ key: "JOB_TYPE"
29
+ value: "post"
30
+ }
@@ -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
+ }
@@ -5,10 +5,20 @@ build_file: "google-auth-library-ruby/.kokoro/trampoline.sh"
5
5
  # Configure the docker image for kokoro-trampoline.
6
6
  env_vars: {
7
7
  key: "TRAMPOLINE_IMAGE"
8
- value: "gcr.io/cloud-devrel-kokoro-resources/yoshi-ruby/ruby-multi"
8
+ value: "gcr.io/cloud-devrel-kokoro-resources/yoshi-ruby/multi"
9
9
  }
10
10
 
11
11
  env_vars: {
12
12
  key: "TRAMPOLINE_BUILD_FILE"
13
13
  value: "github/google-auth-library-ruby/.kokoro/build.sh"
14
14
  }
15
+
16
+ env_vars: {
17
+ key: "TRAMPOLINE_SCRIPT"
18
+ value: "trampoline_v1.py"
19
+ }
20
+
21
+ env_vars: {
22
+ key: "OS"
23
+ value: "linux"
24
+ }
@@ -1,3 +1,8 @@
1
1
  # Format: //devtools/kokoro/config/proto/build.proto
2
2
 
3
3
  build_file: "google-auth-library-ruby/.kokoro/osx.sh"
4
+
5
+ env_vars: {
6
+ key: "OS"
7
+ value: "osx"
8
+ }
@@ -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
+ }
@@ -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
 
@@ -29,7 +60,7 @@ build_file: "google-auth-library-ruby/.kokoro/trampoline.sh"
29
60
  # Configure the docker image for kokoro-trampoline.
30
61
  env_vars: {
31
62
  key: "TRAMPOLINE_IMAGE"
32
- value: "gcr.io/cloud-devrel-kokoro-resources/google-cloud-ruby/ruby-release"
63
+ value: "gcr.io/cloud-devrel-kokoro-resources/yoshi-ruby/release"
33
64
  }
34
65
 
35
66
  env_vars: {
@@ -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
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "name": "googleauth",
3
+ "language": "ruby",
4
+ "distribution-name": "googleauth"
5
+ }
@@ -1,42 +1,19 @@
1
+ inherit_gem:
2
+ google-style: google-style.yml
3
+
1
4
  AllCops:
2
5
  Exclude:
3
- - "spec/**/*"
4
6
  - "Rakefile"
5
-
6
- Metrics/AbcSize:
7
- Max: 25
7
+ - "integration/**/*"
8
+ - "rakelib/**/*"
9
+ - "spec/**/*"
10
+ - "test/**/*"
11
+ Metrics/ClassLength:
12
+ Max: 200
13
+ Metrics/ModuleLength:
14
+ Max: 110
8
15
  Metrics/BlockLength:
9
16
  Exclude:
10
17
  - "googleauth.gemspec"
11
- Metrics/CyclomaticComplexity:
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:
18
+ Style/SafeNavigation:
42
19
  Enabled: false
@@ -1,3 +1,34 @@
1
+ # Release History
2
+
3
+ ### 0.13.1 / 2020-07-30
4
+
5
+ * Support scopes when using GCE Metadata Server authentication ([@ball-hayden][])
6
+
7
+ ### 0.13.0 / 2020-06-17
8
+
9
+ * Support for validating ID tokens.
10
+ * Fixed header application of ID tokens from service accounts.
11
+
12
+ ### 0.12.0 / 2020-04-08
13
+
14
+ * Support for ID token credentials.
15
+ * Support reading quota_id_project from service account credentials.
16
+
17
+ ### 0.11.0 / 2020-02-24
18
+
19
+ * Support Faraday 1.x.
20
+ * Allow special "postmessage" value for redirect_uri.
21
+
22
+ ### 0.10.0 / 2019-10-09
23
+
24
+ Note: This release now requires Ruby 2.4 or later
25
+
26
+ * Increase metadata timeout to improve reliability in some hosting environments
27
+ * Support an environment variable to suppress Cloud SDK credentials warnings
28
+ * Make the header check case insensitive
29
+ * Set instance variables at initialization to avoid spamming warnings
30
+ * Pass "Metadata-Flavor" header to metadata server when checking for GCE
31
+
1
32
  ### 0.9.0 / 2019-08-05
2
33
 
3
34
  * 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.
@@ -118,3 +149,4 @@
118
149
  [@tbetbetbe]: https://github.com/tbetbetbe
119
150
  [@murgatroid99]: https://github.com/murgatroid99
120
151
  [@vsubramani]: https://github.com/vsubramani
152
+ [@ball-hayden]: https://github.com/ball-hayden
data/Gemfile CHANGED
@@ -8,18 +8,23 @@ 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"
13
+ gem "minitest", "~> 5.14"
14
+ gem "minitest-focus", "~> 1.1"
12
15
  gem "rack-test", "~> 0.6"
13
- gem "rake", "~> 10.0"
16
+ gem "rake", "~> 13.0"
14
17
  gem "redis", "~> 3.2"
15
18
  gem "rspec", "~> 3.0"
16
- gem "rubocop", ">= 0.41", "< 0.50"
17
19
  gem "simplecov", "~> 0.9"
18
20
  gem "sinatra"
19
- gem "webmock", "~> 1.21"
21
+ gem "webmock", "~> 3.8"
20
22
  end
21
23
 
22
24
  platforms :jruby do
23
25
  group :development do
24
26
  end
25
27
  end
28
+
29
+ gem "faraday", "~> 0.17"
30
+ 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/google/google-auth-library-ruby">http://www.github.com/google/google-auth-library-ruby</a></dd>
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
  [![Gem Version](https://badge.fury.io/rb/googleauth.svg)](http://badge.fury.io/rb/googleauth)
11
- [![Coverage Status](https://coveralls.io/repos/google/google-auth-library-ruby/badge.svg)](https://coveralls.io/r/google/google-auth-library-ruby)
12
11
 
13
12
  ## Description
14
13
 
@@ -179,15 +178,13 @@ access and refresh tokens. Two storage implementations are included:
179
178
  * Google::Auth::Stores::RedisTokenStore
180
179
 
181
180
  Custom storage implementations can also be used. See
182
- [token_store.rb](lib/googleauth/token_store.rb) for additional details.
181
+ [token_store.rb](https://googleapis.dev/ruby/googleauth/latest/Google/Auth/TokenStore.html) for additional details.
183
182
 
184
183
  ## Supported Ruby Versions
185
184
 
186
- This library is currently supported on Ruby 2.3+.
185
+ This library requires Ruby 2.4 or later.
187
186
 
188
- However, Ruby 2.4 or later is strongly recommended, as earlier releases have
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.
@@ -209,7 +206,6 @@ hesitate to
209
206
  [ask questions](http://stackoverflow.com/questions/tagged/google-auth-library-ruby)
210
207
  about the client or APIs on [StackOverflow](http://stackoverflow.com).
211
208
 
212
- [google-apis-ruby-client]: (https://github.com/google/google-api-ruby-client)
213
- [application default credentials]: (https://developers.google.com/accounts/docs/application-default-credentials)
214
- [contributing]: https://github.com/google/google-auth-library-ruby/tree/master/CONTRIBUTING.md
215
- [copying]: https://github.com/google/google-auth-library-ruby/tree/master/COPYING
209
+ [application default credentials]: https://developers.google.com/accounts/docs/application-default-credentials
210
+ [contributing]: https://github.com/googleapis/google-auth-library-ruby/tree/master/.github/CONTRIBUTING.md
211
+ [copying]: https://github.com/googleapis/google-auth-library-ruby/tree/master/COPYING
data/Rakefile CHANGED
@@ -1,18 +1,40 @@
1
1
  # -*- ruby -*-
2
+ require "json"
2
3
  require "bundler/gem_tasks"
3
4
 
5
+ require "rubocop/rake_task"
6
+ RuboCop::RakeTask.new
7
+
8
+ require "rake/testtask"
9
+
10
+ desc "Run tests."
11
+ Rake::TestTask.new do |t|
12
+ t.libs << "test"
13
+ t.test_files = FileList["test/**/*_test.rb"]
14
+ t.warning = false
15
+ end
16
+
17
+ desc "Run integration tests."
18
+ Rake::TestTask.new("integration") do |t|
19
+ t.libs << "integration"
20
+ t.test_files = FileList["integration/**/*_test.rb"]
21
+ t.warning = false
22
+ end
23
+
4
24
  task :ci do
5
25
  header "Using Ruby - #{RUBY_VERSION}"
6
26
  sh "bundle exec rubocop"
27
+ Rake::Task["test"].invoke
28
+ Rake::Task["integration"].invoke
7
29
  sh "bundle exec rspec"
8
30
  end
9
31
 
10
- task :release, :tag do |_t, args|
32
+ task :release_gem, :tag do |_t, args|
11
33
  tag = args[:tag]
12
34
  raise "You must provide a tag to release." if tag.nil?
13
35
 
14
36
  # Verify the tag format "vVERSION"
15
- m = tag.match(/v(?<version>\S*)/)
37
+ m = tag.match /v(?<version>\S*)/
16
38
  raise "Tag #{tag} does not match the expected format." if m.nil?
17
39
 
18
40
  version = m[:version]
@@ -33,17 +55,24 @@ task :release, :tag do |_t, args|
33
55
  sh "bundle exec rake build"
34
56
  end
35
57
 
36
- path_to_be_pushed = "pkg/#{version}.gem"
58
+ path_to_be_pushed = "pkg/googleauth-#{version}.gem"
59
+ gem_was_published = nil
37
60
  if File.file? path_to_be_pushed
38
61
  begin
39
- ::Gems.push File.new(path_to_be_pushed)
62
+ response = ::Gems.push File.new(path_to_be_pushed)
63
+ puts response
64
+ raise unless response.include? "Successfully registered gem:"
65
+ gem_was_published = true
40
66
  puts "Successfully built and pushed googleauth for version #{version}"
41
67
  rescue StandardError => e
68
+ gem_was_published = false
42
69
  puts "Error while releasing googleauth version #{version}: #{e.message}"
43
70
  end
44
71
  else
45
72
  raise "Cannot build googleauth for version #{version}"
46
73
  end
74
+
75
+ Rake::Task["kokoro:publish_docs"].invoke if gem_was_published
47
76
  end
48
77
 
49
78
  namespace :kokoro do
@@ -63,6 +92,14 @@ namespace :kokoro do
63
92
  Rake::Task["ci"].invoke
64
93
  end
65
94
 
95
+ task :post do
96
+ require_relative "rakelib/link_checker.rb"
97
+
98
+ link_checker = LinkChecker.new
99
+ link_checker.run
100
+ exit link_checker.exit_status
101
+ end
102
+
66
103
  task :nightly do
67
104
  Rake::Task["ci"].invoke
68
105
  end
@@ -75,7 +112,13 @@ namespace :kokoro do
75
112
  .first.split("(").last.split(")").first || "0.1.0"
76
113
  end
77
114
  Rake::Task["kokoro:load_env_vars"].invoke
78
- Rake::Task["release"].invoke "v/#{version}"
115
+ Rake::Task["release_gem"].invoke "v#{version}"
116
+ end
117
+
118
+ task :publish_docs do
119
+ require_relative "rakelib/devsite_builder.rb"
120
+
121
+ DevsiteBuilder.new(__dir__).publish
79
122
  end
80
123
  end
81
124