feat: support default browser for CLI (#345)

This commit is contained in:
Kevin Yue
2024-04-15 08:27:33 -04:00
committed by GitHub
parent 18ae1c5fa5
commit d94d730a44
12 changed files with 96 additions and 11 deletions

View File

@@ -11,7 +11,10 @@ use serde_json::json;
use tauri::{App, AppHandle, RunEvent};
use tempfile::NamedTempFile;
use crate::auth_window::{portal_prelogin, AuthWindow};
use crate::{
auth_window::{portal_prelogin, AuthWindow},
browser_authenticator::BrowserAuthenticator,
};
const VERSION: &str = concat!(env!("CARGO_PKG_VERSION"), " (", compile_time::date_str!(), ")");
@@ -37,6 +40,8 @@ struct Cli {
ignore_tls_errors: bool,
#[arg(long)]
clean: bool,
#[arg(long)]
default_browser: bool,
}
impl Cli {
@@ -56,6 +61,15 @@ impl Cli {
None => portal_prelogin(&self.server, &gp_params).await?,
};
if self.default_browser {
let browser_auth = BrowserAuthenticator::new(&saml_request);
browser_auth.authenticate()?;
info!("Please continue the authentication process in the default browser");
return Ok(());
}
self.saml_request.replace(saml_request);
let app = create_app(self.clone())?;