-
-
Notifications
You must be signed in to change notification settings - Fork 15.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
globalprotect-openconnect: add core logic and packages for 2.x releases #316526
Conversation
1ad80b9
to
96ec2b5
Compare
7a78a6e
to
52907bd
Compare
I'm keeping an eye on this PR as I'm also in need to a 2.x version of globalprotect. While in most cases I would pitch in to help move a PR along, I'm unfortunately still very new to nix however if you need someone to help test then please let me know. |
Thanks for getting a great start on v2! I built this locally and tried
Next I tried
The browser opened and appeared to authenticate, landing me on a page with this message:
that "click here" is a I base64-decoded the bit after the On a hunch, I did
Note that I have not actually added this to |
@jerith666 The behavior you described is exactly what is expected when you run the program out of |
@davisRoman @jerith666 if you find this PR helpful, it would help if you both could add a 👍 to this PR. Thanks. |
Out of curiosity, since it'll take some time to polish and upstream this PR, would it be possible for me to cherry-pick these commits locally somehow? Unfortunately, the lack of a 2.x globalprotect is preventing me from using my NixOS laptop as my work laptop. I am aware of others at my job that are in the same boat. |
I have a couple techniques for this depending on my use case (quick testing, long term use, etc.). For your use case, I would recommend the following.
As an example, this is something I hacked up under my
|
@wegank Aside from the merge conflict due to the changelog, would you say this PR is in a good shape to be merged or would we need to wait on other reviewers? |
Just a note that I haven't had a chance to come back and try via |
The PR also fails a CI check, so there's still some work to be done. |
@wegank The only PR check it's failing is the one about putting the packages in the by-name directory path. If you look at the change, you will see that it's not feasible since there is a common.nix file that is depended on for both gpclient and gpagent, so that check if a false positive. Let me know if you think otherwise. |
It looks like I will have to follow this recommendation just for the sake of suppressing the warning. |
That check is mandatory: merging this PR while ignoring the error will cause CI check to fail on all other pull requests. I'd suggest dropping |
You do not want |
The |
Okay, I've used this for a few days at work this week, and it works. I'd like to keep v1 around too, because I prefer it for the ergonomic reasons I gave above. But if others feel that's a bad idea since it's unmaintained upstream, I can work around it locally. |
I have tested this locally (installed to system packages using a similar I've tested against a dozen or so portals supporting various combinations of auth (everything from local to SAML to CIE / Cloud Auth) and had success. While I switched almost everything over to Nix last year, lack of GP support for newer Palo Alto auth methods had forced me to use a VM up until now. Awesome work @Binary-Eater , much appreciated! |
The 1.x iteration of globalprotect-openconnect is no longer being developed. Remove related components from nixpkgs. Signed-off-by: Rahul Rameshbabu <sergeantsagara@protonmail.com>
Add maintainer information for Rahul Rameshbabu. Signed-off-by: Rahul Rameshbabu <sergeantsagara@protonmail.com>
The GUI of GlobalProtect-openconnect is unfree software, while the CLI is licensed as GPLv3-only. This packaging work focuses on the CLI, and components required for the CLI. Link: https://github.com/yuezk/GlobalProtect-openconnect Signed-off-by: Rahul Rameshbabu <sergeantsagara@protonmail.com>
2728d94
to
156fe9a
Compare
@ofborg build gpauth gpclient |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I said, I'll probably keep using v1 until $job
updates their server & it's no longer compatible, for ergonomic reasons. But I just rebuilt & tested again, and it's still working, so let's get this in.
4969385
to
2b0ff83
Compare
Anyone in here relying on this other package? https://github.com/yuezk/GlobalProtect-openconnect I had to bring back the deleted module and package to keep it working. I wish I didn't need all this software, but it's $work... 🤷🏽 |
You mean v1 of that package? This PR updated us from v1 to v2 of that package. I am still using v1, which I did by basically reverting the parts of this PR that removed the v1 package in my fork of nixpkgs. |
@gvolpe did you try the V2 version of the software that was merged? |
As a note, the v2 package is named |
@Binary-Eater sorry, I should have provided more info, was caught by surprise by this change and spent most of my Sunday trying to get it back to a working state as I need it for work. The new $ gpclient launch-gui
[2024-10-07T05:59:37Z INFO gpclient::cli] gpclient started: 2.3.7 (2024-10-05)
[2024-10-07T05:59:37Z INFO gpclient::launch_gui] Log file: /home/gvolpe/.local/share/gpclient/gpclient.log
[2024-10-07T05:59:37Z INFO gpclient::launch_gui] Service exited with status: exit status: 127 The log shows the following error: Error accessing /usr/bin/gpservice: No such file or directory EDIT: Nevermind, I missed this bit on the PR description
And trying to connect with the CLI directly seems to get stuck in a loop: $ gpclient connect $work-server.com
[2024-10-07T06:03:59Z INFO gpauth::auth_window] Loaded uri: https://i**********m/app/panw_globalprotect/...OOD697/sso/saml?SAMLRequest=l**********%3D&RelayState=6**********x
[2024-10-07T06:03:59Z INFO gpauth::auth_window] No response found in main resource
[2024-10-07T06:03:59Z INFO gpauth::auth_window] Got invalid auth data, retrying...
[2024-10-07T06:03:59Z INFO gpapi::portal::prelogin] Portal prelogin with user_agent: PAN GlobalProtect
[2024-10-07T06:03:59Z INFO gpauth::auth_window] Injected loading element successfully
[2024-10-07T06:03:59Z INFO gpapi::portal::prelogin] Perform prelogin, user_agent: PAN GlobalProtect
[2024-10-07T06:03:59Z INFO gpauth::auth_window] Load the SAML request as URI...
[2024-10-07T06:03:59Z WARN gpauth::auth_window] Failed to load uri: https://i**********m/app/panw_globalprotect/...OOD697/sso/saml?SAMLRequest=l**********%3D&RelayState=8**********x with error: TLS/SSL support not available; install glib-networking
[2024-10-07T06:03:59Z INFO gpauth::auth_window] Loaded uri: https://i**********m/app/panw_globalprotect/...OOD697/sso/saml?SAMLRequest=l**********%3D&RelayState=8**********x
[2024-10-07T06:03:59Z INFO gpauth::auth_window] No response found in main resource
[2024-10-07T06:03:59Z INFO gpauth::auth_window] Got invalid auth data, retrying... Same issue running it with For completeness, here's how I install these new packages on my NixOS (Hyprland / Wayland) machine: environment.systemPackages = with pkgs; [ gpauth gpclient ]; |
Okay I followed this approach shared by @jerith666 and I've made some progress. The following command launches a new tab on my open work browser and I get successfully redirected back to the terminal where I'm prompted to select the gateway. After I do so, I get permission denied errors: Click to see logs$ gpclient connect $work-server.com --browser work-browser
[2024-10-07T07:21:46Z INFO gpclient::cli] gpclient started: 2.3.7 (2024-10-05)
[2024-10-07T07:21:46Z INFO gpapi::portal::prelogin] Portal prelogin with user_agent: PAN GlobalProtect
[2024-10-07T07:21:46Z INFO gpapi::portal::prelogin] Perform prelogin, user_agent: PAN GlobalProtect
[2024-10-07T07:21:47Z INFO gpauth::cli] gpauth started: 2.3.7 (2024-10-05)
[2024-10-07T07:21:47Z INFO gpapi::process::browser_authenticator] Launching browser: work-browser
[2024-10-07T07:21:47Z INFO gpauth::cli] Please continue the authentication process in the default browser
[2024-10-07T07:21:47Z INFO gpauth::cli] Listening authentication data on port 45807
[2024-10-07T07:21:47Z INFO gpauth::cli] If it hangs, please check the logs at `/tmp/gpcallback.log` for more information
[2024-10-07T07:21:55Z INFO gpauth::cli] Received the browser authentication data from the socket
[2024-10-07T07:21:55Z INFO gpauth::cli] Authentication completed
[2024-10-07T07:21:55Z INFO gpapi::portal::config] Retrieve the portal config, user_agent: PAN GlobalProtect
[2024-10-07T07:21:56Z INFO gpapi::gateway::parse_gateways] Try to parse the external gateways...
> Which gateway do you want to connect to? REDACTED
[2024-10-07T07:22:02Z INFO gpclient::connect] Connecting to the selected gateway: REDACTED
[2024-10-07T07:22:02Z INFO gpapi::gateway::login] Perform gateway login, user_agent: PAN GlobalProtect
[2024-10-07T07:22:03Z INFO openconnect::ffi] openconnect version: v9.12
[2024-10-07T07:22:03Z INFO openconnect::ffi] User agent: PAN GlobalProtect
[2024-10-07T07:22:03Z INFO openconnect::ffi] VPNC script: /nix/store/j769xj3qq2q6s6wh4csapr6mw0sig84v-vpnc-scripts-unstable-2023-01-03/bin/vpnc-script
[2024-10-07T07:22:03Z INFO openconnect::ffi] OS: linux
[2024-10-07T07:22:03Z INFO openconnect::ffi] CSD_USER: 1000
[2024-10-07T07:22:03Z INFO openconnect::ffi] CSD_WRAPPER: (null)
[2024-10-07T07:22:03Z INFO openconnect::ffi] RECONNECT_TIMEOUT: 300
[2024-10-07T07:22:03Z INFO openconnect::ffi] MTU: 0
[2024-10-07T07:22:03Z INFO openconnect::ffi] DISABLE_IPV6: 0
[2024-10-07T07:22:03Z INFO openconnect::ffi] NO_DTLS: 0
[2024-10-07T07:22:03Z INFO openconnect::ffi] POST https://work-server.com/ssl-vpn/getconfig.esp
[2024-10-07T07:22:03Z INFO openconnect::ffi] Connected to REDACTED IP ADDRESS
[2024-10-07T07:22:03Z INFO openconnect::ffi] SSL negotiation with GATEWAY
[2024-10-07T07:22:04Z INFO openconnect::ffi] Connected to HTTPS on GATEWAY with ciphersuite (TLS1.2)-(ECDHE-SECP256R1)-(RSA-SHA256)-(AES-256-GCM)
[2024-10-07T07:22:04Z INFO openconnect::ffi] Tunnel timeout (rekey interval) is 2880 minutes.
[2024-10-07T07:22:04Z INFO openconnect::ffi] Idle timeout is 2880 minutes.
[2024-10-07T07:22:04Z WARN openconnect::ffi] No MTU received. Calculated 1422 for ESP tunnel
[2024-10-07T07:22:04Z INFO openconnect::ffi] POST https://work-server.com/ssl-vpn/hipreportcheck.esp
[2024-10-07T07:22:04Z WARN openconnect::ffi] WARNING: Server asked us to submit HIP report with md5sum 109cd121dfdf5faf1f420ca7fab50501.
VPN connectivity may be disabled or limited without HIP report submission.
You need to provide a --csd-wrapper argument with the HIP report submission script.
[2024-10-07T07:22:04Z INFO openconnect::ffi] ESP session established with server
[2024-10-07T07:22:04Z INFO openconnect::ffi] ESP tunnel connected; exiting HTTPS mainloop.
mkdir: cannot create directory ‘/var/run/vpnc’: Permission denied
[2024-10-07T07:22:04Z WARN openconnect::ffi] Failed to bind local tun device (TUNSETIFF): Operation not permitted
[2024-10-07T07:22:04Z WARN openconnect::ffi] To configure local networking, openconnect must be running as root
See https://www.infradead.org/openconnect/nonroot.html for more information
mkdir: cannot create directory ‘/var/run/vpnc’: Permission denied
[2024-10-07T07:22:04Z WARN openconnect::ffi] Failed to bind local tun device (TUNSETIFF): Operation not permitted
[2024-10-07T07:22:04Z WARN openconnect::ffi] To configure local networking, openconnect must be running as root
See https://www.infradead.org/openconnect/nonroot.html for more information
[2024-10-07T07:22:04Z WARN openconnect::ffi] Set up tun device failed
[2024-10-07T07:22:04Z INFO openconnect::ffi] POST https://work-server.com/ssl-vpn/logout.esp
[2024-10-07T07:22:04Z INFO openconnect::ffi] SSL negotiation with GATEWAY
[2024-10-07T07:22:05Z INFO openconnect::ffi] Connected to HTTPS on GATEWAY with ciphersuite (TLS1.2)-(ECDHE-SECP256R1)-(RSA-SHA256)-(AES-256-GCM)
[2024-10-07T07:22:05Z INFO openconnect::ffi] Logout successful.
[2024-10-07T07:22:05Z INFO openconnect::ffi] openconnect_mainloop returned -5, exiting So I tried the same command but with $ sudo gpclient connect $work-server.com --browser chromium
...
[2024-10-07T07:30:20Z INFO gpapi::process::browser_authenticator] Launching browser: chromium
[2024-10-07T07:30:20Z INFO gpauth::cli] Please continue the authentication process in the default browser
[2024-10-07T07:30:20Z INFO gpauth::cli] Listening authentication data on port 39543
[2024-10-07T07:30:20Z INFO gpauth::cli] If it hangs, please check the logs at `/tmp/gpcallback.log` for more information Unfortunately, it fails to execute the callback so it just hangs on the terminal. I tried sending the prelogin-cookie/callback base64 string as follows: $ echo PRELOGIN_COOKIE | ncat localhost 39543 But I just get "Invalid auth data", so I'm missing this last piece: $ [2024-10-07T07:32:02Z INFO gpauth::cli] Received the browser authentication data from the socket
[2024-10-07T07:32:02Z WARN gpapi::auth] Failed to decode SAML auth data: Invalid byte 10, offset 380.
[2024-10-07T07:32:02Z INFO gpauth::cli] Authentication completed
[2024-10-07T07:32:02Z INFO gpclient::connect] Failed to connect portal with prelogin: Invalid auth data
Error: Invalid auth data |
This works: $ gpauth <portal> --browser work-browser 2>/dev/null | sudo gpclient connect <portal> --cookie-on-stdin This too (the $ sudo -E gpclient connect <portal> --browser work-browser I'm still keeping |
@gvolpe I agree in terms of ergonomics that this new V2 client is a downgrade. Unfortunately, the V1 client is no longer maintained and does not support every new authentication scheme GlobalProtect has come up with recently. Unfortunately, the GUI component for V2 is unfree (you also need a paid license, which is not as big of an issue) and more importantly unauditable (which seems somewhat problematic for a VPN client), so I felt hesitant to package something like that when the cli is easy to audit. |
@Binary-Eater completely agree with the approach, appreciate your work on this! Fingers crossed a new open-source UI comes around for v2 🤞🏽 (didn't know one needed a paid license to use it 😮 ). |
Here's how I ended up wrapping the v2 client to make it work in the most painless way I could: let
vpnScript = pkgs.stdenv.mkDerivation {
name="vpn";
src = pkgs.writeScript "vpn" ''
#! ${pkgs.bash}/bin/bash
id
${pkgs.gpclient}/bin/gpclient \
connect \
--browser ${pkgs.chromium}/bin/chromium \
https://<redacted> \
--csd-wrapper ${pkgs.openconnect}/libexec/openconnect/hipreport.sh
'';
dontUnpack=true;
installPhase = ''
mkdir -p $out/bin
ln -s $src $out/bin/vpn
'';
};
in
{
security.wrappers = {
vpn = {
owner = "root";
group = "root";
setuid = true;
setgid = true;
source = "${vpnScript}/bin/vpn";
};
};
} Though for some reason I still have to use |
Description of changes
The 1.x iteration of globalprotect-openconnect is no longer being
developed. Remove related components from nixpkgs.
The GUI of GlobalProtect-openconnect is unfree software, while the CLI is
licensed as GPLv3-only. This packaging work focuses on the CLI, and
components required for the CLI.
Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.