fix: replace passwd with OTP on gateway MFA retry

Gateway login OTP retries were appending a second passwd form field
instead of replacing the credential password. That regressed in 2.6.0
when login params moved from a HashMap to a Vec and could cause MFA
submissions to fail with HTTP 512 (fix #626).

Bump version to 2.6.4.
This commit is contained in:
Kevin Yue committed 2026-06-25 14:41:42 +08:00
1 parent b5b71df6e6
commit 494e4a5331
5 files changed
+60 -11

No files matched your search

Generated
+8 -8
View File
@@ -214,7 +214,7 @@ checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"
[[package]]
name = "auth"
version = "2.6.3"
version = "2.6.4"
dependencies = [
"anyhow",
"block2",
@@ -705,7 +705,7 @@ dependencies = [
[[package]]
name = "common"
version = "2.6.3"
version = "2.6.4"
[[package]]
name = "compile-time"
@@ -1732,7 +1732,7 @@ dependencies = [
[[package]]
name = "gpapi"
version = "2.6.3"
version = "2.6.4"
dependencies = [
"anyhow",
"base64 0.22.1",
@@ -1776,7 +1776,7 @@ dependencies = [
[[package]]
name = "gpauth"
version = "2.6.3"
version = "2.6.4"
dependencies = [
"anyhow",
"auth",
@@ -1796,7 +1796,7 @@ dependencies = [
[[package]]
name = "gpclient"
version = "2.6.3"
version = "2.6.4"
dependencies = [
"anyhow",
"askama",
@@ -1825,7 +1825,7 @@ dependencies = [
[[package]]
name = "gpgui-helper"
version = "2.6.3"
version = "2.6.4"
dependencies = [
"anyhow",
"clap",
@@ -1843,7 +1843,7 @@ dependencies = [
[[package]]
name = "gpservice"
version = "2.6.3"
version = "2.6.4"
dependencies = [
"anyhow",
"axum",
@@ -3191,7 +3191,7 @@ dependencies = [
[[package]]
name = "openconnect"
version = "2.6.3"
version = "2.6.4"
dependencies = [
"autotools",
"cc",
+1 -1
View File
@@ -11,7 +11,7 @@ members = [
[workspace.package]
rust-version = "1.89"
version = "2.6.3"
version = "2.6.4"
authors = ["Kevin Yue <[email protected]>"]
homepage = "https://github.com/yuezk/GlobalProtect-openconnect"
edition = "2024"
+6
View File
@@ -1,5 +1,11 @@
# Changelog
## 2.6.4
### Fixed
- Fixed gateway login MFA OTP retries sending duplicate `passwd` form fields, which could cause authentication to fail with HTTP 512 after 2.6.0 (fix [#626](https://github.com/yuezk/GlobalProtect-openconnect/issues/626)).
## 2.6.3
### Fixed
+44 -1
View File
@@ -39,7 +39,7 @@ pub(crate) fn build(input: &GatewayLoginInput) -> RequestParams {
input.gp_params.input_str().unwrap_or_default().into(),
));
if let Some(otp) = input.gp_params.otp() {
body.push(("passwd".into(), otp.into()));
set_body_param(&mut body, "passwd", otp);
}
if let Some(os_version) = input.gp_params.os_version() {
body.push(("os-version".into(), os_version.into()));
@@ -99,6 +99,15 @@ pub(crate) fn build(input: &GatewayLoginInput) -> RequestParams {
RequestParams { body, query: vec![] }
}
fn set_body_param(body: &mut Vec<(String, String)>, key: &str, value: impl Into<String>) {
let value = value.into();
if let Some(pos) = body.iter().position(|(k, _)| k == key) {
body[pos].1 = value;
} else {
body.push((key.to_string(), value));
}
}
/// Resolve the gateway server to an IPv4 address if the profile requires it.
///
/// Falls back to the original gateway host if resolution fails.
@@ -153,6 +162,40 @@ mod tests {
Credential::Password(PasswordCredential::new("alice", "secret"))
}
fn passwd_values(body: &[(String, String)]) -> Vec<&str> {
body
.iter()
.filter(|(k, _)| k == "passwd")
.map(|(_, v)| v.as_str())
.collect()
}
#[test]
fn otp_retry_replaces_passwd_instead_of_appending_duplicate() {
let mut gp_params = make_gp_params();
gp_params.set_input_str("challenge-token");
gp_params.set_otp("123456");
let cred = make_credential();
let input = GatewayLoginInput {
gp_params: &gp_params,
cred: &cred,
gateway_host: "vpn.example.com",
context: None,
client_ip: None,
extend_lifetime: false,
};
let result = build(&input);
assert_eq!(passwd_values(&result.body), vec!["123456"]);
let encoded = serde_urlencoded::to_string(&result.body).expect("form body should encode");
assert_eq!(encoded.matches("passwd=").count(), 1);
assert!(encoded.contains("passwd=123456"));
assert!(!encoded.contains("passwd=secret"));
}
#[test]
fn build_without_context_includes_identity_fields() {
let profile = test_profile(ClientOs::Linux);
+1 -1
View File
@@ -26,7 +26,7 @@
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
pname = "globalprotect-openconnect";
version = cargoToml.workspace.package.version;
releaseTag = "v2.6.3";
releaseTag = "v2.6.4";
toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;