Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/auth/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ async-trait.workspace = true
base64.workspace = true
bytes.workspace = true
http.workspace = true
reqwest = { workspace = true, features = ["json", "rustls-tls"] }
rustls = { workspace = true, features = ["logging", "ring", "std", "tls12"] }
reqwest = { workspace = true, features = ["json", "rustls-tls-no-provider", "rustls-tls-webpki-roots"] }
rustls = { workspace = true, features = ["logging", "std", "tls12"] }
rustls-pki-types = { workspace = true, features = ["std"] }
serde.workspace = true
serde_json.workspace = true
Expand All @@ -66,14 +66,16 @@ url.workspace = true
mutants.workspace = true

[features]
default = ["default-idtoken-backend"]
default = ["default-idtoken-backend", "default-rustls-provider"]
# The `idtoken` feature enables support to create and validate OIDC ID Tokens.
# See the create top-level documentation for more information.
idtoken = ["dep:jsonwebtoken"]
# By default this crate enables the `rust_crypto` backend. Applications can
# link `google-cloud-auth` with `default-features = false, feature = ["idtoken"]
# to select the backend themselves.
default-idtoken-backend = ["jsonwebtoken?/rust_crypto"]
# Enable a default TLS configuration for `reqwest`.
default-rustls-provider = ["reqwest/rustls-tls", "rustls/ring"]
# Do not use, this was a mistake in the 1.3 release.
jsonwebtoken = ["dep:jsonwebtoken"]

Expand Down
9 changes: 8 additions & 1 deletion src/auth/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ also describes the common terminology used with authentication, such as

# Features

- `default-rustls-provider`: enabled by default. This feature selects a default
crypto provider and trusted root certificate selection for TLS. Applications
that have specific requirements for TLS (such as exclusively using the
[aws-lc-rs], or [ring] crates) should disable this default and configure the
`reqwest` crate features to fit their needs.
- `idtoken`: disabled by default, this feature enables support to create and
verify [OIDC ID Tokens].
- `default-idtoken-backend`: enabled by default, this feature enables a default
Expand All @@ -26,13 +31,15 @@ also describes the common terminology used with authentication, such as
backend selection:
- Configure this crate with `default-features = false`, and
`features = ["idtoken"]`
- Configure the `jsonwebtoken` crate to use the desired backend.
- Select the desired backend for `jsonwebtoken`.

[authentication methods at google]: https://cloud.google.com/docs/authentication
[aws-lc-rs]: https://crates.io/crates/aws-lc-rs
[credentials]: https://cloud.google.com/docs/authentication#credentials
[credentials::credentials]: https://docs.rs/google-cloud-auth/latest/google_cloud_auth/credentials/struct.Credentials.html
[gcloud-auth]: https://crates.io/crates/gcloud-auth
[jsonwebtoken]: https://crates.io/crates/jsonwebtoken
[oidc id tokens]: https://cloud.google.com/docs/authentication/token-types#identity-tokens
[principals]: https://cloud.google.com/docs/authentication#principal
[ring]: https://crates.io/crates/ring
[tokens]: https://cloud.google.com/docs/authentication#token
17 changes: 14 additions & 3 deletions src/auth/src/credentials/service_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,9 +399,20 @@ impl ServiceAccountKey {
// Creates a signer using the private key stored in the service account file.
pub(crate) fn signer(&self) -> Result<Box<dyn Signer>> {
let private_key = self.private_key.clone();
let key_provider = CryptoProvider::get_default().map_or_else(
|| rustls::crypto::ring::default_provider().key_provider,
|p| p.key_provider,
let key_provider = CryptoProvider::get_default().map(|p| p.key_provider);
#[cfg(feature = "default-rustls-provider")]
let key_provider =
key_provider.unwrap_or_else(|| rustls::crypto::ring::default_provider().key_provider);
#[cfg(not(feature = "default-rustls-provider"))]
let key_provider = key_provider.expect(
r###"
The default rustls::CryptoProvider should be configured by the application. The
`google-cloud-auth` crate was compiled without the `default-rustls-provider`
feature. Without this feature the crate expects the application to initialize
the rustls crypto provider using `rustls::CryptoProvider::install_default()`.

Note that the application must use the exact same version of `rustls` as the
`google-cloud-auth` crate does. Otherwise `install_default()` has no effect."###,
);

let key_der = PrivateKeyDer::from_pem_slice(private_key.as_bytes()).map_err(|e| {
Expand Down
9 changes: 8 additions & 1 deletion src/auth/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
//!
//! # Features
//!
//! - `default-rustls-provider`: enabled by default. This feature selects a default
//! crypto provider and trusted root certificate selection for TLS. Applications
//! that have specific requirements for TLS (such as exclusively using the
//! [aws-lc-rs], or [ring] crates) should disable this default and configure the
//! `reqwest` crate features to fit their needs.
//! - `idtoken`: disabled by default, this feature enables support to create and
//! verify [OIDC ID Tokens].
//! - `default-idtoken-backend`: enabled by default, this feature enables a default
Expand All @@ -36,8 +41,10 @@
//! backend selection:
//! - Configure this crate with `default-features = false`, and
//! `features = ["idtoken"]`
//! - Configure the `jsonwebtoken` crate to use the desired backend.
//! - Select the desired backend for `jsonwebtoken`.
//!
//! [aws-lc-rs]: https://crates.io/crates/aws-lc-rs
//! [ring]: https://crates.io/crates/ring
//! [jsonwebtoken]: https://crates.io/crates/jsonwebtoken
//! [oidc id tokens]: https://cloud.google.com/docs/authentication/token-types#identity-tokens
//! [Authentication methods at Google]: https://cloud.google.com/docs/authentication
Expand Down
2 changes: 1 addition & 1 deletion src/gax-internal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ tonic-prost = { workspace = true, optional = true }
tower = { workspace = true, optional = true }
tracing = { workspace = true, optional = true }
# Local crates
google-cloud-auth = { workspace = true, optional = true }
google-cloud-auth = { workspace = true, optional = true, features = ["default-rustls-provider"] }
gax = { workspace = true, optional = true }
rpc = { workspace = true, optional = true }
wkt = { workspace = true, optional = true }
Expand Down
18 changes: 9 additions & 9 deletions src/storage/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ hex = { workspace = true, features = ["std"] }
# Transitive dependencies. Used for minimal version selection.
mime.workspace = true
# Local crates
google-cloud-auth.workspace = true
gax.workspace = true
gaxi = { workspace = true, features = ["_internal-common", "_internal-grpc-client"] }
gtype.workspace = true
iam_v1.workspace = true
longrunning.workspace = true
lro.workspace = true
rpc.workspace = true
wkt.workspace = true
google-cloud-auth = { workspace = true, features = ["default-rustls-provider"] }
gax.workspace = true
gaxi = { workspace = true, features = ["_internal-common", "_internal-grpc-client"] }
gtype.workspace = true
iam_v1.workspace = true
longrunning.workspace = true
lro.workspace = true
rpc.workspace = true
wkt.workspace = true

[features]
unstable-stream = ["reqwest/stream"]
Expand Down
2 changes: 1 addition & 1 deletion tests/crypto-providers/test-gaxi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,5 @@ features = ["_internal-http-client"]
[features]
with-default = [
# TODO(#4170) - enable when gax-internal is ready
# "google-cloud-gax-internal/_default-tls"
# "google-cloud-gax-internal/_default-rustls-provider"
]
Loading