]> www.infradead.org Git - users/dwmw2/openconnect.git/commitdiff
AC SAML: do not assume the cookie will be on the final page
authorLuca Boccassi <luca.boccassi@microsoft.com>
Thu, 30 Dec 2021 00:24:30 +0000 (00:24 +0000)
committerLuca Boccassi <bluca@debian.org>
Wed, 23 Feb 2022 19:22:53 +0000 (19:22 +0000)
At least with Google's SAML, the cookie appears before the final page.

Signed-off-by: Luca Boccassi <luca.boccassi@microsoft.com>
cstp.c

diff --git a/cstp.c b/cstp.c
index 81ea1fefb2157db1c8700c9a37ce2308c75236bc..e8fbc4d930a7d8cb115ccc5e989c249556ce617e 100644 (file)
--- a/cstp.c
+++ b/cstp.c
@@ -1254,10 +1254,6 @@ int cstp_sso_detect_done(struct openconnect_info *vpninfo,
 {
        int i;
 
-       /* If we're not at the final URI, tell the webview to keep going */
-       if (strcmp(result->uri, vpninfo->sso_login_final))
-               return -EAGAIN;
-
        for (i=0; result->cookies[i] != NULL; i+=2) {
                const char *cname = result->cookies[i], *cval = result->cookies[i+1];
                if (!strcmp(vpninfo->sso_token_cookie, cname)) {
@@ -1270,6 +1266,11 @@ int cstp_sso_detect_done(struct openconnect_info *vpninfo,
                }
        }
 
+       /* If we're not at the final URI, tell the webview to keep going.
+        * Note that we might find the cookie at any time, not only on the last page. */
+       if (strcmp(result->uri, vpninfo->sso_login_final))
+               return -EAGAIN;
+
        /* Tell the webview to terminate */
        return 0;
 }