-
Notifications
You must be signed in to change notification settings - Fork 255
L72: Allow Call Credentials to be Specified in grpc_google_default_credentials_create
#190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
dcb83af
Add first draft
gnossen c91c6d5
Update numbering
gnossen 7fd1b68
Add Google Group discussion
gnossen 4194b78
Darn vim buffers
gnossen e9e14df
Review comments
gnossen 3cdf581
Incorporate apolcyn's feedback
gnossen 1f9d86a
Address comments
gnossen 1519611
Formatting
gnossen 6a7b2ed
Address review comments
gnossen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| Allow Call Credentials to be Specified in `grpc_google_default_credentials_create` | ||
| ---- | ||
| * Author(s): rbellevi | ||
| * Approver: markdroth | ||
| * Status: Draft | ||
| * Implemented in: Core | ||
| * Last updated: July 8th, 2020 | ||
| * Discussion at: https://groups.google.com/g/grpc-io/c/fZNm4pU8e3s/m/2Be8u1n7BQAJ | ||
|
|
||
| ## Abstract | ||
|
|
||
| This document proposes that `grpc_google_default_credentials_create` be | ||
| amended to allow the user to specify their desired call credentials. | ||
|
|
||
| ## Background | ||
|
|
||
| The Google default credentials created by the | ||
| `grpc_google_default_credentials_create` function in Core enable connection to | ||
| Google services via a combination of ALTS and SSL credentials, along with a special oauth2 | ||
| token that, by default, asserts the same identity as the channel-level ALTS credential. | ||
| The ALTS credential will use the identity in a token gathered from a request to | ||
| the | ||
| `http://metadata.google.internal/computeMetadata/v1/project/service-accounts/default/token` | ||
| endpoint. | ||
|
|
||
| In C++, auth is handled by the gRPC library itself. In wrapped | ||
| languages such as Python, however, auth is handled by external libraries which | ||
| incur a dependency on gRPC, such as [`google-auth-library-python`](https://github.com/googleapis/google-auth-library-python). | ||
| These libraries have their own implementation of the | ||
| [Application Default Credentials](https://cloud.google.com/docs/authentication/production?_ga=2.68587985.1354052904.1594166352-2074181900.1593114348#finding_credentials_automatically) | ||
| (ADC) mechanism, which uses the following strategy to create credentials: | ||
|
|
||
| 1. First, ADC checks to see if the environment variable | ||
| `GOOGLE_APPLICATION_CREDENTIALS` is set. If the variable is set, ADC uses | ||
| the service account file that the variable points to. | ||
|
|
||
| 2. If the environment variable isn't set, ADC uses the default service account | ||
| that Compute Engine, Google Kubernetes Engine, Cloud Run, App Engine, and | ||
| Cloud Functions provide, for applications that run on those services. | ||
|
|
||
| 3. If ADC can't use either of the above credentials, an error occurs. | ||
|
|
||
| Thus, if an auth library were to use the current version of | ||
| `grpc_google_default_credentials_create`, this ADC | ||
| logic would be duplicated between the auth library and gRPC Core. | ||
|
|
||
| By default, the identity pulled from the `metadata.google.internal` endpoint and | ||
| the identity from the ADC mechanism will align. | ||
|
|
||
| ## Proposal | ||
|
|
||
| I propose that the signature of `grpc_google_default_credentials_create` be | ||
| amended to the following: | ||
|
|
||
| ```C | ||
| GRPCAPI grpc_channel_credentials* | ||
| grpc_google_default_credentials_create(grpc_call_credentials* call_credentials); | ||
| ``` | ||
|
|
||
| Supplying `nullptr` for `call_credentials` will result in the current behavior | ||
| of the function. That is, Core will attach a compute engine call credential | ||
| based on the Application Default Credentials mechanism. | ||
|
|
||
| ## Rationale | ||
|
|
||
| A first attempt at this problem was the addition of a new API very similar to | ||
| `grpc_google_default_credentials_create`, but it was determined that too much | ||
| was duplicated by this implementation. | ||
|
|
||
| It is possible that the call credentials provided by the caller are not compute | ||
| engine credentials or do not assert the identity of the default service account | ||
| of the VM. Ideally, a programmatic check would verify that no such credentials | ||
| are passed in. Unfortunately, the type of credentials passed in are opaque to | ||
| both Core and the gRPC wrapped language library, making such a check impossible. | ||
| A prominent warning will be added to the documentation for the function to warn | ||
| users of such pitfalls. | ||
|
|
||
| ## Implementation | ||
|
|
||
| The implementation of this proposal will be carried out in [this PR.](https://github.com/grpc/grpc/pull/23203) | ||
|
|
||
| ## Open issues (if applicable) | ||
|
|
||
| N/A | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: s/enable/enables
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"The Google default credentials ... enables"? "Enable" agrees with the plural subject, unless we've atomized "credentials" to be singular.