mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2025-05-20 07:26:58 -04:00
Enhancements and Bug Fixes: Align Pre-login Behavior, TLS Error Ignorance, GUI Auto-Launch, and Documentation Improvements (#291)
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
use clap::Parser;
|
||||
use gpapi::{
|
||||
auth::{SamlAuthData, SamlAuthResult},
|
||||
clap::args::Os,
|
||||
gp_params::{ClientOs, GpParams},
|
||||
utils::{normalize_server, openssl},
|
||||
GP_USER_AGENT,
|
||||
};
|
||||
@@ -26,23 +28,35 @@ struct Cli {
|
||||
saml_request: Option<String>,
|
||||
#[arg(long, default_value = GP_USER_AGENT)]
|
||||
user_agent: String,
|
||||
#[arg(long, default_value = "Linux")]
|
||||
os: Os,
|
||||
#[arg(long)]
|
||||
os_version: Option<String>,
|
||||
#[arg(long)]
|
||||
hidpi: bool,
|
||||
#[arg(long)]
|
||||
fix_openssl: bool,
|
||||
#[arg(long)]
|
||||
ignore_tls_errors: bool,
|
||||
#[arg(long)]
|
||||
clean: bool,
|
||||
}
|
||||
|
||||
impl Cli {
|
||||
async fn run(&mut self) -> anyhow::Result<()> {
|
||||
if self.ignore_tls_errors {
|
||||
info!("TLS errors will be ignored");
|
||||
}
|
||||
|
||||
let mut openssl_conf = self.prepare_env()?;
|
||||
|
||||
self.server = normalize_server(&self.server)?;
|
||||
let gp_params = self.build_gp_params();
|
||||
|
||||
// Get the initial SAML request
|
||||
let saml_request = match self.saml_request {
|
||||
Some(ref saml_request) => saml_request.clone(),
|
||||
None => portal_prelogin(&self.server, &self.user_agent).await?,
|
||||
None => portal_prelogin(&self.server, &gp_params).await?,
|
||||
};
|
||||
|
||||
self.saml_request.replace(saml_request);
|
||||
@@ -82,10 +96,22 @@ impl Cli {
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
fn build_gp_params(&self) -> GpParams {
|
||||
let gp_params = GpParams::builder()
|
||||
.user_agent(&self.user_agent)
|
||||
.client_os(ClientOs::from(&self.os))
|
||||
.os_version(self.os_version.clone())
|
||||
.ignore_tls_errors(self.ignore_tls_errors)
|
||||
.build();
|
||||
|
||||
gp_params
|
||||
}
|
||||
|
||||
async fn saml_auth(&self, app_handle: AppHandle) -> anyhow::Result<SamlAuthData> {
|
||||
let auth_window = AuthWindow::new(app_handle)
|
||||
.server(&self.server)
|
||||
.user_agent(&self.user_agent)
|
||||
.gp_params(self.build_gp_params())
|
||||
.saml_request(self.saml_request.as_ref().unwrap())
|
||||
.clean(self.clean);
|
||||
|
||||
|
Reference in New Issue
Block a user