From 07f4d8b1fb5577c43afe30709376b66da1339711 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phan=20Kochen?= Date: Tue, 27 Feb 2024 10:40:28 +0100 Subject: [PATCH] Fix state test --- examples/tester.rs | 6 +++++- src/lib.rs | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/examples/tester.rs b/examples/tester.rs index 455db27..ec10827 100644 --- a/examples/tester.rs +++ b/examples/tester.rs @@ -25,7 +25,11 @@ async fn main() { match cmd[0] { "echo" => println!("ok\t{}", cmd[1]), "auth" => match client.start_auth(&cmd[1]).await { - Ok(url) => println!("ok\t{}", url), + Ok(mut url) => { + url.query_pairs_mut() + .append_pair("state", cmd.get(2).cloned().unwrap_or_default()); + println!("ok\t{}", url); + } Err(err) => println!("err\t{}", err), }, "verify" => match client.verify(&cmd[1]).await { diff --git a/src/lib.rs b/src/lib.rs index 6fc5f48..4f8be1c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -255,6 +255,9 @@ impl Client { /// If performing the redirect in the HTTP response, the recommended method is to send a 303 /// HTTP status code with the `Location` header set to the URL. But other solutions are /// possible, such as fetching this URL using a request from client-side JavaScript. + /// + /// The caller may add a `state` query parameter to the returned URL, which is passed verbatim + /// to the redirect URI after the user returns. pub async fn start_auth(&self, email: &str) -> Result { let discovery = self .store