Skip to content

Commit 42cc8bb

Browse files
authored
Merge pull request grpc#206 from jboeuf/remove_legacy_scoped_creds
Google authentication cleanup.
2 parents cf10e52 + 05f5166 commit 42cc8bb

File tree

1 file changed

+7
-66
lines changed

1 file changed

+7
-66
lines changed

docs/guides/auth.md

Lines changed: 7 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ creds = GRPC::Core::Credentials.new(load_certs) # load_certs typically loads a
169169
stub = Helloworld::Greeter::Stub.new('myservice.example.com', creds)
170170
```
171171

172-
#### Authenticate with Google using scopeless credentials (recommended approach)
172+
#### Authenticate with Google
173173

174174
```ruby
175175
require 'googleauth' # from http://www.rubydoc.info/gems/googleauth/0.1.0
@@ -181,19 +181,6 @@ combined_creds = ssl_creds.compose(call_creds)
181181
stub = Helloworld::Greeter::Stub.new('greeter.googleapis.com', combined_creds)
182182
```
183183

184-
#### Authenticate with Google using Oauth2 token (legacy approach)
185-
186-
```ruby
187-
require 'googleauth' # from http://www.rubydoc.info/gems/googleauth/0.1.0
188-
...
189-
ssl_creds = GRPC::Core::ChannelCredentials.new(load_certs) # load_certs typically loads a CA roots file
190-
scope = 'https://www.googleapis.com/auth/grpc-testing'
191-
authentication = Google::Auth.get_application_default(scope)
192-
call_creds = GRPC::Core::CallCredentials.new(authentication.updater_proc)
193-
combined_creds = ssl_creds.compose(call_creds)
194-
stub = Helloworld::Greeter::Stub.new('greeter.googleapis.com', combined_creds)
195-
```
196-
197184
### C++
198185

199186
#### Base case - no encryption or authentication
@@ -212,7 +199,7 @@ std::unique_ptr<Greeter::Stub> stub(Greeter::NewStub(channel));
212199
...
213200
```
214201

215-
#### Authenticate with Google using scopeless credentials
202+
#### Authenticate with Google
216203

217204
```cpp
218205
auto creds = grpc::GoogleDefaultCredentials();
@@ -239,7 +226,7 @@ var channel = new Channel("myservice.example.com", channelCredentials);
239226
var client = new Greeter.GreeterClient(channel);
240227
```
241228

242-
####Authenticate with Google using scopeless credentials (recommended approach)
229+
####Authenticate with Google
243230
```csharp
244231
using Grpc.Auth; // from Grpc.Auth NuGet package
245232
...
@@ -251,21 +238,6 @@ var client = new Greeter.GreeterClient(channel);
251238
...
252239
```
253240

254-
####Authenticate with Google using OAuth2 token (legacy approach)
255-
```csharp
256-
using Grpc.Auth; // from Grpc.Auth NuGet package
257-
...
258-
string scope = "https://www.googleapis.com/auth/grpc-testing";
259-
var googleCredential = await GoogleCredential.GetApplicationDefaultAsync();
260-
if (googleCredential.IsCreateScopedRequired)
261-
{
262-
googleCredential = googleCredential.CreateScoped(new[] { scope });
263-
}
264-
var channel = new Channel("greeter.googleapis.com", googleCredential.ToChannelCredentials());
265-
var client = new Greeter.GreeterClient(channel);
266-
...
267-
```
268-
269241
####Authenticate a single RPC call
270242
```csharp
271243
var channel = new Channel("greeter.googleapis.com", new SslCredentials()); // Use publicly trusted roots.
@@ -300,7 +272,7 @@ channel = implementations.secure_channel('myservice.example.com', 443, creds)
300272
stub = helloworld_pb2.beta_create_Greeter_stub(channel)
301273
```
302274

303-
####Authenticate with Google using OAuth2 token (legacy approach)
275+
####Authenticate with Google
304276
```python
305277
transport_creds = implementations.ssl_channel_credentials(open('roots.pem').read(), None, None)
306278
def oauth2token_credentials(context, callback):
@@ -363,7 +335,7 @@ ManagedChannel channel = NettyChannelBuilder.forAddress("myservice.example.com",
363335
GreeterGrpc.GreeterStub stub = GreeterGrpc.newStub(channel);
364336
```
365337

366-
####Authenticate with Google using OAuth2 token
338+
####Authenticate with Google
367339

368340
The following code snippet shows how you can call the [Google Cloud PubSub API](https://cloud.google.com/pubsub/overview) using gRPC with a service account. The credentials are loaded from a key stored in a well-known location or by detecting that the application is running in an environment that can provide one automatically, e.g. Google Compute Engine. While this example is specific to Google and its services, similar patterns can be followed for other service providers.
369341

@@ -398,7 +370,7 @@ var ssl_creds = grpc.credentials.createSsl(root_certs);
398370
var stub = new helloworld.Greeter('myservice.example.com', ssl_creds);
399371
```
400372

401-
####Authenticate with Google using scopeless credentials (recommended approach)
373+
####Authenticate with Google
402374

403375
```js
404376
// Authenticating with Google
@@ -412,24 +384,6 @@ var ssl_creds = grpc.credentials.createSsl(root_certs);
412384
});
413385
```
414386

415-
####Authenticate with Google using Oauth2 token (legacy approach)
416-
417-
```js
418-
var GoogleAuth = require('google-auth-library'); // from https://www.npmjs.com/package/google-auth-library
419-
...
420-
var ssl_creds = grpc.Credentials.createSsl(root_certs); // load_certs typically loads a CA roots file
421-
var scope = 'https://www.googleapis.com/auth/grpc-testing';
422-
(new GoogleAuth()).getApplicationDefault(function(err, auth) {
423-
if (auth.createScopeRequired()) {
424-
auth = auth.createScoped(scope);
425-
}
426-
var call_creds = grpc.credentials.createFromGoogleCredential(auth);
427-
var combined_creds = grpc.credentials.combineChannelCredentials(ssl_creds, call_creds);
428-
var stub = new helloworld.Greeter('greeter.googleapis.com', combined_credentials);
429-
});
430-
```
431-
432-
433387
### PHP
434388

435389
####Base case - No encryption/authorization
@@ -441,7 +395,7 @@ $client = new helloworld\GreeterClient('localhost:50051', [
441395
...
442396
```
443397

444-
####Authenticate with Google using scopeless credentials (recommended approach)
398+
####Authenticate with Google
445399

446400
```php
447401
function updateAuthMetadataCallback($context)
@@ -458,16 +412,3 @@ $opts = [
458412
];
459413
$client = new helloworld\GreeterClient('greeter.googleapis.com', $opts);
460414
````
461-
462-
####Authenticate with Google using Oauth2 token (legacy approach)
463-
464-
```php
465-
// the environment variable "GOOGLE_APPLICATION_CREDENTIALS" needs to be set
466-
$scope = "https://www.googleapis.com/auth/grpc-testing";
467-
$auth = Google\Auth\ApplicationDefaultCredentials::getCredentials($scope);
468-
$opts = [
469-
'credentials' => Grpc\Credentials::createSsl(file_get_contents('roots.pem'));
470-
'update_metadata' => $auth->getUpdateMetadataFunc(),
471-
];
472-
$client = new helloworld\GreeterClient('greeter.googleapis.com', $opts);
473-
```

0 commit comments

Comments
 (0)