Skip to content

feat(grpc): Google call credentials#2610

Open
arjan-bal wants to merge 12 commits intohyperium:masterfrom
arjan-bal:gcp-call-creds
Open

feat(grpc): Google call credentials#2610
arjan-bal wants to merge 12 commits intohyperium:masterfrom
arjan-bal:gcp-call-creds

Conversation

@arjan-bal
Copy link
Copy Markdown
Collaborator

@arjan-bal arjan-bal commented Apr 28, 2026

This PR introduces a CallCredentials implementation that injects authentication tokens based on GCP Application Default Credentials (ADC), leveraging the official google-cloud-auth crate.

To avoid pulling in Google-specific dependencies by default, the implementation is housed in a new grpc-google crate. Additionally, to facilitate unit testing, the following types from the grpc crate are now exported:

  • The attributes module.
  • Constructors for the static data structs CallDetails and ClientConnectionSecurityInfo.

The code was manually tested by running this example, which will be included in a follow-up PR.

Comment thread grpc-google/src/lib.rs
#[trait_variant::make(Send)]
pub trait TokenProvider: Sync + Debug + 'static {
/// Returns an authentication token.
async fn get_token(&self) -> Result<String, String>;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Are we sure about String error type? It loses some context error context.

Comment thread grpc-google/src/lib.rs
S: Into<String>,
{
let credentials = google_cloud_auth::credentials::Builder::default()
.with_scopes(scopes)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For my education: Is scopes a mandatory argument and the default scope documented somewhere?
What happens if this isn't specified?

Copy link
Copy Markdown
Collaborator

@dfawley dfawley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good except for the nit about the comments.

Comment thread grpc-google/src/lib.rs
*
*/

//! GCP Credentials implementation for gRPC.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please spell out what GCP stands for and ideally link to a site with more info.

Comment thread grpc-google/src/lib.rs
//! GCP Credentials implementation for gRPC.
//!
//! This crate provides a way to create gRPC channel credentials that
//! automatically fetch and attach Google Cloud Platform (GCP) authentication
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, just move the explanation from here then?

Comment thread grpc-google/Cargo.toml
@@ -0,0 +1,22 @@
[package]
name = "grpc-google"
version = "0.9.0-alpha.1"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0.0.0-alpha?

Comment thread grpc-google/src/lib.rs
format!("invalid values in authorization header value: {}", e),
)
})?;
value.set_sensitive(true);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Outside the scope of this PR: Is this not the default? I suspect we would want it to be.

@arjan-bal arjan-bal assigned arjan-bal and unassigned sauravzg and dfawley Apr 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants