Skip to content

Reduce yup-oauth2 features #539

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 2 commits into from
Feb 26, 2025
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
2 changes: 1 addition & 1 deletion etc/api/shared.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ directories:
# The subdirectory to contain documentation from all APIs and related programs
doc_subdir: doc
cargo:
build_version: "6.0.0"
build_version: "7.0.0"
repo_base_url: https://github.com/Byron/google-apis-rs
authors:
# don't forget to possibly add them to copyright authors
Expand Down
21 changes: 19 additions & 2 deletions google-apis-common/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "google-apis-common"
version = "7.0.0"
version = "8.0.0"
authors = ["Sebastian Thiel <[email protected]>"]
repository = "https://github.com/Byron/google-apis-rs"
homepage = "https://github.com/Byron/google-apis-rs/google-apis-common"
Expand All @@ -27,4 +27,21 @@ serde_json = "1"
serde_with = "3"
tokio = { version = "1", features = ["time"] }
url = "2"
yup-oauth2 = { version = "12", optional = true }
yup-oauth2 = { version = "12", default-features = false, optional = true }

[features]
## Enable OAuth 2.0 authentication support via the `yup-oauth2` crate
yup-oauth2 = ["dep:yup-oauth2"]

## Enable Service Account support for the `yup-oauth2 crate
yup-oauth2-service-account = ["yup-oauth2", "yup-oauth2/service-account"]

## Use AWS-LC as the crypto backend
##
## Either this feature or `ring` must be enabled when enabling `yup-oauth2-service-account`
aws-lc-rs = ["yup-oauth2?/aws-lc-rs"]

## Use Ring as the crypto backend
##
## Either this feature or `aws-lc-rs` must be enabled when enabling `yup-oauth2-service-account`
ring = ["yup-oauth2?/ring"]
4 changes: 2 additions & 2 deletions google-clis-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# This library is just to try out the code that should ultimately go into the code generator !
[package]
name = "google-clis-common"
version = "7.0.0"
version = "8.0.0"
authors = ["Sebastian Thiel <[email protected]>"]
repository = "https://github.com/Byron/google-apis-rs"
homepage = "https://github.com/Byron/google-apis-rs/google-clis-common"
Expand All @@ -21,4 +21,4 @@ mime = "0.3"
serde = "1"
serde_json = "1"
strsim = "0.11"
yup-oauth2 = "12"
yup-oauth2 = { version = "12", default-features = false }
25 changes: 20 additions & 5 deletions src/generator/templates/Cargo.toml.mako
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ clap = "2"
http-body-util = "0.1"
% endif
hyper = "1"
hyper-rustls = { version = "0.27", default-features = false }
hyper-rustls = { version = "0.27", default-features = false, features = ["http2", "rustls-native-certs", "native-tokio"] }
Copy link
Owner

Choose a reason for hiding this comment

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

How come these are enabled by default now?

Copy link
Contributor Author

@paolobarbolini paolobarbolini Feb 17, 2025

Choose a reason for hiding this comment

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

They were already enabled by yup-oauth2 before, but since we now compile it without the hyper-rustls feature we have to enable them ourselves.

hyper-util = "0.1"
mime = "0.3"
serde = { version = "1", features = ["derive"] }
Expand All @@ -47,11 +47,11 @@ tokio = { version = "1", features = ["full"] }
% endif
url = "2"
utoipa = { version = "4", optional = true }
yup-oauth2 = { version = "12", optional = true }
yup-oauth2 = { version = "12", default-features = false, optional = true }

google-apis-common = { path = "../../google-apis-common", version = "7" }
google-apis-common = { path = "../../google-apis-common", version = "8" }
% if cargo.get('is_executable'):
google-clis-common = { path = "../../google-clis-common", version = "7" }
google-clis-common = { path = "../../google-clis-common", version = "8" }
% endif

<%
Expand All @@ -71,7 +71,22 @@ version = "${util.crate_version()}"

% if not cargo.get('is_executable'):
[features]
default = ["yup-oauth2"]
default = ["yup-oauth2", "ring"]
utoipa = ["dep:utoipa"]

## Enable OAuth 2.0 authentication support via the `yup-oauth2` crate
yup-oauth2 = ["dep:yup-oauth2", "google-apis-common/yup-oauth2"]

## Enable Service Account support for the `yup-oauth2 crate
yup-oauth2-service-account = ["yup-oauth2", "yup-oauth2/service-account", "google-apis-common/yup-oauth2-service-account"]

## Use AWS-LC as the crypto backend
##
## Either this feature or `ring` must be enabled when enabling `yup-oauth2-service-account`
aws-lc-rs = ["yup-oauth2?/aws-lc-rs", "google-apis-common/aws-lc-rs", "hyper-rustls/aws-lc-rs"]

## Use Ring as the crypto backend
##
## Either this feature or `aws-lc-rs` must be enabled when enabling `yup-oauth2-service-account`
ring = ["yup-oauth2?/ring", "google-apis-common/ring", "hyper-rustls/ring"]
% endif
15 changes: 13 additions & 2 deletions src/generator/templates/api/lib/lib.mako
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,20 @@ let secret: yup_oauth2::ApplicationSecret = Default::default();
// what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
// retrieve them from storage.
% endif
let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
let connector = hyper_rustls::HttpsConnectorBuilder::new()
.with_native_roots()
.unwrap()
.https_only()
.enable_http2()
.build();

let executor = hyper_util::rt::TokioExecutor::new();
let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
secret,
yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
yup_oauth2::client::CustomHyperClientBuilder::from(
hyper_util::client::legacy::Client::builder(executor).build(connector),
),
).build().await.unwrap();

let client = hyper_util::client::legacy::Client::builder(
Expand All @@ -276,7 +287,7 @@ let client = hyper_util::client::legacy::Client::builder(
.with_native_roots()
.unwrap()
.https_or_http()
.enable_http1()
.enable_http2()
.build()
);
let mut hub = ${hub_type}::new(client, auth);\
Expand Down
2 changes: 1 addition & 1 deletion src/generator/templates/cli/main.rs.mako
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async fn main() {
.with_native_roots()
.unwrap()
.https_or_http()
.enable_http1()
.enable_http2()
.build();

match Engine::new(matches, connector).await {
Expand Down
Loading