Compare commits

...
Author SHA1 Message Date
Kevin Yue e98fd7894a ci: build FreeBSD package on 14.4 2026-08-05 11:11:46 +08:00
Kevin Yue 6f860d3dff fix: avoid reformatting VPN progress messages 2026-08-05 10:27:19 +08:00
Kevin Yue 5902bee5ff chore: prepare 2.6.5 release 2026-08-05 10:16:07 +08:00
Kevin Yue 494e4a5331 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.
2026-06-25 14:41:42 +08:00
Kevin Yue b5b71df6e6 doc: update OpenBSD/FreeBSD instructions 2026-06-24 12:53:05 +08:00
Kevin Yue 49f410e63b Merge branch 'fix/nixos-desktop-launch-path' 2026-06-24 12:52:20 +08:00
Kevin Yue 225acf13aa fix: use stable NixOS desktop launcher path 2026-06-24 09:26:07 +08:00
Kevin Yueandgithub-actions[bot] 61d2b702c0 chore: update flake hashes for v2.6.3 (#631)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-06-23 23:12:52 +08:00
github-actions[bot] 3276ac0f9a chore: update flake hashes for v2.6.3 (#630) [no ci] 2026-06-23 21:57:51 +08:00
Kevin Yue 0b037e158c chore: prepare 2.6.3 release
- Fix NixOS GUI authorization after package updates.

- Treat Ctrl+C initiated OpenConnect disconnect as a successful shutdown.

- Update snapshot flake hash automation for prebuilt Nix packages.

- Bump gp workspace version and changelog to 2.6.3.
2026-06-23 20:06:04 +08:00
Kevin Yue 10e94e0b81 fix: use minimal Rust PPA build deps 2026-06-22 23:46:06 +08:00
github-actions[bot] 0f76539075 chore: update flake hashes for v2.6.2 (#628)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-06-22 23:08:15 +08:00
Kevin Yue f9b8c55924 Merge branch 'release/2.6.2' 2026-06-22 22:50:48 +08:00
Kevin Yue a708ce0115 chore: release 2.6.2 2026-06-22 20:33:14 +08:00
github-actions[bot] b3f4ba0a32 chore: update flake hashes for v2.6.1 (#625) 2026-06-22 14:33:21 +08:00
Kevin Yue 02cf4a0b26 ci: parallelize gpgui release builds 2026-06-22 12:51:52 +08:00
Kevin Yue 370189cbee fix: resolve release changelog path 2026-06-22 12:42:47 +08:00
Kevin Yue 6746cf64c3 fix: complete 2.6.1 release updates 2026-06-22 11:46:26 +08:00
Kevin Yue 40739739b5 fix: correct direct gateway browser auth mode 2026-06-22 08:24:48 +08:00
Kevin Yue dc7a200b93 ci: avoid Docker Hub auth pulls in release builds 2026-06-21 22:28:49 +08:00
Kevin Yue f49b6471f3 ci: reduce release Docker pull pressure 2026-06-21 22:25:28 +08:00
24 changed files with 642 additions and 142 deletions

No files matched your search

+11 -61
View File
@@ -130,6 +130,7 @@ jobs:
if-no-files-found: error if-no-files-found: error
build-gp: build-gp:
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
needs: needs:
- tarball - tarball
strategy: strategy:
@@ -153,19 +154,17 @@ jobs:
with: with:
name: artifact-source name: artifact-source
path: build-gp-${{ matrix.package }} path: build-gp-${{ matrix.package }}
- name: Docker Login
run: echo ${{ secrets.DOCKER_HUB_TOKEN }} | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin
- name: Build ${{ matrix.package }} package in Docker - name: Build ${{ matrix.package }} package in Docker
# LIBXML2_STATIC is needed to avoid the dynamic linking issue on different distros # LIBXML2_STATIC is needed to avoid the dynamic linking issue on different distros
run: | run: |
docker run --pull=always --rm \ docker run --rm \
-e COREPACK_INTEGRITY_KEYS=0 \ -e COREPACK_INTEGRITY_KEYS=0 \
-e LIBXML2_STATIC=1 \ -e LIBXML2_STATIC=1 \
-v $(pwd)/build-gp-${{ matrix.package }}:/workspace \ -v $(pwd)/build-gp-${{ matrix.package }}:/workspace \
yuezk/gpdev:${{ matrix.package }}-builder-tauri2 yuezk/gpdev:${{ matrix.package }}-builder-tauri2
- name: Install ${{ matrix.package }} package in Docker - name: Install ${{ matrix.package }} package in Docker
run: | run: |
docker run --pull=always --rm \ docker run --rm \
-e COREPACK_INTEGRITY_KEYS=0 \ -e COREPACK_INTEGRITY_KEYS=0 \
-e GPGUI_INSTALLED=0 \ -e GPGUI_INSTALLED=0 \
-v $(pwd)/build-gp-${{ matrix.package }}:/workspace \ -v $(pwd)/build-gp-${{ matrix.package }}:/workspace \
@@ -182,6 +181,7 @@ jobs:
build-gp-${{ matrix.package }}/artifacts/* build-gp-${{ matrix.package }}/artifacts/*
build-docker-image: build-docker-image:
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
@@ -282,18 +282,16 @@ jobs:
run: | run: |
cd gpgui-source cd gpgui-source
tar -czf gpgui.tar.gz gpgui gp tar -czf gpgui.tar.gz gpgui gp
- name: Docker Login
run: echo ${{ secrets.DOCKER_HUB_TOKEN }} | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin
- name: Build gpgui in Docker - name: Build gpgui in Docker
run: | run: |
docker run --pull=always --rm \ docker run --rm \
-e COREPACK_INTEGRITY_KEYS=0 \ -e COREPACK_INTEGRITY_KEYS=0 \
-v $(pwd)/gpgui-source:/workspace yuezk/gpdev:${{ matrix.libc.builder }} -v $(pwd)/gpgui-source:/workspace yuezk/gpdev:${{ matrix.libc.builder }}
- name: Install gpgui in Docker - name: Install gpgui in Docker
run: | run: |
cd gpgui-source cd gpgui-source
tar -xJf *.bin.tar.xz tar -xJf *.bin.tar.xz
docker run --pull=always --rm \ docker run --rm \
-e COREPACK_INTEGRITY_KEYS=0 \ -e COREPACK_INTEGRITY_KEYS=0 \
-v $(pwd):/workspace yuezk/gpdev:${{ matrix.libc.builder }} \ -v $(pwd):/workspace yuezk/gpdev:${{ matrix.libc.builder }} \
bash -c "cd /workspace/gpgui_*/ && ./gpgui --version" bash -c "cd /workspace/gpgui_*/ && ./gpgui --version"
@@ -306,58 +304,6 @@ jobs:
gpgui-source/*.bin.tar.xz gpgui-source/*.bin.tar.xz
gpgui-source/*.bin.tar.xz.sha256 gpgui-source/*.bin.tar.xz.sha256
build-nix-prebuilt:
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
strategy:
fail-fast: false
matrix:
include:
- runner: ubuntu-latest
nixpkgs: nixos-25.11
- runner: ubuntu-latest
nixpkgs: nixos-26.05
- runner: ubuntu-24.04-arm
nixpkgs: nixos-25.11
- runner: ubuntu-24.04-arm
nixpkgs: nixos-26.05
name: build-nix-prebuilt (${{ matrix.nixpkgs }}, ${{ matrix.runner }})
runs-on: ${{ matrix.runner }}
steps:
- name: Checkout GlobalProtect-openconnect
uses: actions/checkout@v6
with:
token: ${{ secrets.GH_PAT }}
repository: yuezk/GlobalProtect-openconnect
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.gp_branch || github.ref }}
submodules: recursive
- name: Install Nix
uses: cachix/install-nix-action@v31
- name: Build prebuilt Nix package
run: |
nix build .#prebuilt \
--override-input nixpkgs "github:NixOS/nixpkgs/${{ matrix.nixpkgs }}" \
--extra-experimental-features "nix-command flakes" \
--print-build-logs
- name: Inspect prebuilt Nix package
run: |
test -x result/bin/gpclient
test -x result/bin/gpauth
test -x result/bin/gpservice
test -x result/bin/gpgui-helper
test -x result/bin/gpgui
test ! -L result/bin/gpservice
head -n1 result/bin/gpclient | grep '^#!'
head -n1 result/bin/gpservice | grep '^#!'
grep -q '/run/wrappers/bin/pkexec' result/bin/gpclient
grep -q 'gpservice_public=.*/bin/gpservice' result/bin/gpclient
grep -q 'exec .*/bin/gpservice' result/bin/gpservice
! grep -q '@gpservice_public@\|@gpservice_fhs@\|\$out/bin/gpservice' result/bin/gpclient result/bin/gpservice
! grep -R '/usr/bin/gp' result/share
setup-bsd-matrix: setup-bsd-matrix:
runs-on: ubuntu-latest runs-on: ubuntu-latest
outputs: outputs:
@@ -475,7 +421,7 @@ jobs:
if: ${{ matrix.os == 'freebsd' }} if: ${{ matrix.os == 'freebsd' }}
uses: vmactions/freebsd-vm@v1 uses: vmactions/freebsd-vm@v1
with: with:
release: "14.3" release: "14.4"
arch: ${{ matrix.arch }} arch: ${{ matrix.arch }}
usesh: true usesh: true
prepare: | prepare: |
@@ -600,6 +546,7 @@ jobs:
env: env:
NEEDS_JSON: ${{ toJson(needs) }} NEEDS_JSON: ${{ toJson(needs) }}
BSD_MATRIX_ENABLED: ${{ needs.setup-bsd-matrix.outputs.enabled }} BSD_MATRIX_ENABLED: ${{ needs.setup-bsd-matrix.outputs.enabled }}
IS_TAG: ${{ startsWith(github.ref, 'refs/tags/') }}
run: | run: |
python3 - <<'PY' python3 - <<'PY'
import json import json
@@ -608,12 +555,15 @@ jobs:
needs = json.loads(os.environ["NEEDS_JSON"]) needs = json.loads(os.environ["NEEDS_JSON"])
bsd_matrix_enabled = os.environ["BSD_MATRIX_ENABLED"] == "true" bsd_matrix_enabled = os.environ["BSD_MATRIX_ENABLED"] == "true"
is_tag = os.environ["IS_TAG"] == "true"
failed = [] failed = []
for name, data in needs.items(): for name, data in needs.items():
result = data["result"] result = data["result"]
if result in {"failure", "cancelled"}: if result in {"failure", "cancelled"}:
failed.append(f"{name}: {result}") failed.append(f"{name}: {result}")
elif name in {"build-gp", "build-docker-image"} and result == "skipped" and is_tag:
continue
elif name in {"build-gpgui-frontend", "build-bsd"} and result == "skipped" and not bsd_matrix_enabled: elif name in {"build-gpgui-frontend", "build-bsd"} and result == "skipped" and not bsd_matrix_enabled:
continue continue
elif result == "skipped": elif result == "skipped":
+2 -4
View File
@@ -116,12 +116,10 @@ jobs:
--pattern '*[^offline].tar.gz' \ --pattern '*[^offline].tar.gz' \
--dir build-${{ matrix.package }} --dir build-${{ matrix.package }}
- name: Docker Login
run: echo ${{ secrets.DOCKER_HUB_TOKEN }} | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin
- name: Build ${{ matrix.package }} package in Docker - name: Build ${{ matrix.package }} package in Docker
# LIBXML2_STATIC is needed to avoid the dynamic linking issue on different distros # LIBXML2_STATIC is needed to avoid the dynamic linking issue on different distros
run: | run: |
docker run --pull=always --rm \ docker run --rm \
-v $(pwd)/build-${{ matrix.package }}:/workspace \ -v $(pwd)/build-${{ matrix.package }}:/workspace \
-e COREPACK_INTEGRITY_KEYS=0 \ -e COREPACK_INTEGRITY_KEYS=0 \
-e LIBXML2_STATIC=1 \ -e LIBXML2_STATIC=1 \
@@ -130,7 +128,7 @@ jobs:
- name: Install ${{ matrix.package }} package in Docker - name: Install ${{ matrix.package }} package in Docker
run: | run: |
docker run --pull=always --rm \ docker run --rm \
-e COREPACK_INTEGRITY_KEYS=0 \ -e COREPACK_INTEGRITY_KEYS=0 \
-v $(pwd)/build-${{ matrix.package }}:/workspace \ -v $(pwd)/build-${{ matrix.package }}:/workspace \
yuezk/gpdev:${{ matrix.package }}-builder-tauri2 \ yuezk/gpdev:${{ matrix.package }}-builder-tauri2 \
+85 -3
View File
@@ -6,6 +6,9 @@ on:
version: version:
description: "Release version. Defaults to Cargo.toml workspace version." description: "Release version. Defaults to Cargo.toml workspace version."
required: false required: false
release_tag:
description: "GitHub release tag to fetch assets from. Defaults to v<version>; use snapshot for snapshot assets."
required: false
permissions: permissions:
contents: write contents: write
@@ -24,15 +27,94 @@ jobs:
- name: Update flake hashes - name: Update flake hashes
env: env:
RELEASE_VERSION: ${{ inputs.version }} RELEASE_VERSION: ${{ inputs.version }}
RELEASE_TAG: ${{ inputs.release_tag }}
run: | run: |
if [[ -n "$RELEASE_VERSION" ]]; then if [[ -n "$RELEASE_VERSION" ]]; then
scripts/update-flake-hashes.sh "$RELEASE_VERSION" scripts/update-flake-hashes.sh "$RELEASE_VERSION" "$RELEASE_TAG"
else else
scripts/update-flake-hashes.sh scripts/update-flake-hashes.sh "" "$RELEASE_TAG"
fi fi
- name: Upload updated flake
uses: actions/upload-artifact@v7
with:
name: updated-flake
path: flake.nix
if-no-files-found: error
validate-nix-prebuilt:
needs:
- update-flake-hashes
strategy:
fail-fast: false
matrix:
include:
- runner: ubuntu-latest
nixpkgs: nixos-25.11
- runner: ubuntu-latest
nixpkgs: nixos-26.05
- runner: ubuntu-24.04-arm
nixpkgs: nixos-25.11
- runner: ubuntu-24.04-arm
nixpkgs: nixos-26.05
name: validate-nix-prebuilt (${{ matrix.nixpkgs }}, ${{ matrix.runner }})
runs-on: ${{ matrix.runner }}
steps:
- name: Checkout GlobalProtect-openconnect
uses: actions/checkout@v6
with:
submodules: recursive
- name: Download updated flake
uses: actions/download-artifact@v8
with:
name: updated-flake
path: .
- name: Install Nix
uses: cachix/install-nix-action@v31
- name: Build prebuilt Nix package
run: |
nix build .#prebuilt \
--override-input nixpkgs "github:NixOS/nixpkgs/${{ matrix.nixpkgs }}" \
--extra-experimental-features "nix-command flakes" \
--print-build-logs
- name: Inspect prebuilt Nix package
run: |
test -x result/bin/gpclient
test -x result/bin/gpauth
test -x result/bin/gpservice
test -x result/bin/gpgui-helper
test -x result/bin/gpgui
test ! -L result/bin/gpservice
head -n1 result/bin/gpclient | grep '^#!'
head -n1 result/bin/gpservice | grep '^#!'
grep -q '/run/wrappers/bin/pkexec' result/bin/gpclient
grep -q 'gpservice_public=.*/bin/gpservice' result/bin/gpclient
grep -q 'exec .*/bin/gpservice' result/bin/gpservice
! grep -q '@gpservice_public@\|@gpservice_fhs@\|\$out/bin/gpservice' result/bin/gpclient result/bin/gpservice
! grep -R '/usr/bin/gp' result/share
open-pull-request:
needs:
- validate-nix-prebuilt
runs-on: ubuntu-latest
steps:
- name: Checkout GlobalProtect-openconnect
uses: actions/checkout@v6
- name: Download updated flake
uses: actions/download-artifact@v8
with:
name: updated-flake
path: .
- name: Open pull request - name: Open pull request
env: env:
GH_TOKEN: ${{ github.token }} GH_TOKEN: ${{ github.token }}
RELEASE_VERSION: ${{ inputs.version }} RELEASE_VERSION: ${{ inputs.version }}
run: scripts/open-flake-hashes-pr.sh "$RELEASE_VERSION" RELEASE_TAG: ${{ inputs.release_tag }}
run: scripts/open-flake-hashes-pr.sh "$RELEASE_VERSION" "$RELEASE_TAG"
Generated
+8 -8
View File
@@ -214,7 +214,7 @@ checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"
[[package]] [[package]]
name = "auth" name = "auth"
version = "2.6.1" version = "2.6.5"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"block2", "block2",
@@ -705,7 +705,7 @@ dependencies = [
[[package]] [[package]]
name = "common" name = "common"
version = "2.6.1" version = "2.6.5"
[[package]] [[package]]
name = "compile-time" name = "compile-time"
@@ -1732,7 +1732,7 @@ dependencies = [
[[package]] [[package]]
name = "gpapi" name = "gpapi"
version = "2.6.1" version = "2.6.5"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"base64 0.22.1", "base64 0.22.1",
@@ -1776,7 +1776,7 @@ dependencies = [
[[package]] [[package]]
name = "gpauth" name = "gpauth"
version = "2.6.1" version = "2.6.5"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"auth", "auth",
@@ -1796,7 +1796,7 @@ dependencies = [
[[package]] [[package]]
name = "gpclient" name = "gpclient"
version = "2.6.1" version = "2.6.5"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"askama", "askama",
@@ -1825,7 +1825,7 @@ dependencies = [
[[package]] [[package]]
name = "gpgui-helper" name = "gpgui-helper"
version = "2.6.1" version = "2.6.5"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"clap", "clap",
@@ -1843,7 +1843,7 @@ dependencies = [
[[package]] [[package]]
name = "gpservice" name = "gpservice"
version = "2.6.1" version = "2.6.5"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"axum", "axum",
@@ -3191,7 +3191,7 @@ dependencies = [
[[package]] [[package]]
name = "openconnect" name = "openconnect"
version = "2.6.1" version = "2.6.5"
dependencies = [ dependencies = [
"autotools", "autotools",
"cc", "cc",
+1 -1
View File
@@ -11,7 +11,7 @@ members = [
[workspace.package] [workspace.package]
rust-version = "1.89" rust-version = "1.89"
version = "2.6.1" version = "2.6.5"
authors = ["Kevin Yue <[email protected]>"] authors = ["Kevin Yue <[email protected]>"]
homepage = "https://github.com/yuezk/GlobalProtect-openconnect" homepage = "https://github.com/yuezk/GlobalProtect-openconnect"
edition = "2024" edition = "2024"
+21 -1
View File
@@ -72,7 +72,7 @@ For browser-based authentication with the CLI:
**Method 1:** Using sudo with environment preservation: **Method 1:** Using sudo with environment preservation:
```bash ```bash
sudo -E gpclient connect --browser <portal> sudo gpclient connect --browser <portal>
``` ```
**Method 2:** Using authentication piping: **Method 2:** Using authentication piping:
@@ -200,6 +200,26 @@ sudo apk add --allow-untrusted globalprotect-openconnect-*.apk
The package uses Alpine's native musl build. Make sure the `community` repository is enabled so GUI dependencies such as `webkit2gtk-4.1`, `libsecret`, and `libayatana-appindicator` can be resolved. GUI-launched connections use polkit, and VPN tunnel creation requires `/dev/net/tun`. The package uses Alpine's native musl build. Make sure the `community` repository is enabled so GUI dependencies such as `webkit2gtk-4.1`, `libsecret`, and `libayatana-appindicator` can be resolved. GUI-launched connections use polkit, and VPN tunnel creation requires `/dev/net/tun`.
### FreeBSD
Download the latest FreeBSD package from the [releases](https://github.com/yuezk/GlobalProtect-openconnect/releases) page, then install:
```bash
sudo pkg install ./globalprotect-openconnect-*-freebsd-*.pkg
```
To build from source, see [Building from Source on FreeBSD and OpenBSD](./docs/bsd-source-build.md).
### OpenBSD
Download the latest OpenBSD package from the [releases](https://github.com/yuezk/GlobalProtect-openconnect/releases) page, then install:
```bash
doas pkg_add -D unsigned ./globalprotect-openconnect-*-openbsd-*.tgz
```
To build from source, see [Building from Source on FreeBSD and OpenBSD](./docs/bsd-source-build.md).
### Gentoo ### Gentoo
Available via the `guru` and `lamdness` overlays: Available via the `guru` and `lamdness` overlays:
+36 -1
View File
@@ -57,6 +57,19 @@ struct Cli {
#[arg(long, help = "Override the GlobalProtect client version reported to the server")] #[arg(long, help = "Override the GlobalProtect client version reported to the server")]
client_version: Option<String>, client_version: Option<String>,
#[arg(
short,
long,
help = "Use SSL client certificate file in pkcs#8 (.pem) or pkcs#12 (.p12, .pfx) format"
)]
certificate: Option<String>,
#[arg(short = 'k', long, help = "Use SSL private key file in pkcs#8 (.pem) format")]
sslkey: Option<String>,
#[arg(short = 'p', long, help = "The key passphrase of the private key")]
key_password: Option<String>,
#[arg(long, help = "Get around the OpenSSL `unsafe legacy renegotiation` error")] #[arg(long, help = "Get around the OpenSSL `unsafe legacy renegotiation` error")]
fix_openssl: bool, fix_openssl: bool,
@@ -128,7 +141,7 @@ impl Cli {
let auth_request = match self.saml_request.as_deref() { let auth_request = match self.saml_request.as_deref() {
Some(auth_request) => auth_request.to_string(), Some(auth_request) => auth_request.to_string(),
None => auth_prelogin(&server, &gp_params, self.external_browser_requested()).await?, None => auth_prelogin(&server, &gp_params, self.external_browser_requested(), self.gateway).await?,
}; };
#[cfg(feature = "webview-auth")] #[cfg(feature = "webview-auth")]
@@ -161,6 +174,9 @@ impl Cli {
fn build_gp_params(&self) -> GpParams { fn build_gp_params(&self) -> GpParams {
GpParams::builder(self.build_os_profile()) GpParams::builder(self.build_os_profile())
.ignore_tls_errors(self.ignore_tls_errors) .ignore_tls_errors(self.ignore_tls_errors)
.certificate(self.certificate.clone())
.sslkey(self.sslkey.clone())
.key_password(self.key_password.clone())
.is_gateway(self.gateway) .is_gateway(self.gateway)
.build() .build()
} }
@@ -276,4 +292,23 @@ mod tests {
assert_eq!(profile.client_version(), "legacy-client"); assert_eq!(profile.client_version(), "legacy-client");
assert!(profile.user_agent().contains("legacy-client")); assert!(profile.user_agent().contains("legacy-client"));
} }
#[test]
fn client_certificate_args_parse() {
let cli = Cli::try_parse_from([
"gpauth",
"portal.example.com",
"--certificate",
"/tmp/client.pem",
"--sslkey",
"/tmp/client.key",
"--key-password",
"secret",
])
.expect("gpauth args should parse");
assert_eq!(cli.certificate.as_deref(), Some("/tmp/client.pem"));
assert_eq!(cli.sslkey.as_deref(), Some("/tmp/client.key"));
assert_eq!(cli.key_password.as_deref(), Some("secret"));
}
} }
+16 -12
View File
@@ -48,7 +48,7 @@ impl ConnectHandler<'_> {
&self, &self,
prelogin: &Prelogin, prelogin: &Prelogin,
server: &str, server: &str,
portal_default_browser_enabled: bool, gateway_browser_auth_allowed: bool,
) -> anyhow::Result<Credential> { ) -> anyhow::Result<Credential> {
if should_read_stdin_credential(self.args.cookie_on_stdin, self.args.as_gateway, prelogin.is_gateway()) { if should_read_stdin_credential(self.args.cookie_on_stdin, self.args.as_gateway, prelogin.is_gateway()) {
return self.read_cookie_from_stdin(); return self.read_cookie_from_stdin();
@@ -58,10 +58,10 @@ impl ConnectHandler<'_> {
match prelogin { match prelogin {
Prelogin::Saml(prelogin) => { Prelogin::Saml(prelogin) => {
let external_browser_supported = default_browser_auth_allowed( let external_browser_supported = can_use_external_browser_auth(
prelogin.support_default_browser(), prelogin.support_default_browser(),
is_gateway, is_gateway,
portal_default_browser_enabled, gateway_browser_auth_allowed,
); );
let browser = if external_browser_supported { let browser = if external_browser_supported {
self.args.browser.as_deref() self.args.browser.as_deref()
@@ -74,12 +74,16 @@ impl ConnectHandler<'_> {
}; };
let verbose = self.shared_args.verbose.to_verbose_arg(); let verbose = self.shared_args.verbose.to_verbose_arg();
let os_profile = self.os_profile.borrow().clone(); let os_profile = self.os_profile.borrow().clone();
let key_password = self.latest_key_password.borrow().clone();
let auth_launcher = SamlAuthLauncher::new(server) let auth_launcher = SamlAuthLauncher::new(server)
.gateway(is_gateway) .gateway(is_gateway)
.saml_request(prelogin.saml_request()) .saml_request(prelogin.saml_request())
.os_profile(&os_profile) .os_profile(&os_profile)
.fix_openssl(self.shared_args.fix_openssl) .fix_openssl(self.shared_args.fix_openssl)
.ignore_tls_errors(self.shared_args.ignore_tls_errors) .ignore_tls_errors(self.shared_args.ignore_tls_errors)
.certificate(self.args.certificate.as_deref())
.sslkey(self.args.sslkey.as_deref())
.key_password(key_password.as_deref())
.browser(browser) .browser(browser)
.verbose(verbose); .verbose(verbose);
@@ -184,12 +188,12 @@ fn should_read_stdin_credential(cookie_on_stdin: bool, as_gateway: bool, prelogi
cookie_on_stdin && (!prelogin_is_gateway || as_gateway) cookie_on_stdin && (!prelogin_is_gateway || as_gateway)
} }
fn default_browser_auth_allowed( fn can_use_external_browser_auth(
saml_support_default_browser: bool, saml_support_default_browser: bool,
is_gateway: bool, is_gateway: bool,
portal_default_browser_enabled: bool, gateway_browser_auth_allowed: bool,
) -> bool { ) -> bool {
saml_support_default_browser && (!is_gateway || portal_default_browser_enabled) saml_support_default_browser && (!is_gateway || gateway_browser_auth_allowed)
} }
fn log_stdin_host_id(host_id: Option<&str>) { fn log_stdin_host_id(host_id: Option<&str>) {
@@ -250,18 +254,18 @@ mod tests {
#[test] #[test]
fn portal_saml_can_use_default_browser_when_supported() { fn portal_saml_can_use_default_browser_when_supported() {
assert!(default_browser_auth_allowed(true, false, false)); assert!(can_use_external_browser_auth(true, false, false));
} }
#[test] #[test]
fn gateway_saml_requires_portal_default_browser_policy() { fn gateway_saml_requires_gateway_browser_auth_allowance() {
assert!(!default_browser_auth_allowed(true, true, false)); assert!(!can_use_external_browser_auth(true, true, false));
assert!(default_browser_auth_allowed(true, true, true)); assert!(can_use_external_browser_auth(true, true, true));
} }
#[test] #[test]
fn default_browser_auth_requires_saml_support() { fn default_browser_auth_requires_saml_support() {
assert!(!default_browser_auth_allowed(false, false, true)); assert!(!can_use_external_browser_auth(false, false, true));
assert!(!default_browser_auth_allowed(false, true, true)); assert!(!can_use_external_browser_auth(false, true, true));
} }
} }
+42 -15
View File
@@ -28,6 +28,8 @@ use crate::{
use super::{ConnectHandler, args::cookie_cache_path}; use super::{ConnectHandler, args::cookie_cache_path};
const OPENCONNECT_INTERRUPTED_EXIT_CODE: i32 = -4;
struct GatewayLoginSession { struct GatewayLoginSession {
cookie: String, cookie: String,
extension_auth: SessionExtensionAuth, extension_auth: SessionExtensionAuth,
@@ -139,8 +141,11 @@ impl ConnectHandler<'_> {
let mut gp_params = self.build_gp_params(); let mut gp_params = self.build_gp_params();
gp_params.set_is_gateway(true); gp_params.set_is_gateway(true);
let prelogin = prelogin(gateway, &gp_params, self.prelogin_options(false)).await?; let gateway_browser_auth_allowed = true;
let cred = self.obtain_credential(&prelogin, gateway, false).await?; let prelogin = prelogin(gateway, &gp_params, self.direct_gateway_prelogin_options()).await?;
let cred = self
.obtain_credential(&prelogin, gateway, gateway_browser_auth_allowed)
.await?;
let login_session = self let login_session = self
.login_gateway(gateway, &cred, &gp_params, gateway_context.as_ref()) .login_gateway(gateway, &cred, &gp_params, gateway_context.as_ref())
@@ -174,19 +179,16 @@ impl ConnectHandler<'_> {
gateway: &str, gateway: &str,
portal_cred: &AuthCookieCredential, portal_cred: &AuthCookieCredential,
allow_extend_session: bool, allow_extend_session: bool,
portal_default_browser_enabled: bool, portal_config_default_browser: bool,
gateway_context: GatewayLoginContext, gateway_context: GatewayLoginContext,
) -> Result<(), GatewayConnectError> { ) -> Result<(), GatewayConnectError> {
info!("Connecting to gateway with portal-cookie first, gateway prelogin fallback..."); info!("Connecting to gateway with portal-cookie first, gateway prelogin fallback...");
let mut gp_params = self.build_gp_params(); let mut gp_params = self.build_gp_params();
gp_params.set_is_gateway(true); gp_params.set_is_gateway(true);
let gateway_browser_auth_allowed = self.gateway_browser_auth_allowed(portal_config_default_browser);
let gateway_prelogin = prelogin( let gateway_prelogin = prelogin(gateway, &gp_params, self.prelogin_options(gateway_browser_auth_allowed))
gateway,
&gp_params,
self.prelogin_options(portal_default_browser_enabled),
)
.await .await
.map_err(GatewayConnectError::before_tunnel)?; .map_err(GatewayConnectError::before_tunnel)?;
@@ -219,7 +221,7 @@ impl ConnectHandler<'_> {
} }
let gateway_cred = match self let gateway_cred = match self
.obtain_credential(&gateway_prelogin, gateway, portal_default_browser_enabled) .obtain_credential(&gateway_prelogin, gateway, gateway_browser_auth_allowed)
.await .await
{ {
Ok(cred) => cred, Ok(cred) => cred,
@@ -372,10 +374,13 @@ impl ConnectHandler<'_> {
let session_ctx_on_connect = Arc::clone(&session_ctx); let session_ctx_on_connect = Arc::clone(&session_ctx);
let tunnel_established = Arc::new(AtomicBool::new(false)); let tunnel_established = Arc::new(AtomicBool::new(false));
let tunnel_established_on_connect = Arc::clone(&tunnel_established); let tunnel_established_on_connect = Arc::clone(&tunnel_established);
let disconnect_requested = Arc::new(AtomicBool::new(false));
let disconnect_requested_on_signal = Arc::clone(&disconnect_requested);
tokio::spawn(async move { tokio::spawn(async move {
shutdown_signal().await; shutdown_signal().await;
info!("Received the interrupt signal, disconnecting..."); info!("Received the interrupt signal, disconnecting...");
disconnect_requested_on_signal.store(true, Ordering::SeqCst);
vpn_clone.disconnect(); vpn_clone.disconnect();
}); });
@@ -403,7 +408,8 @@ impl ConnectHandler<'_> {
fs::remove_file(GP_CLIENT_LOCK_FILE).map_err(|err| GatewayConnectError::after_tunnel(err.into()))?; fs::remove_file(GP_CLIENT_LOCK_FILE).map_err(|err| GatewayConnectError::after_tunnel(err.into()))?;
} }
classify_openconnect_result(connect_result, tunnel_established) let disconnect_requested = disconnect_requested.load(Ordering::SeqCst);
classify_openconnect_result(connect_result, tunnel_established, disconnect_requested)
} }
fn determine_hip_script(&self) -> (bool, Option<String>) { fn determine_hip_script(&self) -> (bool, Option<String>) {
@@ -427,11 +433,19 @@ impl ConnectHandler<'_> {
} }
} }
fn classify_openconnect_result(exit_code: i32, tunnel_established: bool) -> Result<(), GatewayConnectError> { fn classify_openconnect_result(
exit_code: i32,
tunnel_established: bool,
disconnect_requested: bool,
) -> Result<(), GatewayConnectError> {
if exit_code == 0 { if exit_code == 0 {
return Ok(()); return Ok(());
} }
if disconnect_requested && exit_code == OPENCONNECT_INTERRUPTED_EXIT_CODE {
return Ok(());
}
let error = anyhow::anyhow!("OpenConnect exited with status {}", exit_code); let error = anyhow::anyhow!("OpenConnect exited with status {}", exit_code);
if tunnel_established { if tunnel_established {
Err(GatewayConnectError::after_tunnel(error)) Err(GatewayConnectError::after_tunnel(error))
@@ -477,20 +491,33 @@ mod tests {
#[test] #[test]
fn openconnect_success_is_not_a_gateway_failure() { fn openconnect_success_is_not_a_gateway_failure() {
assert!(classify_openconnect_result(0, false).is_ok()); assert!(classify_openconnect_result(0, false, false).is_ok());
assert!(classify_openconnect_result(0, true).is_ok()); assert!(classify_openconnect_result(0, true, false).is_ok());
} }
#[test] #[test]
fn openconnect_failure_before_callback_is_retryable_gateway_failure() { fn openconnect_failure_before_callback_is_retryable_gateway_failure() {
let err = classify_openconnect_result(1, false).expect_err("nonzero exit should fail"); let err = classify_openconnect_result(1, false, false).expect_err("nonzero exit should fail");
assert!(err.is_before_tunnel()); assert!(err.is_before_tunnel());
} }
#[test] #[test]
fn openconnect_failure_after_callback_is_terminal_gateway_failure() { fn openconnect_failure_after_callback_is_terminal_gateway_failure() {
let err = classify_openconnect_result(1, true).expect_err("nonzero exit should fail"); let err = classify_openconnect_result(1, true, false).expect_err("nonzero exit should fail");
assert!(!err.is_before_tunnel());
}
#[test]
fn interrupted_exit_after_requested_disconnect_is_success() {
assert!(classify_openconnect_result(OPENCONNECT_INTERRUPTED_EXIT_CODE, true, true).is_ok());
}
#[test]
fn interrupted_exit_without_requested_disconnect_is_failure() {
let err = classify_openconnect_result(OPENCONNECT_INTERRUPTED_EXIT_CODE, true, false)
.expect_err("unexpected interrupt should fail");
assert!(!err.is_before_tunnel()); assert!(!err.is_before_tunnel());
} }
+38 -5
View File
@@ -65,10 +65,18 @@ impl<'a> ConnectHandler<'a> {
builder.build() builder.build()
} }
pub(super) fn prelogin_options(&self, portal_default_browser_enabled: bool) -> PreloginOptions { pub(super) fn prelogin_options(&self, gateway_browser_auth_allowed: bool) -> PreloginOptions {
PreloginOptions::default() PreloginOptions::default()
.external_browser_requested(self.external_browser_requested()) .external_browser_requested(self.external_browser_requested())
.portal_default_browser_enabled(portal_default_browser_enabled) .gateway_external_browser_allowed(gateway_browser_auth_allowed)
}
pub(super) fn direct_gateway_prelogin_options(&self) -> PreloginOptions {
self.prelogin_options(true)
}
pub(super) fn gateway_browser_auth_allowed(&self, portal_config_default_browser: bool) -> bool {
gateway_browser_auth_allowed(portal_config_default_browser, self.external_browser_requested())
} }
fn external_browser_requested(&self) -> bool { fn external_browser_requested(&self) -> bool {
@@ -169,7 +177,8 @@ impl<'a> ConnectHandler<'a> {
None => portal_config.auth_cookie().clone(), None => portal_config.auth_cookie().clone(),
}; };
let allow_extend_session = portal_config.allow_extend_session().unwrap_or(false); let allow_extend_session = portal_config.allow_extend_session().unwrap_or(false);
let portal_default_browser_enabled = portal_config.default_browser().unwrap_or(false); let portal_config_default_browser = portal_config.default_browser().unwrap_or(false);
info!("Portal config default-browser: {}", portal_config_default_browser);
if self.args.auto_gateway { if self.args.auto_gateway {
let gateways = portal_config.gateways(); let gateways = portal_config.gateways();
@@ -194,7 +203,7 @@ impl<'a> ConnectHandler<'a> {
gateway.server(), gateway.server(),
&auth_cookie, &auth_cookie,
allow_extend_session, allow_extend_session,
portal_default_browser_enabled, portal_config_default_browser,
gateway_context, gateway_context,
) )
.await .await
@@ -259,7 +268,7 @@ impl<'a> ConnectHandler<'a> {
gateway, gateway,
&auth_cookie, &auth_cookie,
allow_extend_session, allow_extend_session,
portal_default_browser_enabled, portal_config_default_browser,
gateway_context, gateway_context,
) )
.await .await
@@ -279,3 +288,27 @@ impl<'a> ConnectHandler<'a> {
); );
} }
} }
fn gateway_browser_auth_allowed(portal_config_default_browser: bool, external_browser_requested: bool) -> bool {
portal_config_default_browser || external_browser_requested
}
#[cfg(test)]
mod tests {
use super::gateway_browser_auth_allowed;
#[test]
fn gateway_browser_auth_is_allowed_by_portal_config() {
assert!(gateway_browser_auth_allowed(true, false));
}
#[test]
fn gateway_browser_auth_is_allowed_by_explicit_browser_request() {
assert!(gateway_browser_auth_allowed(false, true));
}
#[test]
fn gateway_browser_auth_is_disabled_without_portal_config_or_user_request() {
assert!(!gateway_browser_auth_allowed(false, false));
}
}
+31
View File
@@ -1,5 +1,35 @@
# Changelog # Changelog
## 2.6.5
### Fixed
- Fixed duplicate tray icons caused by both Tauri configuration and application code creating a tray icon (fix [#464](https://github.com/yuezk/GlobalProtect-openconnect/issues/464)).
- Fixed a potential crash when VPN progress messages contain printf-style format specifiers.
## 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
- Fixed NixOS GUI launch authorization after package updates.
- Fixed disconnect handling so a normal Ctrl+C logout no longer reports an error.
- Fixed snapshot flake hash update automation for prebuilt Nix packages.
## 2.6.2
### Fixed
- Fixed gateway fallback browser authentication when external browser authentication is explicitly requested.
- Added logging for portal config default-browser behavior.
- Added GUI managed configuration support with `gpgui.conf`, including reset to managed config.
- Improved GUI config directory migration and managed license auto activation.
## 2.6.1 ## 2.6.1
### Changed ### Changed
@@ -12,6 +42,7 @@
- Fixed NixOS GUI launch failures caused by package-local binary paths. - Fixed NixOS GUI launch failures caused by package-local binary paths.
- Fixed NixOS tray icon setup documentation for GNOME desktops. - Fixed NixOS tray icon setup documentation for GNOME desktops.
- Fixed browser authentication for portals that require a client certificate.
- Fixed release automation so Nix flake hash updates are run manually after release assets are available. - Fixed release automation so Nix flake hash updates are run manually after release assets are available.
## 2.6.0 ## 2.6.0
+4 -3
View File
@@ -19,10 +19,11 @@ pub async fn auth_prelogin(
server: &str, server: &str,
gp_params: &GpParams, gp_params: &GpParams,
external_browser_requested: bool, external_browser_requested: bool,
gateway_external_browser_allowed: bool,
) -> anyhow::Result<String> { ) -> anyhow::Result<String> {
// gpauth only performs the initial portal/gateway prelogin. Portal policy is let options = PreloginOptions::default()
// not available here, so gateway prelogin stays on the embedded value. .external_browser_requested(external_browser_requested)
let options = PreloginOptions::default().external_browser_requested(external_browser_requested); .gateway_external_browser_allowed(gateway_external_browser_allowed);
match prelogin(server, gp_params, options).await? { match prelogin(server, gp_params, options).await? {
Prelogin::Saml(prelogin) => Ok(prelogin.saml_request().to_string()), Prelogin::Saml(prelogin) => Ok(prelogin.saml_request().to_string()),
Prelogin::Standard(_) => bail!("Received non-SAML prelogin response"), Prelogin::Standard(_) => bail!("Received non-SAML prelogin response"),
+2 -2
View File
@@ -184,7 +184,7 @@ impl<'a> WebviewAuthenticator<'a> {
let auth_request = match self.auth_request { let auth_request = match self.auth_request {
Some(auth_request) => auth_request.to_string(), Some(auth_request) => auth_request.to_string(),
None => auth_prelogin(&self.server, &self.gp_params, false).await?, None => auth_prelogin(&self.server, &self.gp_params, false, false).await?,
}; };
let (tx, rx) = oneshot::channel::<anyhow::Result<()>>(); let (tx, rx) = oneshot::channel::<anyhow::Result<()>>();
@@ -257,7 +257,7 @@ impl<'a> WebviewAuthenticator<'a> {
document.body.appendChild(loading); document.body.appendChild(loading);
"#)?; "#)?;
let auth_request = auth_prelogin(&self.server, &self.gp_params, false).await?; let auth_request = auth_prelogin(&self.server, &self.gp_params, false, false).await?;
let (tx, rx) = oneshot::channel::<anyhow::Result<()>>(); let (tx, rx) = oneshot::channel::<anyhow::Result<()>>();
let webview_user_agent = self.webview_user_agent.clone(); let webview_user_agent = self.webview_user_agent.clone();
+44 -1
View File
@@ -39,7 +39,7 @@ pub(crate) fn build(input: &GatewayLoginInput) -> RequestParams {
input.gp_params.input_str().unwrap_or_default().into(), input.gp_params.input_str().unwrap_or_default().into(),
)); ));
if let Some(otp) = input.gp_params.otp() { 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() { if let Some(os_version) = input.gp_params.os_version() {
body.push(("os-version".into(), os_version.into())); body.push(("os-version".into(), os_version.into()));
@@ -99,6 +99,15 @@ pub(crate) fn build(input: &GatewayLoginInput) -> RequestParams {
RequestParams { body, query: vec![] } 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. /// Resolve the gateway server to an IPv4 address if the profile requires it.
/// ///
/// Falls back to the original gateway host if resolution fails. /// Falls back to the original gateway host if resolution fails.
@@ -153,6 +162,40 @@ mod tests {
Credential::Password(PasswordCredential::new("alice", "secret")) 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] #[test]
fn build_without_context_includes_identity_fields() { fn build_without_context_includes_identity_fields() {
let profile = test_profile(ClientOs::Linux); let profile = test_profile(ClientOs::Linux);
+6 -6
View File
@@ -90,7 +90,7 @@ impl Prelogin {
#[derive(Debug, Clone, Copy, Default)] #[derive(Debug, Clone, Copy, Default)]
pub struct PreloginOptions { pub struct PreloginOptions {
external_browser_requested: bool, external_browser_requested: bool,
portal_default_browser_enabled: bool, gateway_external_browser_allowed: bool,
} }
impl PreloginOptions { impl PreloginOptions {
@@ -99,13 +99,13 @@ impl PreloginOptions {
self self
} }
pub fn portal_default_browser_enabled(mut self, portal_default_browser_enabled: bool) -> Self { pub fn gateway_external_browser_allowed(mut self, gateway_external_browser_allowed: bool) -> Self {
self.portal_default_browser_enabled = portal_default_browser_enabled; self.gateway_external_browser_allowed = gateway_external_browser_allowed;
self self
} }
fn browser_mode(self, is_gateway: bool) -> PreloginBrowserMode { fn browser_mode(self, is_gateway: bool) -> PreloginBrowserMode {
if self.external_browser_requested && (!is_gateway || self.portal_default_browser_enabled) { if self.external_browser_requested && (!is_gateway || self.gateway_external_browser_allowed) {
PreloginBrowserMode::External PreloginBrowserMode::External
} else { } else {
PreloginBrowserMode::Embedded PreloginBrowserMode::Embedded
@@ -307,12 +307,12 @@ mod tests {
} }
#[test] #[test]
fn browser_mode_requires_portal_policy_for_gateway_external() { fn browser_mode_requires_gateway_external_browser_allowed_for_gateway_external() {
let options = PreloginOptions::default().external_browser_requested(true); let options = PreloginOptions::default().external_browser_requested(true);
assert_eq!(options.browser_mode(true), PreloginBrowserMode::Embedded); assert_eq!(options.browser_mode(true), PreloginBrowserMode::Embedded);
let options = options.portal_default_browser_enabled(true); let options = options.gateway_external_browser_allowed(true);
assert_eq!(options.browser_mode(true), PreloginBrowserMode::External); assert_eq!(options.browser_mode(true), PreloginBrowserMode::External);
} }
+45
View File
@@ -16,6 +16,9 @@ pub struct SamlAuthLauncher<'a> {
os: Option<&'a str>, os: Option<&'a str>,
host_id: Option<&'a str>, host_id: Option<&'a str>,
client_version: Option<&'a str>, client_version: Option<&'a str>,
certificate: Option<&'a str>,
sslkey: Option<&'a str>,
key_password: Option<&'a str>,
fix_openssl: bool, fix_openssl: bool,
ignore_tls_errors: bool, ignore_tls_errors: bool,
#[cfg(feature = "webview-auth")] #[cfg(feature = "webview-auth")]
@@ -38,6 +41,9 @@ impl<'a> SamlAuthLauncher<'a> {
os: None, os: None,
host_id: None, host_id: None,
client_version: None, client_version: None,
certificate: None,
sslkey: None,
key_password: None,
fix_openssl: false, fix_openssl: false,
ignore_tls_errors: false, ignore_tls_errors: false,
#[cfg(feature = "webview-auth")] #[cfg(feature = "webview-auth")]
@@ -83,6 +89,21 @@ impl<'a> SamlAuthLauncher<'a> {
self self
} }
pub fn certificate(mut self, certificate: Option<&'a str>) -> Self {
self.certificate = certificate;
self
}
pub fn sslkey(mut self, sslkey: Option<&'a str>) -> Self {
self.sslkey = sslkey;
self
}
pub fn key_password(mut self, key_password: Option<&'a str>) -> Self {
self.key_password = key_password;
self
}
#[cfg(feature = "webview-auth")] #[cfg(feature = "webview-auth")]
pub fn hidpi(mut self, hidpi: bool) -> Self { pub fn hidpi(mut self, hidpi: bool) -> Self {
self.hidpi = hidpi; self.hidpi = hidpi;
@@ -148,6 +169,18 @@ impl<'a> SamlAuthLauncher<'a> {
auth_cmd.arg("--ignore-tls-errors"); auth_cmd.arg("--ignore-tls-errors");
} }
if let Some(certificate) = self.certificate {
auth_cmd.arg("--certificate").arg(certificate);
}
if let Some(sslkey) = self.sslkey {
auth_cmd.arg("--sslkey").arg(sslkey);
}
if let Some(key_password) = self.key_password {
auth_cmd.arg("--key-password").arg(key_password);
}
#[cfg(feature = "webview-auth")] #[cfg(feature = "webview-auth")]
{ {
if self.hidpi { if self.hidpi {
@@ -222,4 +255,16 @@ mod tests {
assert_eq!(launcher.client_version, Some("6.0.0")); assert_eq!(launcher.client_version, Some("6.0.0"));
} }
#[test]
fn client_certificate_options_are_stored() {
let launcher = SamlAuthLauncher::new("portal.example.com")
.certificate(Some("/tmp/client.pem"))
.sslkey(Some("/tmp/client.key"))
.key_password(Some("secret"));
assert_eq!(launcher.certificate, Some("/tmp/client.pem"));
assert_eq!(launcher.sslkey, Some("/tmp/client.key"));
assert_eq!(launcher.key_password, Some("secret"));
}
} }
+1 -1
View File
@@ -35,7 +35,7 @@ static void print_progress(__attribute__((unused)) void *_vpninfo, int level,
if (message == NULL) { if (message == NULL) {
ERROR("Failed to format log message"); ERROR("Failed to format log message");
} else { } else {
LOG(level, message); vpn_log(level, message);
free(message); free(message);
} }
} }
+91
View File
@@ -0,0 +1,91 @@
# Building from Source on FreeBSD and OpenBSD
This guide builds the open-source components from the `GlobalProtect-openconnect` repository on FreeBSD or OpenBSD.
## Workspace
Clone `GlobalProtect-openconnect`:
```sh
mkdir gp-build
cd gp-build
git clone --recurse-submodules https://github.com/yuezk/GlobalProtect-openconnect.git gp
```
## FreeBSD
Install build and runtime dependencies:
```sh
sudo pkg install git rust libiconv gettext-tools autoconf automake libtool patch \
gmake pkgconf libxml2 gnutls p11-kit nettle gmp gnome-keyring \
libayatana-appindicator polkit webkit2-gtk_41
```
Build and install:
```sh
cd gp
cargo build --release --workspace
sudo gmake install-bsd
```
Verify the installed binaries:
```sh
gpclient --version
gpauth --version
```
## OpenBSD
Install build and runtime dependencies:
```sh
doas pkg_add git rust libiconv gettext-tools autoconf-2.72 automake-1.17 \
libtool patch gmake pkgconf libxml gnutls p11-kit nettle gmp \
gnome-keyring polkit webkitgtk41
```
Use the installed Autoconf and Automake versions:
```sh
export AUTOCONF_VERSION=2.72
export AUTOMAKE_VERSION=1.17
```
If your shell cannot resolve the versioned tools automatically, add the usual unversioned command links:
```sh
doas ln -sf /usr/local/bin/autoreconf-2.72 /usr/local/bin/autoreconf
doas ln -sf /usr/local/bin/autoconf-2.72 /usr/local/bin/autoconf
doas ln -sf /usr/local/bin/autoheader-2.72 /usr/local/bin/autoheader
doas ln -sf /usr/local/bin/autom4te-2.72 /usr/local/bin/autom4te
doas ln -sf /usr/local/bin/aclocal-1.17 /usr/local/bin/aclocal
doas ln -sf /usr/local/bin/automake-1.17 /usr/local/bin/automake
```
Build and install:
```sh
cd gp
cargo build --release --workspace
doas gmake install-bsd
```
Verify the installed binaries:
```sh
gpclient --version
gpauth --version
```
## Verify
After installation, check the CLI help:
```sh
gpclient --help
```
+34 -10
View File
@@ -26,6 +26,7 @@
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml); cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
pname = "globalprotect-openconnect"; pname = "globalprotect-openconnect";
version = cargoToml.workspace.package.version; version = cargoToml.workspace.package.version;
releaseTag = "v2.6.5";
toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
@@ -35,29 +36,29 @@
}; };
src = pkgs.fetchzip { src = pkgs.fetchzip {
url = "https://github.com/yuezk/GlobalProtect-openconnect/releases/download/v${version}/globalprotect-openconnect-${version}.tar.gz"; url = "https://github.com/yuezk/GlobalProtect-openconnect/releases/download/${releaseTag}/globalprotect-openconnect-${version}.tar.gz";
hash = "sha256-Ejvb//r6tE6yMwNwUJq5Z0r57K0IHKFN1YVaXnvpGIs="; hash = "sha256-cp7KRUwVJsyg8m7O70k/uo6WwLqCPbFCnWtXzHn1GgU=";
}; };
cpu = pkgs.stdenv.hostPlatform.parsed.cpu.name; cpu = pkgs.stdenv.hostPlatform.parsed.cpu.name;
gpguiHashes = { gpguiHashes = {
x86_64 = "sha256-jLMErGlfbzhRk8onqqiRXOMeNhdFWBZGOqPPEh9vLyM="; x86_64 = "sha256-7va5dBhmamOqJYbsHUtjWYFnoM8q5ZshB2CyK0NW6fE=";
aarch64 = "sha256-YSjn2oxDaKTtdfK7rsmuMZfD9n1bitVbScIW0fyedXI="; aarch64 = "sha256-uBzBKx39te5R4PloDusjSjUf1Y2iF/xO4dXUX2K4P8o=";
}; };
gpgui = pkgs.fetchzip { gpgui = pkgs.fetchzip {
url = "https://github.com/yuezk/GlobalProtect-openconnect/releases/download/v${version}/gpgui_${cpu}.bin.tar.xz"; url = "https://github.com/yuezk/GlobalProtect-openconnect/releases/download/${releaseTag}/gpgui_${cpu}.bin.tar.xz";
hash = gpguiHashes.${cpu}; hash = gpguiHashes.${cpu};
}; };
binaryHashes = { binaryHashes = {
x86_64 = "sha256-atZRM7v5areQTDkrJrOczSz0tc3P6aGU+BE4VblNE08="; x86_64 = "sha256-AqF+mwxmXxF/dFxmMXbtT2PONVArKKfMpwmX+3cYr5o=";
aarch64 = "sha256-ENE0fHlLSt493QIlotaIMf11MszJszl4ZZAsYWuFJeE="; aarch64 = "sha256-Ul77xppKrrQQDRl/zKjrrj2+8CRjrMagJbLqmDlfz9U=";
}; };
binaryPackage = pkgs.fetchzip { binaryPackage = pkgs.fetchzip {
url = "https://github.com/yuezk/GlobalProtect-openconnect/releases/download/v${version}/globalprotect-openconnect_${version}_${cpu}.bin.tar.xz"; url = "https://github.com/yuezk/GlobalProtect-openconnect/releases/download/${releaseTag}/globalprotect-openconnect_${version}_${cpu}.bin.tar.xz";
hash = binaryHashes.${cpu}; hash = binaryHashes.${cpu};
}; };
@@ -90,7 +91,7 @@
rewriteSourceInstallPaths = '' rewriteSourceInstallPaths = ''
substituteInPlace $out/share/applications/gpgui.desktop \ substituteInPlace $out/share/applications/gpgui.desktop \
--replace-fail /usr/bin/gpclient $out/bin/gpclient --replace-fail /usr/bin/gpclient /run/current-system/sw/bin/gpclient
substituteInPlace $out/libexec/gpclient/hipreport.sh \ substituteInPlace $out/libexec/gpclient/hipreport.sh \
--replace-fail /usr/bin/gpclient $out/bin/gpclient --replace-fail /usr/bin/gpclient $out/bin/gpclient
@@ -106,7 +107,7 @@
rewriteHostInstallPaths = '' rewriteHostInstallPaths = ''
substituteInPlace $out/share/applications/gpgui.desktop \ substituteInPlace $out/share/applications/gpgui.desktop \
--replace-fail /usr/bin/gpclient $out/bin/gpclient --replace-fail /usr/bin/gpclient /run/current-system/sw/bin/gpclient
substituteInPlace $out/share/polkit-1/actions/com.yuezk.gpgui.policy \ substituteInPlace $out/share/polkit-1/actions/com.yuezk.gpgui.policy \
--replace-fail /usr/bin/gpservice $out/bin/gpservice --replace-fail /usr/bin/gpservice $out/bin/gpservice
@@ -117,6 +118,22 @@
fi fi
''; '';
installNixosPolkitRule = ''
chmod u+w $out/share $out/share/polkit-1 2>/dev/null || true
install -d $out/share/polkit-1/rules.d
cat > $out/share/polkit-1/rules.d/49-gpgui.rules <<EOF
polkit.addRule(function(action, subject) {
if (
action.id == "org.freedesktop.policykit.exec" &&
action.lookup("program") == "$out/bin/gpservice" &&
subject.active
) {
return polkit.Result.YES;
}
});
EOF
'';
fromSource = naersk'.buildPackage { fromSource = naersk'.buildPackage {
inherit pname version src; inherit pname version src;
@@ -168,6 +185,7 @@
cp -r packaging/files/usr/libexec $out/libexec cp -r packaging/files/usr/libexec $out/libexec
${rewriteSourceInstallPaths} ${rewriteSourceInstallPaths}
${installNixosPolkitRule}
''; '';
}; };
@@ -197,6 +215,8 @@
cp -r artifacts/usr/lib $out/lib cp -r artifacts/usr/lib $out/lib
fi fi
install -Dm755 ${gpgui}/gpgui $out/bin/gpgui
runHook postInstall runHook postInstall
''; '';
}; };
@@ -218,6 +238,9 @@
"--bind-try" "--bind-try"
"/run/wrappers" "/run/wrappers"
"/run/wrappers" "/run/wrappers"
"--ro-bind-try"
"/etc/gpgui"
"/etc/gpgui"
]; ];
}; };
@@ -327,6 +350,7 @@
fi fi
${rewriteHostInstallPaths} ${rewriteHostInstallPaths}
${installNixosPolkitRule}
runHook postInstall runHook postInstall
''; '';
+2 -1
View File
@@ -23,7 +23,8 @@ Build-Depends: debhelper (>= 9),
libayatana-appindicator3-1, libayatana-appindicator3-1,
gnome-keyring, gnome-keyring,
libwebkit2gtk-4.1-dev, libwebkit2gtk-4.1-dev,
rust-@RUST_VERSION@-all cargo-@RUST_VERSION@,
rustc-@RUST_VERSION@
Homepage: https://github.com/yuezk/GlobalProtect-openconnect Homepage: https://github.com/yuezk/GlobalProtect-openconnect
Package: globalprotect-openconnect Package: globalprotect-openconnect
+74
View File
@@ -0,0 +1,74 @@
# GlobalProtect-openconnect Docker image
This image provides the GlobalProtect-openconnect command-line tools on Alpine Linux. It includes:
- `gpclient` - connect to and disconnect from GlobalProtect VPN portals and gateways
- `gpauth` - complete authentication separately and pipe the result into `gpclient`
The image does not include embedded webview authentication, `gpgui-helper`, or the graphical `gpgui` application.
## Pull
```bash
docker pull yuezk/globalprotect-openconnect:<version>
```
Release images are tagged as `vX.Y.Z`, `X.Y.Z`, and `latest`.
## Usage
VPN tunnel creation requires access to `/dev/net/tun` and the `NET_ADMIN` capability:
```bash
docker run --rm -it --cap-add=NET_ADMIN --device=/dev/net/tun \
yuezk/globalprotect-openconnect:<version> \
connect <portal> --cookie-on-stdin
```
For browser authentication in a headless environment, use remote browser authentication:
```bash
docker run --rm -it --cap-add=NET_ADMIN --device=/dev/net/tun \
yuezk/globalprotect-openconnect:<version> \
connect <portal> --browser remote
```
On a Linux host, add host networking if the VPN routes should affect the host network namespace:
```bash
docker run --rm -it --network host --cap-add=NET_ADMIN --device=/dev/net/tun \
yuezk/globalprotect-openconnect:<version> \
connect <portal> --browser remote
```
Without `--network host`, the VPN connection stays inside the container network namespace. Docker Desktop on macOS and Windows does not make the host use the VPN through `--network host`; run `gpclient` on the host or use a container gateway setup for host traffic.
You can also run `gpauth` separately and pipe its remote-browser output into `gpclient`:
```bash
docker run --rm -it --entrypoint gpauth yuezk/globalprotect-openconnect:<version> \
<portal> --browser remote 2>/dev/null \
| docker run --rm -i --cap-add=NET_ADMIN --device=/dev/net/tun \
yuezk/globalprotect-openconnect:<version> \
connect <portal> --cookie-on-stdin
```
## Common commands
Show top-level help:
```bash
docker run --rm yuezk/globalprotect-openconnect:<version> --help
```
Show help for a command:
```bash
docker run --rm yuezk/globalprotect-openconnect:<version> help connect
```
## Project
GlobalProtect-openconnect is a modern GlobalProtect VPN client for Linux, built on OpenConnect with support for SSO, non-SSO, FIDO2, client certificate authentication, multiple portals and gateways, and direct gateway connections.
Source: https://github.com/yuezk/GlobalProtect-openconnect
+28 -2
View File
@@ -3,6 +3,7 @@
set -euo pipefail set -euo pipefail
release_version="${1:-}" release_version="${1:-}"
release_tag="${2:-}"
if git diff --quiet -- flake.nix; then if git diff --quiet -- flake.nix; then
echo "flake.nix hashes are already up to date" echo "flake.nix hashes are already up to date"
@@ -14,16 +15,41 @@ if [[ -z "$release_version" ]]; then
fi fi
version="${release_version#v}" version="${release_version#v}"
branch="chore/update-flake-hashes-v${version}" if [[ -z "$release_tag" ]]; then
release_tag="v$version"
fi
branch_suffix="v${version}"
title="chore: update flake hashes for v${version}" title="chore: update flake hashes for v${version}"
body="Updates the Nix flake fetchzip hashes for v${version} release assets." body="Updates the Nix flake fetchzip hashes for v${version} release assets."
if [[ "$release_tag" != "v$version" ]]; then
branch_suffix="${branch_suffix}-${release_tag}"
title="chore: update flake hashes for v${version} from ${release_tag}"
body="Updates the Nix flake fetchzip hashes for v${version} using ${release_tag} release assets."
fi
git config user.name "github-actions[bot]" git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
if [[ "$release_tag" == "snapshot" ]]; then
source_branch="${GITHUB_REF_NAME:-$(git branch --show-current)}"
source_branch_slug="$(printf '%s' "$source_branch" | sed -E 's#[/[:space:]]+#-#g; s#[^A-Za-z0-9._-]##g; s#^-+##; s#-+$##')"
branch="chore/flake-${source_branch_slug}"
git switch -C "$branch" git switch -C "$branch"
git add flake.nix git add flake.nix
git commit -m "$title" git commit -m "$title"
git push --force-with-lease origin "$branch" git push --force origin "$branch"
echo "Updated snapshot flake hashes on branch $branch from $source_branch; skipping PR creation"
exit 0
fi
branch="chore/update-flake-hashes-${branch_suffix}"
git switch -C "$branch"
git add flake.nix
git commit -m "$title"
git push --force origin "$branch"
if gh pr view "$branch" --json number > /tmp/flake-pr.json 2> /dev/null; then if gh pr view "$branch" --json number > /tmp/flake-pr.json 2> /dev/null; then
pr_number="$(jq -r '.number' /tmp/flake-pr.json)" pr_number="$(jq -r '.number' /tmp/flake-pr.json)"
+3 -1
View File
@@ -10,6 +10,8 @@ if [[ -z "$tag" ]]; then
fi fi
version="${tag#v}" version="${tag#v}"
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
changelog="$script_dir/../changelog.md"
awk -v version="$version" ' awk -v version="$version" '
$0 == "## " version { $0 == "## " version {
@@ -27,4 +29,4 @@ awk -v version="$version" '
exit 1 exit 1
} }
} }
' changelog.md ' "$changelog"
+17 -4
View File
@@ -9,10 +9,11 @@ PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
FLAKE_FILE="$PROJECT_DIR/flake.nix" FLAKE_FILE="$PROJECT_DIR/flake.nix"
usage() { usage() {
echo "Usage: $0 [version]" echo "Usage: $0 [version] [release-tag]"
echo echo
echo "Updates flake.nix fetchzip hashes from the published GitHub release assets." echo "Updates flake.nix fetchzip hashes from the published GitHub release assets."
echo "When version is omitted, the workspace package version from Cargo.toml is used." echo "When version is omitted, the workspace package version from Cargo.toml is used."
echo "When release-tag is omitted, v<version> is used. Use snapshot to test snapshot assets."
} }
if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then
@@ -35,12 +36,21 @@ if [[ -z "$version" ]]; then
version="$(grep '^version' "$PROJECT_DIR/Cargo.toml" | head -1 | sed 's/version *= *"\(.*\)"/\1/')" version="$(grep '^version' "$PROJECT_DIR/Cargo.toml" | head -1 | sed 's/version *= *"\(.*\)"/\1/')"
fi fi
version="${version#v}" version="${version#v}"
release_tag="${2:-}"
if [[ -z "$release_tag" ]]; then
release_tag="v$version"
fi
if [[ -z "$version" ]]; then if [[ -z "$version" ]]; then
echo "Could not determine release version" >&2 echo "Could not determine release version" >&2
exit 1 exit 1
fi fi
if [[ -z "$release_tag" ]]; then
echo "Could not determine release tag" >&2
exit 1
fi
prefetch_hash() { prefetch_hash() {
local url="$1" local url="$1"
local attempt local attempt
@@ -67,7 +77,7 @@ prefetch_hash() {
release_url() { release_url() {
local asset="$1" local asset="$1"
echo "https://github.com/$REPO/releases/download/v$version/$asset" echo "https://github.com/$REPO/releases/download/$release_tag/$asset"
} }
source_hash="$(prefetch_hash "$(release_url "globalprotect-openconnect-$version.tar.gz")")" source_hash="$(prefetch_hash "$(release_url "globalprotect-openconnect-$version.tar.gz")")"
@@ -81,8 +91,10 @@ GPGUI_X86_64_HASH="$gpgui_x86_64_hash" \
GPGUI_AARCH64_HASH="$gpgui_aarch64_hash" \ GPGUI_AARCH64_HASH="$gpgui_aarch64_hash" \
BINARY_X86_64_HASH="$binary_x86_64_hash" \ BINARY_X86_64_HASH="$binary_x86_64_hash" \
BINARY_AARCH64_HASH="$binary_aarch64_hash" \ BINARY_AARCH64_HASH="$binary_aarch64_hash" \
RELEASE_TAG="$release_tag" \
perl -0pi -e ' perl -0pi -e '
s|(url = "https://github\.com/yuezk/GlobalProtect-openconnect/releases/download/v\$\{version\}/globalprotect-openconnect-\$\{version\}\.tar\.gz";\n\s*hash = ")[^"]+(";)|$1 . $ENV{"SOURCE_HASH"} . $2|e; s|(releaseTag = ")[^"]+(";)|$1 . $ENV{"RELEASE_TAG"} . $2|e;
s|(url = "https://github\.com/yuezk/GlobalProtect-openconnect/releases/download/\$\{releaseTag\}/globalprotect-openconnect-\$\{version\}\.tar\.gz";\n\s*hash = ")[^"]+(";)|$1 . $ENV{"SOURCE_HASH"} . $2|e;
s|(gpguiHashes = \{\n\s*x86_64 = ")[^"]+(";)|$1 . $ENV{"GPGUI_X86_64_HASH"} . $2|e; s|(gpguiHashes = \{\n\s*x86_64 = ")[^"]+(";)|$1 . $ENV{"GPGUI_X86_64_HASH"} . $2|e;
s|(gpguiHashes = \{\n\s*x86_64 = "[^"]+";\n\s*aarch64 = ")[^"]+(";)|$1 . $ENV{"GPGUI_AARCH64_HASH"} . $2|e; s|(gpguiHashes = \{\n\s*x86_64 = "[^"]+";\n\s*aarch64 = ")[^"]+(";)|$1 . $ENV{"GPGUI_AARCH64_HASH"} . $2|e;
s|(binaryHashes = \{\n\s*x86_64 = ")[^"]+(";)|$1 . $ENV{"BINARY_X86_64_HASH"} . $2|e; s|(binaryHashes = \{\n\s*x86_64 = ")[^"]+(";)|$1 . $ENV{"BINARY_X86_64_HASH"} . $2|e;
@@ -94,5 +106,6 @@ grep -F "$gpgui_x86_64_hash" "$FLAKE_FILE" > /dev/null
grep -F "$gpgui_aarch64_hash" "$FLAKE_FILE" > /dev/null grep -F "$gpgui_aarch64_hash" "$FLAKE_FILE" > /dev/null
grep -F "$binary_x86_64_hash" "$FLAKE_FILE" > /dev/null grep -F "$binary_x86_64_hash" "$FLAKE_FILE" > /dev/null
grep -F "$binary_aarch64_hash" "$FLAKE_FILE" > /dev/null grep -F "$binary_aarch64_hash" "$FLAKE_FILE" > /dev/null
grep -F "releaseTag = \"$release_tag\";" "$FLAKE_FILE" > /dev/null
echo "Updated flake.nix hashes for v$version" echo "Updated flake.nix hashes for v$version assets from $release_tag"