Skip to content

Commit 15bbb88

Browse files
authored
Merge pull request #539 from paolobarbolini/reduce-yup-oauth2-features
Reduce yup-oauth2 features
2 parents b5e3f68 + 1c6581c commit 15bbb88

File tree

6 files changed

+56
-13
lines changed

6 files changed

+56
-13
lines changed

etc/api/shared.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ directories:
9494
# The subdirectory to contain documentation from all APIs and related programs
9595
doc_subdir: doc
9696
cargo:
97-
build_version: "6.0.0"
97+
build_version: "7.0.0"
9898
repo_base_url: https://github.com/Byron/google-apis-rs
9999
authors:
100100
# don't forget to possibly add them to copyright authors

google-apis-common/Cargo.toml

+19-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "google-apis-common"
3-
version = "7.0.0"
3+
version = "8.0.0"
44
authors = ["Sebastian Thiel <[email protected]>"]
55
repository = "https://github.com/Byron/google-apis-rs"
66
homepage = "https://github.com/Byron/google-apis-rs/google-apis-common"
@@ -27,4 +27,21 @@ serde_json = "1"
2727
serde_with = "3"
2828
tokio = { version = "1", features = ["time"] }
2929
url = "2"
30-
yup-oauth2 = { version = "12", optional = true }
30+
yup-oauth2 = { version = "12", default-features = false, optional = true }
31+
32+
[features]
33+
## Enable OAuth 2.0 authentication support via the `yup-oauth2` crate
34+
yup-oauth2 = ["dep:yup-oauth2"]
35+
36+
## Enable Service Account support for the `yup-oauth2 crate
37+
yup-oauth2-service-account = ["yup-oauth2", "yup-oauth2/service-account"]
38+
39+
## Use AWS-LC as the crypto backend
40+
##
41+
## Either this feature or `ring` must be enabled when enabling `yup-oauth2-service-account`
42+
aws-lc-rs = ["yup-oauth2?/aws-lc-rs"]
43+
44+
## Use Ring as the crypto backend
45+
##
46+
## Either this feature or `aws-lc-rs` must be enabled when enabling `yup-oauth2-service-account`
47+
ring = ["yup-oauth2?/ring"]

google-clis-common/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# This library is just to try out the code that should ultimately go into the code generator !
33
[package]
44
name = "google-clis-common"
5-
version = "7.0.0"
5+
version = "8.0.0"
66
authors = ["Sebastian Thiel <[email protected]>"]
77
repository = "https://github.com/Byron/google-apis-rs"
88
homepage = "https://github.com/Byron/google-apis-rs/google-clis-common"
@@ -21,4 +21,4 @@ mime = "0.3"
2121
serde = "1"
2222
serde_json = "1"
2323
strsim = "0.11"
24-
yup-oauth2 = "12"
24+
yup-oauth2 = { version = "12", default-features = false }

src/generator/templates/Cargo.toml.mako

+20-5
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ clap = "2"
3232
http-body-util = "0.1"
3333
% endif
3434
hyper = "1"
35-
hyper-rustls = { version = "0.27", default-features = false }
35+
hyper-rustls = { version = "0.27", default-features = false, features = ["http2", "rustls-native-certs", "native-tokio"] }
3636
hyper-util = "0.1"
3737
mime = "0.3"
3838
serde = { version = "1", features = ["derive"] }
@@ -47,11 +47,11 @@ tokio = { version = "1", features = ["full"] }
4747
% endif
4848
url = "2"
4949
utoipa = { version = "4", optional = true }
50-
yup-oauth2 = { version = "12", optional = true }
50+
yup-oauth2 = { version = "12", default-features = false, optional = true }
5151
52-
google-apis-common = { path = "../../google-apis-common", version = "7" }
52+
google-apis-common = { path = "../../google-apis-common", version = "8" }
5353
% if cargo.get('is_executable'):
54-
google-clis-common = { path = "../../google-clis-common", version = "7" }
54+
google-clis-common = { path = "../../google-clis-common", version = "8" }
5555
% endif
5656
5757
<%
@@ -71,7 +71,22 @@ version = "${util.crate_version()}"
7171

7272
% if not cargo.get('is_executable'):
7373
[features]
74-
default = ["yup-oauth2"]
74+
default = ["yup-oauth2", "ring"]
7575
utoipa = ["dep:utoipa"]
76+
77+
## Enable OAuth 2.0 authentication support via the `yup-oauth2` crate
7678
yup-oauth2 = ["dep:yup-oauth2", "google-apis-common/yup-oauth2"]
79+
80+
## Enable Service Account support for the `yup-oauth2 crate
81+
yup-oauth2-service-account = ["yup-oauth2", "yup-oauth2/service-account", "google-apis-common/yup-oauth2-service-account"]
82+
83+
## Use AWS-LC as the crypto backend
84+
##
85+
## Either this feature or `ring` must be enabled when enabling `yup-oauth2-service-account`
86+
aws-lc-rs = ["yup-oauth2?/aws-lc-rs", "google-apis-common/aws-lc-rs", "hyper-rustls/aws-lc-rs"]
87+
88+
## Use Ring as the crypto backend
89+
##
90+
## Either this feature or `aws-lc-rs` must be enabled when enabling `yup-oauth2-service-account`
91+
ring = ["yup-oauth2?/ring", "google-apis-common/ring", "hyper-rustls/ring"]
7792
% endif

src/generator/templates/api/lib/lib.mako

+13-2
Original file line numberDiff line numberDiff line change
@@ -263,9 +263,20 @@ let secret: yup_oauth2::ApplicationSecret = Default::default();
263263
// what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
264264
// retrieve them from storage.
265265
% endif
266-
let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
266+
let connector = hyper_rustls::HttpsConnectorBuilder::new()
267+
.with_native_roots()
268+
.unwrap()
269+
.https_only()
270+
.enable_http2()
271+
.build();
272+
273+
let executor = hyper_util::rt::TokioExecutor::new();
274+
let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
267275
secret,
268276
yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
277+
yup_oauth2::client::CustomHyperClientBuilder::from(
278+
hyper_util::client::legacy::Client::builder(executor).build(connector),
279+
),
269280
).build().await.unwrap();
270281
271282
let client = hyper_util::client::legacy::Client::builder(
@@ -276,7 +287,7 @@ let client = hyper_util::client::legacy::Client::builder(
276287
.with_native_roots()
277288
.unwrap()
278289
.https_or_http()
279-
.enable_http1()
290+
.enable_http2()
280291
.build()
281292
);
282293
let mut hub = ${hub_type}::new(client, auth);\

src/generator/templates/cli/main.rs.mako

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ async fn main() {
3939
.with_native_roots()
4040
.unwrap()
4141
.https_or_http()
42-
.enable_http1()
42+
.enable_http2()
4343
.build();
4444

4545
match Engine::new(matches, connector).await {

0 commit comments

Comments
 (0)