mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2026-11-23 07:46:13 -05:00
feat: release GP Connect 3.3.0 with Native Shell support
This commit is contained in:
226 files changed
+7700
-5225
No files matched your search
@@ -19,6 +19,7 @@ pub struct SamlPrelogin {
|
||||
region: String,
|
||||
is_gateway: bool,
|
||||
saml_request: String,
|
||||
saml_method: String,
|
||||
support_default_browser: bool,
|
||||
}
|
||||
|
||||
@@ -27,6 +28,10 @@ impl SamlPrelogin {
|
||||
&self.region
|
||||
}
|
||||
|
||||
pub fn saml_method(&self) -> &str {
|
||||
&self.saml_method
|
||||
}
|
||||
|
||||
pub fn saml_request(&self) -> &str {
|
||||
&self.saml_request
|
||||
}
|
||||
@@ -171,7 +176,7 @@ pub async fn prelogin(portal: &str, gp_params: &GpParams, options: PreloginOptio
|
||||
|
||||
debug!("Prelogin response XML: {}", res_xml);
|
||||
|
||||
let prelogin = parse_res_xml(&res_xml, is_gateway).map_err(|err| {
|
||||
let prelogin = parse_prelogin_response(&res_xml, is_gateway).map_err(|err| {
|
||||
warn!("Parse response error, response: {}", res_xml);
|
||||
PortalError::PreloginError(err.to_string())
|
||||
})?;
|
||||
@@ -187,7 +192,8 @@ fn request_param<'a>(params: &'a crate::params::RequestParams, name: &str) -> Op
|
||||
.find_map(|(key, value)| (key == name).then_some(value.as_str()))
|
||||
}
|
||||
|
||||
fn parse_res_xml(res_xml: &str, is_gateway: bool) -> anyhow::Result<Prelogin> {
|
||||
/// Parse server authentication metadata without performing a network request.
|
||||
pub fn parse_prelogin_response(res_xml: &str, is_gateway: bool) -> anyhow::Result<Prelogin> {
|
||||
let root = Element::parse(res_xml.as_bytes())?;
|
||||
|
||||
let status = root
|
||||
@@ -211,6 +217,11 @@ fn parse_res_xml(res_xml: &str, is_gateway: bool) -> anyhow::Result<Prelogin> {
|
||||
let saml_default_browser = root.descendant_text("saml-default-browser");
|
||||
// Check if the prelogin response is SAML
|
||||
if saml_method.is_some() && saml_request.is_some() {
|
||||
let saml_method = saml_method.unwrap();
|
||||
anyhow::ensure!(
|
||||
matches!(saml_method.as_str(), "REDIRECT" | "POST"),
|
||||
"Unsupported SAML binding"
|
||||
);
|
||||
let saml_request = base64::decode_to_string(&saml_request.unwrap())?;
|
||||
let support_default_browser = saml_default_browser.map(|s| s.to_lowercase() == "yes").unwrap_or(false);
|
||||
|
||||
@@ -218,6 +229,7 @@ fn parse_res_xml(res_xml: &str, is_gateway: bool) -> anyhow::Result<Prelogin> {
|
||||
region,
|
||||
is_gateway,
|
||||
saml_request,
|
||||
saml_method,
|
||||
support_default_browser,
|
||||
};
|
||||
|
||||
@@ -258,13 +270,13 @@ mod tests {
|
||||
|
||||
fn gp_params(client_os: ClientOs) -> GpParams {
|
||||
let profile = OsProfile::builder(client_os)
|
||||
.host_identity(HostIdentity::new(
|
||||
.host_identity(HostIdentity::from_parts(
|
||||
"test-computer".to_string(),
|
||||
"host-id".to_string(),
|
||||
"serial".to_string(),
|
||||
"aa:bb:cc:dd:ee:ff".to_string(),
|
||||
))
|
||||
.build();
|
||||
.build(crate::os_profile::test_snapshot());
|
||||
GpParams::builder(profile).build()
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user