feat: support specify the browser to use

Related: #405, #407, #397
This commit is contained in:
Kevin Yue
2024-08-14 21:27:01 +08:00
parent c2a6a436a5
commit 9460d498fc
7 changed files with 108 additions and 13 deletions

View File

@@ -40,6 +40,8 @@ struct Cli {
clean: bool,
#[arg(long)]
default_browser: bool,
#[arg(long)]
external_browser: Option<String>,
}
impl Cli {
@@ -59,8 +61,15 @@ impl Cli {
None => portal_prelogin(&self.server, &gp_params).await?,
};
if self.default_browser {
let browser_auth = BrowserAuthenticator::new(&saml_request);
let browser_auth = if let Some(external_browser) = &self.external_browser {
Some(BrowserAuthenticator::new_with_browser(&saml_request, external_browser))
} else if self.default_browser {
Some(BrowserAuthenticator::new(&saml_request))
} else {
None
};
if let Some(browser_auth) = browser_auth {
browser_auth.authenticate()?;
info!("Please continue the authentication process in the default browser");