googleauth 0.13.0 → 0.13.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 76c72d4ffdf847178b1dbd45ff3563f30efd9b2e0a251ff70a3cd0a4eaecf842
4
- data.tar.gz: 3ae45e385f73dfd312263e2e51ea7d977b9f2a310765626f5e3f38bd03523ac0
3
+ metadata.gz: ed0edf45ba52552808e13667185f0277233c77e8d0e377d7b1924dc0fb9c1d1a
4
+ data.tar.gz: db8eaf43c99d362dae906b0c1c488652201940a8b4f70ca589846a7ecf869dfa
5
5
  SHA512:
6
- metadata.gz: 503a6163b90755a3b07d1dccd6724fa8424501afcfab35582183e871ced300c8d460f6c2068948fdb618ad06b8f074019ed1f0ee4f34546b37bc49dd4a42301c
7
- data.tar.gz: 0a6d1a9c75abff1c03e6114b3154351eb6f7041de65d4621e20c86a28725ecfb9bd4b6705081d87df860e9e0f80c0d21f1539aee77a002770254e08ee5cd0615
6
+ metadata.gz: 62c088c7997002f68a820b928ae2f1898f6efdd32d5850413d9894995fee3dce0689908427547a971884ab1673f2218e3526b20bdbea3d280995bee3fcdef202
7
+ data.tar.gz: d45554051877a0cb282db279cf45df0462dcda88562cd54cf640c554d95eb43adb254821366e0b12529dc5768cbe9bf3fbbf1cb612a72b6a400b619b3ed6fbfc
@@ -1,3 +1,9 @@
1
+ # Release History
2
+
3
+ ### 0.13.1 / 2020-07-30
4
+
5
+ * Support scopes when using GCE Metadata Server authentication ([@ball-hayden][])
6
+
1
7
  ### 0.13.0 / 2020-06-17
2
8
 
3
9
  * Support for validating ID tokens.
@@ -143,3 +149,4 @@ Note: This release now requires Ruby 2.4 or later
143
149
  [@tbetbetbe]: https://github.com/tbetbetbe
144
150
  [@murgatroid99]: https://github.com/murgatroid99
145
151
  [@vsubramani]: https://github.com/vsubramani
152
+ [@ball-hayden]: https://github.com/ball-hayden
@@ -75,7 +75,7 @@ module Google
75
75
  GCECredentials.unmemoize_all
76
76
  raise NOT_FOUND_ERROR
77
77
  end
78
- GCECredentials.new
78
+ GCECredentials.new scope: scope
79
79
  end
80
80
  end
81
81
  end
@@ -85,7 +85,8 @@ module Google
85
85
  c = options[:connection] || Faraday.default_connection
86
86
  retry_with_error do
87
87
  uri = target_audience ? COMPUTE_ID_TOKEN_URI : COMPUTE_AUTH_TOKEN_URI
88
- query = target_audience ? { "audience" => target_audience, "format" => "full" } : nil
88
+ query = target_audience ? { "audience" => target_audience, "format" => "full" } : {}
89
+ query[:scopes] = Array(scope).join " " if scope
89
90
  headers = { "Metadata-Flavor" => "Google" }
90
91
  resp = c.get uri, query, headers
91
92
  case resp.status
@@ -31,6 +31,6 @@ module Google
31
31
  # Module Auth provides classes that provide Google-specific authorization
32
32
  # used to access Google APIs.
33
33
  module Auth
34
- VERSION = "0.13.0".freeze
34
+ VERSION = "0.13.1".freeze
35
35
  end
36
36
  end
@@ -51,7 +51,11 @@ describe Google::Auth::GCECredentials do
51
51
  body = MultiJson.dump("access_token" => opts[:access_token],
52
52
  "token_type" => "Bearer",
53
53
  "expires_in" => 3600)
54
- stub_request(:get, MD_ACCESS_URI)
54
+
55
+ uri = MD_ACCESS_URI
56
+ uri += "?scopes=#{opts[:scope]}" if opts[:scope]
57
+
58
+ stub_request(:get, uri)
55
59
  .with(headers: { "Metadata-Flavor" => "Google" })
56
60
  .to_return(body: body,
57
61
  status: 200,
@@ -69,6 +73,14 @@ describe Google::Auth::GCECredentials do
69
73
 
70
74
  context "metadata is unavailable" do
71
75
  describe "#fetch_access_token" do
76
+ it "should pass scopes when requesting an access token" do
77
+ scope = "https://www.googleapis.com/auth/drive"
78
+ stub = make_auth_stubs access_token: "1/abcdef1234567890", scope: scope
79
+ @client = GCECredentials.new(scope: [scope])
80
+ @client.fetch_access_token!
81
+ expect(stub).to have_been_requested
82
+ end
83
+
72
84
  it "should fail if the metadata request returns a 404" do
73
85
  stub = stub_request(:get, MD_ACCESS_URI)
74
86
  .to_return(status: 404,
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.13.0
4
+ version: 0.13.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Emiola
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-18 00:00:00.000000000 Z
11
+ date: 2020-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday