From 79b82fd2b30e5029590f4b9c98177a266b20694e Mon Sep 17 00:00:00 2001 From: Ralf Grubenmann Date: Thu, 3 Sep 2026 10:44:53 +0200 Subject: [PATCH] feat: open browser automatically on login --- Cargo.lock | 30 ++++++++++++++++++++++++++++++ Cargo.toml | 1 + src/cli/cmd/login.rs | 8 ++++++++ 3 files changed, 39 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 5e0d8a6..682cb11 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3524,6 +3524,25 @@ version = "2.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a756c3fac73139e83f14c2d742155dd2b78d3ee56597b419a0579b7bdd6dd78" +[[package]] +name = "is-docker" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "928bae27f42bc99b60d9ac7334e3a21d10ad8f1835a4e12ec3ec0464765ed1b3" +dependencies = [ + "once_cell", +] + +[[package]] +name = "is-wsl" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "173609498df190136aa7dea1a91db051746d339e18476eed5ca40521f02d7aa5" +dependencies = [ + "is-docker", + "once_cell", +] + [[package]] name = "is_executable" version = "1.0.6" @@ -4301,6 +4320,16 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" +[[package]] +name = "open" +version = "5.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c603ab8300cf18bc3b14146b19fe3dfcc4843ae5a400cd0e7a30b95aa366634" +dependencies = [ + "is-wsl", + "libc", +] + [[package]] name = "openidconnect" version = "4.0.1" @@ -5186,6 +5215,7 @@ dependencies = [ "linux-keyutils-keyring-store", "log", "md5", + "open", "openidconnect", "openssl", "predicates", diff --git a/Cargo.toml b/Cargo.toml index f165a5a..ce78cfc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -64,6 +64,7 @@ md5 = "0.8.1" ulid = "3.0.0" keyring-core = { version = "1.0.0", features = ["sample"] } whoami = "2.1.3" +open = "5.4.3" [target.'cfg(target_os = "windows")'.dependencies] windows-native-keyring-store = "1.1.0" diff --git a/src/cli/cmd/login.rs b/src/cli/cmd/login.rs index d372c87..7de9ee1 100644 --- a/src/cli/cmd/login.rs +++ b/src/cli/cmd/login.rs @@ -103,6 +103,14 @@ impl Input { ctx.write_result(&info).await.context(WriteResultSnafu)?; + // open the browser, if there is one + open::that(info.authorization_url.as_ref()).unwrap_or_else(|_| { + println!( + "Couldn't open browser, please navigate to {}", + info.authorization_url + ); + }); + if steps == Steps::Complete { ctx.write_result(&SimpleMessage { message: "Waiting for authorization response…".into(),