From 6c433a6fb506b94c1cbcda0f288574fecf4dbaf3 Mon Sep 17 00:00:00 2001 From: Michael Bryant Date: Mon, 25 Jan 2021 09:53:22 -0800 Subject: [PATCH 1/3] installed flow: support urls with existing query params --- src/installed.rs | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/installed.rs b/src/installed.rs index 41507bb..b0a390a 100644 --- a/src/installed.rs +++ b/src/installed.rs @@ -36,8 +36,18 @@ where let scopes_string = crate::helper::join(scopes, " "); url.push_str(auth_uri); + + if !url.contains('?') { + url.push('?'); + } else { + match url.chars().last() { + Some('?') | None => {}, + Some(_) => url.push('&'), + } + } + vec![ - format!("?scope={}", scopes_string), + format!("scope={}", scopes_string), "&access_type=offline".to_string(), format!("&redirect_uri={}", redirect_uri.unwrap_or(OOB_REDIRECT_URI)), "&response_type=code".to_string(), @@ -371,6 +381,23 @@ mod tests { ); } + #[test] + fn test_request_url_builder_appends_queries() { + assert_eq!( + "https://accounts.google.\ + com/o/oauth2/auth?unknown=testing&scope=email%20profile&access_type=offline&redirect_uri=urn:ietf:wg:oauth:2.0:\ + oob&response_type=code&client_id=812741506391-h38jh0j4fv0ce1krdkiq0hfvt6n5amr\ + f.apps.googleusercontent.com", + build_authentication_request_url( + "https://accounts.google.com/o/oauth2/auth?unknown=testing", + "812741506391-h38jh0j4fv0ce1krdkiq0hfvt6n5am\ + rf.apps.googleusercontent.com", + &["email", "profile"], + None + ) + ); + } + #[tokio::test] async fn test_server_random_local_port() { let addr1 = InstalledFlowServer::run().unwrap().local_addr(); From 3ca01649081eef9dad442812b0879efabacd959f Mon Sep 17 00:00:00 2001 From: Michael Bryant Date: Mon, 25 Jan 2021 14:13:42 -0800 Subject: [PATCH 2/3] fix lint --- src/installed.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/installed.rs b/src/installed.rs index b0a390a..402ff61 100644 --- a/src/installed.rs +++ b/src/installed.rs @@ -41,7 +41,7 @@ where url.push('?'); } else { match url.chars().last() { - Some('?') | None => {}, + Some('?') | None => {} Some(_) => url.push('&'), } } From 75e402412f59e02a9c1941450321760c69ee256f Mon Sep 17 00:00:00 2001 From: Lewin Bormann Date: Fri, 29 Jan 2021 21:47:05 +0100 Subject: [PATCH 3/3] Release v5.0.2 Includes fix to #141 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 261e44f..c007efd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "yup-oauth2" -version = "5.0.1" +version = "5.0.2" authors = ["Sebastian Thiel ", "Lewin Bormann "] repository = "https://github.com/dermesser/yup-oauth2" description = "An oauth2 implementation, providing the 'device', 'service account' and 'installed' authorization flows"