mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2026-11-20 15:06:14 -05:00
fix(gpclient): keep cookie cache when the cached login gets no answer (#712)
* fix(gpclient): keep cookie cache when the cached login gets no answer A connect or timeout error during the cached gateway login or cached portal discovery deleted the --cookie-cache file and fell back to SAML, although the server never rejected the cookie. Keep the cache and return the error for unanswered requests; only clear it when the server responds. * fix(gpclient): preserve cached cookies for all failed requests --------- Co-authored-by: Kevin Yue <[email protected]>
This commit is contained in:
1 parent
1072a35817
commit
754b220a9d
3 files changed
+172
-19
No files matched your search
@@ -101,6 +101,11 @@ impl ConnectHandler<'_> {
|
||||
{
|
||||
return Some(Err(error));
|
||||
}
|
||||
// A failed request does not establish that the cookie was rejected.
|
||||
if is_network_error(&error) {
|
||||
warn!("Cached gateway authentication request failed: {error}");
|
||||
return Some(Err(error));
|
||||
}
|
||||
cookie_store::clear(&path);
|
||||
warn!("Cached gateway authentication failed: {error}");
|
||||
return None;
|
||||
@@ -830,3 +835,11 @@ mod tests {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// A failed request says nothing about whether a cached cookie is still valid.
|
||||
pub(super) fn is_network_error(error: &anyhow::Error) -> bool {
|
||||
matches!(
|
||||
error.downcast_ref::<gpapi::error::PortalError>(),
|
||||
Some(gpapi::error::PortalError::NetworkError(_))
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user