4 This is a helper script to allow you to interactively login to a GlobalProtect VPN
5 that uses SAML authentication.
7 Interactive login is, unfortunately, sometimes a necessary alternative to automated
8 login via scripts such as
9 [zdave/openconnect-gp-okta](https://github.com/zdave/openconnect-gp-okta).
14 gp-saml-gui uses GTK, which requires Python 3 bindings.
16 On Debian / Ubuntu, these are packaged as `python3-gi`, `gir1.2-gtk-3.0`, and
20 $ sudo apt install python3-gi gir1.2-gtk-3.0 gir1.2-webkit2-4.0
23 Then, set up a virtual environment that can access these system packages,
24 activate it, and install the Python dependencies:
27 $ virtualenv --python=python3 --system-site-packages venv
29 $ pip install requests
35 Specify the GlobalProtect server URL (portal or gateway) and optional arguments.
37 This script will pop up a [GTK WebKit2 WebView](https://webkitgtk.org/) window.
38 After you succesfully complete the SAML login via web forms, the script will output
39 `HOST`, `USER`, and `COOKIE` variables in a form that can be used by
40 [OpenConnect](http://www.infradead.org/openconnect/juniper.html)
41 (similar to the output of `openconnect --authenticate`):
44 $ eval $( gp-saml-gui.py -v vpn.company.com )
45 Got SAML POST content, opening browser...
46 Finished loading about:blank...
47 Finished loading https://company.okta.com/app/panw_globalprotect/deadbeefFOOBARba1234/sso/saml...
48 Finished loading https://company.okta.com/login/sessionCookieRedirect...
49 Finished loading https://vpn.qorvo.com/SAML20/SP/ACS...
50 Got SAML relevant headers, done: {'prelogin-cookie': 'blahblahblah', 'saml-username': 'foo12345@corp.company.com', 'saml-slo': 'no', 'saml-auth-status': '1'}
52 SAML response converted to OpenConnect command line invocation:
55 openconnect --protocol=gp --user='foo12345@corp.company.com' --usergroup=prelogin-cookie:gateway --passwd-on-stdin vpn.company.com
57 $ echo $HOST; echo $USER; echo $COOKIE
58 https://vpn.company.com/gateway:prelogin-cookie
59 foo12345@corp.company.com
62 $ echo "$COOKIE" | openconnect --protocol=gp -u "$USER" --passwd-on-stdin "$HOST"