Compare commits

...

5 Commits

Author SHA1 Message Date
Kevin Yue
54ccb761e5 Fix CI 2024-04-07 09:42:00 -04:00
Kevin Yue
f72dbd1dec Release 2.1.3 2024-04-07 20:46:23 +08:00
Kevin Yue
0814c3153a Merge branch 'feature/as_gateway' into release/2.1.3 2024-04-07 20:44:29 +08:00
Kevin Yue
9f085e8b8c Improve code style 2024-04-07 20:31:05 +08:00
Kevin Yue
0188752c0a Bump version 2.1.3 2024-04-06 20:07:57 +08:00
8 changed files with 32 additions and 26 deletions

View File

@ -25,7 +25,7 @@ jobs:
id: set-matrix id: set-matrix
run: | run: |
if [[ "${{ github.ref }}" == "refs/tags/"* ]]; then if [[ "${{ github.ref }}" == "refs/tags/"* ]]; then
echo 'matrix=[{"runner": "ubuntu-latest", "arch": "amd64"}, {"runner": "arm64", "arch": "arm64"]' >> $GITHUB_OUTPUT echo 'matrix=[{"runner": "ubuntu-latest", "arch": "amd64"}, {"runner": "arm64", "arch": "arm64"}]' >> $GITHUB_OUTPUT
else else
echo 'matrix=[{"runner": "ubuntu-latest", "arch": "amd64"}]' >> $GITHUB_OUTPUT echo 'matrix=[{"runner": "ubuntu-latest", "arch": "amd64"}]' >> $GITHUB_OUTPUT
fi fi
@ -182,7 +182,7 @@ jobs:
gh -R "$REPO" release create $RELEASE_TAG \ gh -R "$REPO" release create $RELEASE_TAG \
--title "$RELEASE_TAG" \ --title "$RELEASE_TAG" \
--notes "$NOTES" \ --notes "$NOTES" \
--target ${{ github.ref }} \ ${{ github.ref == 'refs/heads/dev' && '--target dev' || '' }} \
${{ github.ref == 'refs/heads/dev' && '--prerelease' || '' }} \ ${{ github.ref == 'refs/heads/dev' && '--prerelease' || '' }} \
gh-release/artifact-source/* \ gh-release/artifact-source/* \
gh-release/artifact-gpgui-*/* gh-release/artifact-gpgui-*/*

14
Cargo.lock generated
View File

@ -564,7 +564,7 @@ dependencies = [
[[package]] [[package]]
name = "common" name = "common"
version = "2.1.2" version = "2.1.3"
dependencies = [ dependencies = [
"is_executable", "is_executable",
] ]
@ -1430,7 +1430,7 @@ dependencies = [
[[package]] [[package]]
name = "gpapi" name = "gpapi"
version = "2.1.2" version = "2.1.3"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"base64 0.21.5", "base64 0.21.5",
@ -1462,7 +1462,7 @@ dependencies = [
[[package]] [[package]]
name = "gpauth" name = "gpauth"
version = "2.1.2" version = "2.1.3"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"clap", "clap",
@ -1483,7 +1483,7 @@ dependencies = [
[[package]] [[package]]
name = "gpclient" name = "gpclient"
version = "2.1.2" version = "2.1.3"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"clap", "clap",
@ -1505,7 +1505,7 @@ dependencies = [
[[package]] [[package]]
name = "gpgui-helper" name = "gpgui-helper"
version = "2.1.2" version = "2.1.3"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"clap", "clap",
@ -1523,7 +1523,7 @@ dependencies = [
[[package]] [[package]]
name = "gpservice" name = "gpservice"
version = "2.1.2" version = "2.1.3"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"axum", "axum",
@ -2537,7 +2537,7 @@ dependencies = [
[[package]] [[package]]
name = "openconnect" name = "openconnect"
version = "2.1.2" version = "2.1.3"
dependencies = [ dependencies = [
"cc", "cc",
"common", "common",

View File

@ -5,7 +5,7 @@ members = ["crates/*", "apps/gpclient", "apps/gpservice", "apps/gpauth", "apps/g
[workspace.package] [workspace.package]
rust-version = "1.70" rust-version = "1.70"
version = "2.1.2" version = "2.1.3"
authors = ["Kevin Yue <k3vinyue@gmail.com>"] authors = ["Kevin Yue <k3vinyue@gmail.com>"]
homepage = "https://github.com/yuezk/GlobalProtect-openconnect" homepage = "https://github.com/yuezk/GlobalProtect-openconnect"
edition = "2021" edition = "2021"

View File

@ -366,17 +366,14 @@ fn read_auth_data_from_html(html: &str) -> Result<SamlAuthData, AuthDataParseErr
return Err(AuthDataParseError::Invalid); return Err(AuthDataParseError::Invalid);
} }
match SamlAuthData::from_html(html) { SamlAuthData::from_html(html).or_else(|err| {
Ok(auth_data) => Ok(auth_data), if let Some(gpcallback) = extract_gpcallback(html) {
Err(err) => { info!("Found gpcallback from html...");
if let Some(gpcallback) = extract_gpcallback(html) { SamlAuthData::from_gpcallback(&gpcallback)
info!("Found gpcallback from html..."); } else {
SamlAuthData::from_gpcallback(&gpcallback) Err(err)
} else {
Err(err)
}
} }
} })
} }
fn extract_gpcallback(html: &str) -> Option<String> { fn extract_gpcallback(html: &str) -> Option<String> {

View File

@ -32,7 +32,7 @@ pub(crate) struct ConnectArgs {
user: Option<String>, user: Option<String>,
#[arg(long, short, help = "The VPNC script to use")] #[arg(long, short, help = "The VPNC script to use")]
script: Option<String>, script: Option<String>,
#[arg(long, help = "Treat the server as a gateway, instead of a portal")] #[arg(long, help = "Connect the server as a gateway, instead of a portal")]
as_gateway: bool, as_gateway: bool,
#[arg( #[arg(

View File

@ -1,5 +1,12 @@
# Changelog # Changelog
## 2.1.3 - 2024-04-07
- Support CAS authentication (fix [#339](https://github.com/yuezk/GlobalProtect-openconnect/issues/339))
- CLI: Add `--as-gateway` option to connect as gateway directly (fix [#318](https://github.com/yuezk/GlobalProtect-openconnect/issues/318))
- GUI: Support connect the gateway directly (fix [#318](https://github.com/yuezk/GlobalProtect-openconnect/issues/318))
- GUI: Add an option to use symbolic tray icon (fix [#341](https://github.com/yuezk/GlobalProtect-openconnect/issues/341))
## 2.1.2 - 2024-03-29 ## 2.1.2 - 2024-03-29
- Treat portal as gateway when the gateway login is failed (fix #338) - Treat portal as gateway when the gateway login is failed (fix #338)

View File

@ -162,7 +162,7 @@ pub enum Credential {
Password(PasswordCredential), Password(PasswordCredential),
Prelogin(PreloginCredential), Prelogin(PreloginCredential),
AuthCookie(AuthCookieCredential), AuthCookie(AuthCookieCredential),
CachedCredential(CachedCredential), Cached(CachedCredential),
} }
impl Credential { impl Credential {
@ -179,7 +179,7 @@ impl Credential {
Credential::Password(cred) => cred.username(), Credential::Password(cred) => cred.username(),
Credential::Prelogin(cred) => cred.username(), Credential::Prelogin(cred) => cred.username(),
Credential::AuthCookie(cred) => cred.username(), Credential::AuthCookie(cred) => cred.username(),
Credential::CachedCredential(cred) => cred.username(), Credential::Cached(cred) => cred.username(),
} }
} }
@ -197,7 +197,7 @@ impl Credential {
Some(cred.prelogon_user_auth_cookie()), Some(cred.prelogon_user_auth_cookie()),
None, None,
), ),
Credential::CachedCredential(cred) => ( Credential::Cached(cred) => (
cred.password(), cred.password(),
None, None,
Some(cred.auth_cookie.user_auth_cookie()), Some(cred.auth_cookie.user_auth_cookie()),
@ -244,6 +244,6 @@ impl From<&AuthCookieCredential> for Credential {
impl From<&CachedCredential> for Credential { impl From<&CachedCredential> for Credential {
fn from(value: &CachedCredential) -> Self { fn from(value: &CachedCredential) -> Self {
Self::CachedCredential(value.clone()) Self::Cached(value.clone())
} }
} }

View File

@ -130,13 +130,15 @@ pub struct GpParamsBuilder {
impl GpParamsBuilder { impl GpParamsBuilder {
pub fn new() -> Self { pub fn new() -> Self {
let computer = whoami::fallible::hostname().unwrap_or_else(|_| String::from("localhost"));
Self { Self {
is_gateway: false, is_gateway: false,
user_agent: GP_USER_AGENT.to_string(), user_agent: GP_USER_AGENT.to_string(),
client_os: ClientOs::Linux, client_os: ClientOs::Linux,
os_version: Default::default(), os_version: Default::default(),
client_version: Default::default(), client_version: Default::default(),
computer: whoami::hostname(), computer,
ignore_tls_errors: false, ignore_tls_errors: false,
} }
} }