vlaci / openconnect-sso

Wrapper script for OpenConnect supporting Azure AD (SAMLv2) authentication to Cisco SSL-VPNs
GNU General Public License v3.0
279 stars 119 forks source link

Is there a way to configure openconnect-sso / openconnect to auto reconnect after the connection stalls/is lost? #106

Open JL102 opened 1 year ago

JL102 commented 1 year ago

Hello,

If I have an openconnect session open and then put my computer to sleep, often times when it reawakens, the connection stalls indefinitely. I then have no internet access until I force-close the openconnect daemon (...hopefully I'm using the word 'daemon' correctly in this case) and completely restart it (including needing to re-authenticate).

Is there a way to configure openconnect-sso (e.g. via command line arguments) to automatically attempt to reconnect in the case where the connection stalls or disconnects in this case?

Thanks!

anishsane commented 1 year ago

I was just about to open the same issue request. And yes, it is possible to 'reuse' the same cookie and launch openconnect binary with that.

The cookie was set with an 'expires' attribute. So, we can keep using it till it expires. (I think.)

In the app.py file, in run_openconnect, we can run it in a loop, while also checking that the token has not expired. But a the same time, when we get a ^C, we need to pass that ^C to sudo openconnect and break out of the loop. In my experiments, except KeyboardInterrupt: should take care of it.

anishsane commented 1 year ago

I just realized that the cookie used for sso_token is created with immediate expiry. (time since epoch = 0).

Maybe there is a way to request the expiry date from _create_auth_finish_request section.