|
| 1 | +# L126: C-core: Support ALTS Hard Bound Call Credentials in Google Default Credentials |
| 2 | + |
| 3 | +* Author(s): anniefrchz |
| 4 | +* Approver: markdroth |
| 5 | +* Status: In Review |
| 6 | +* Implemented in: C++ |
| 7 | +* Last updated: 2025-08-22 |
| 8 | +* Discussion at: |
| 9 | + https://groups.google.com/g/grpc-io/c/7rRWghiS95E/m/nENwU3BtCgAJ |
| 10 | + |
| 11 | +## Abstract |
| 12 | + |
| 13 | +This proposal outlines a change to the gRPC Core C-API to support |
| 14 | +alts-credentials configurations within `grpc_google_default_credentials`. This |
| 15 | +enhancement specifically allows a secondary set of call credentials for ALTS to |
| 16 | +be provided alongside the default credentials. |
| 17 | + |
| 18 | +## Background |
| 19 | + |
| 20 | +The existing `grpc_google_default_credentials_create` function allows the |
| 21 | +configuration of a single set of call credentials. In some scenarios, a client |
| 22 | +would want to communicate with services that support hard bound credentials over |
| 23 | +ALTS. This proposal addresses the possibility to support this use case on a |
| 24 | +channel initialized with Google's default credentials. |
| 25 | + |
| 26 | +## Proposal |
| 27 | + |
| 28 | +### C-Core changes |
| 29 | + |
| 30 | +This proposal modifies the function `grpc_google_default_credentials_create` to |
| 31 | +add a second set of call credentials. |
| 32 | + |
| 33 | +```c |
| 34 | +GRPCAPI grpc_channel_credentials* grpc_google_default_credentials_create( |
| 35 | + grpc_call_credentials* tls_credentials, |
| 36 | + grpc_call_credentials* alts_credentials); |
| 37 | +``` |
| 38 | +
|
| 39 | +This new function accepts two arguments: |
| 40 | +
|
| 41 | +1. `tls_credentials`: The primary call credentials, consistent with the |
| 42 | + existing API. This is usually used for TLS connections. |
| 43 | +2. `alts_credentials`: A secondary set of call credentials to be used |
| 44 | + specifically for ALTS connections. |
| 45 | +
|
| 46 | +After a secure connection is established, the gRPC runtime identifies the |
| 47 | +connection's transport security type, which indicates whether the underlying |
| 48 | +connection is using a protocol like ALTS or TLS. The runtime then selects the |
| 49 | +appropriate call credentials for that connection. If the determined transport |
| 50 | +security type is ALTS, the provided alts_credentials will be used. For all other |
| 51 | +transport types, the primary call_credentials are used, maintaining the default |
| 52 | +behavior. |
| 53 | +
|
| 54 | +The hard-bound call credentials will be created through |
| 55 | +`grpc_google_compute_engine_credentials_create`. This function will have a |
| 56 | +`grpc_google_compute_engine_credentials_options` parameter. The caller will be |
| 57 | +able to obtain ALTS hard-bound credentials instead of the standard default call |
| 58 | +credentials by toggling the corresponding flag alts_hard_bound in the structure. |
| 59 | +
|
| 60 | +```c |
| 61 | +typedef struct { |
| 62 | + bool alts_hard_bound = false; |
| 63 | +} grpc_google_compute_engine_credentials_options; |
| 64 | +
|
| 65 | +GRPCAPI grpc_call_credentials* grpc_google_compute_engine_credentials_create( |
| 66 | + grpc_google_compute_engine_credentials_options* options); |
| 67 | +``` |
| 68 | + |
| 69 | +### C++ Changes |
| 70 | + |
| 71 | +Additionally, external customers for the public C++ library will de able to |
| 72 | +create GoogleDefaultCredentials by setting a GoogleDefaultCredentialsOptions |
| 73 | +value into their standard call. For this addition, the proposed struct |
| 74 | +`GoogleDefaultCredentialsOptions` will hold a boolean that will be default to |
| 75 | +false. Callers of the GoogleDefaultCredentials() API will be able to set |
| 76 | +use_alts_call_credentials to false value, if required to indicate the request |
| 77 | +for the underlying bound token call credentials. |
| 78 | + |
| 79 | +```c++ |
| 80 | +struct GoogleDefaultCredentialsOptions { |
| 81 | + bool use_alts_call_credentials = false; |
| 82 | +}; |
| 83 | + |
| 84 | +std::shared_ptr<ChannelCredentials> GoogleDefaultCredentials( |
| 85 | + const GoogleDefaultCredentialsOptions& options = |
| 86 | + GoogleDefaultCredentialsOptions()); |
| 87 | +``` |
| 88 | +
|
| 89 | +### Other C-Core languages |
| 90 | +
|
| 91 | +Other wrapped languages are not in scope for changes to their public API, and |
| 92 | +further discussion is needed if an implementation is scoped. |
| 93 | +
|
| 94 | +## Rationale |
| 95 | +
|
| 96 | +The primary motivation for this change is to enable seamless support for hybrid |
| 97 | +security environments on a single gRPC channel. |
| 98 | +
|
| 99 | +The advantages of this approach are: |
| 100 | +
|
| 101 | +* Consolidated API: It avoids introducing a new function for a closely related |
| 102 | + feature, keeping the API surface clean and concise. An initial review of the |
| 103 | + pull request favored this path to avoid an unnecessary new API. |
| 104 | +* Improved Discoverability: Developers only need to be aware of a single |
| 105 | + function for creating Google default credentials. The optional nature of the |
| 106 | + second parameter would make the basic use case simple while allowing for the |
| 107 | + more advanced dual-credential scenario when needed. |
| 108 | +* Logical Cohesion: Since the new functionality is an extension of the |
| 109 | + existing credential creation process, incorporating it into the original |
| 110 | + function maintains logical cohesion. The function's responsibility is |
| 111 | + expanded rather than duplicated across multiple functions. |
| 112 | +* Cross-language support: Since wrapper languages like Python use this API, |
| 113 | + supporting ALTS bound credentials will be straightforward by passing them as |
| 114 | + an argument to the existing API. |
| 115 | +
|
| 116 | +## Implementation |
| 117 | +
|
| 118 | +The implementation for this proposal has been completed and merged into the main |
| 119 | +gRPC repository. |
| 120 | +
|
| 121 | +* Pull Request: grpc/grpc#39770 |
0 commit comments