Skip to content
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

Allow to use default browser for SAML auth window #98

Closed
anatol opened this issue Oct 14, 2021 · 13 comments
Closed

Allow to use default browser for SAML auth window #98

anatol opened this issue Oct 14, 2021 · 13 comments

Comments

@anatol
Copy link

anatol commented Oct 14, 2021

I use GlobalProtect-openconnect for my VPN and it works great.

Though current login flow has one inconvenience. When I login to my VPN it opens SAML login page in a separate window. I type the login. Then I open my browser to get into internal resources (like JIRA bug tracker) and now I need to type the password and use Yubikey for authentication one more time.

It would be great if the authentication information reused both for VPN application and the browser session. Some other clients (like proprietary GlobalProtect) open SAML in the default browser and once I authenticate there it starts working both for VPN itself and browser. Could you please similar functionality to GlobalProtect-openconnect as well?

@yuezk
Copy link
Owner

yuezk commented Oct 15, 2021

It's a good suggestion, but it's not that easy to implement on the Linux system. The primary problem is the client couldn't communicate with the default browser to get the authentication token, even though I could launch the default browser.

@anatol
Copy link
Author

anatol commented Oct 15, 2021

I think proprietary client is able to use the default browser to share session with SAML login. So communication with browser part should be doable.

I know there are technologies like selenium that allow to start a browser, manage window state, modify/read DOM. Here is a client for c++ https://github.com/sekogan/webdriverxx

@yuezk
Copy link
Owner

yuezk commented Oct 18, 2021

@anatol Thanks. I have some knowledge of browser drivers and had used Protractor to perform the E2E testing. I will take your advice and see if the solution is feasible. Thanks.

@sudoforge
Copy link

sudoforge commented Oct 18, 2021

The proprietary client works with an external browser by providing a callback URI to the SAML provider; something like globalprotect://<foo>. I think this works because the proprietary client is integrated with the specific SAML provider, however, it should be noted that the user would need to ensure that the specific URI is configured to open the application on their system (using an external browser with the proprietary client doesn't work by default for me, for example).

@denilsonsa
Copy link

As an alternative, this project could start up a temporary HTTP server listening to a specific port on localhost. That way, after the authentication process, the browser would connect to the local server to finish up sending the required data back to the daemon.

MozWire project implements this flow. It is a non-official client to the MozillaVPN service, and it also requires a browser authentication.

If this idea gets implemented here, I'd suggest to also display the URL that it tries to open in the browser, just in case launching the browser fails, or if it opens the wrong browser/profile.

@BrendanBall
Copy link

If anyone wants to implement this, here is how you need to do it (at least based on my config):

  1. include default-browser=1 as a query parameter in the prelogin request.
  2. save the saml-request html from the prelogin response somewhere that the default browser can access (either /tmp/ or $XDG_CACHE_HOME).
  3. run xdg-open <path to saml-request.html> to open in your default browser.
  4. Perform login as necessary, redirects happen
  5. The browser requests to open the GlobalProtect application. It does this by making a request with the uri globalprotectcallback:<data>. The browser makes use of xdg-open to decide which application to open
  6. To complete 5. you need to have a desktop entry which specifies MimeType=x-scheme-handler/globalprotectcallback;
  7. The application specified in the desktop entry gets executed with the uri as an argument.
  8. use the data in the uri to complete the auth with openconnect.

I don't think we can use an http server since as users we're not able to configure how the GlobalProtect server behaves.

@kudos
Copy link

kudos commented May 3, 2023

@BrendanBall any chance you could share the script you're using to do all those things? I'm not expecting it to be anything I could use directly, but would help a lot when writing my own. Any maybe someone can evolve it into something more general :)

@BrendanBall
Copy link

I don't have a script that does all of this, but the flow is mostly the same as is currently implemented. You just need to add the default-browser=1 query parameter to the prelogin url.
Then instead of using an embedded webview you save the saml request and use xdg-open. The browser callback makes it a bit difficult to just implement a script to do this because you need an app registered to be used with xdg-open, but if you manage to do that, you could have it pass the callback data to your waiting script by either listening on localhost or using dbus.

I wanted to try integrate it with NetworkManager, but turns out NetworkManager vpn plugins are not that straightforward and lacks a lot of documentation and I'm not a C programmer, so it would just take too much time to figure out.

If you actually have a GlobalProtect account to test against, it shouldn't be too difficult to figure out.
The missing query parameter was the big missing piece, because without it, the server doesn't end up doing the callback, which is why people are using embedded webviews/doing weird things with selenium.

@kudos
Copy link

kudos commented May 5, 2023

@BrendanBall Gotcha, thanks for the clarification!

@janbrummer
Copy link

I wanted to try integrate it with NetworkManager, but turns out NetworkManager vpn plugins are not that straightforward and lacks a lot of documentation and I'm not a C programmer, so it would just take too much time to figure out.

I've just pushed a draft version for openconnect. So there is no need to change NM-openconnect.

@yuezk
Copy link
Owner

yuezk commented Jan 22, 2024

Supported in 2.0.0-beta5, you can enable this option in settings. Closing.

@yuezk yuezk closed this as completed Jan 22, 2024
@Mirro888
Copy link

Mirro888 commented Mar 31, 2024

@BredanBall: the browser returns something like:

globalprotectcallback:cas-as=1&un=[email protected]&token=very_long_string

How shall I use the token in the openconnect client?

Thank you,

Mirro

@yuezk
Copy link
Owner

yuezk commented Apr 1, 2024

@Mirro888 Let's move to #339 to continue the discussion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants