Also changes the "keep going" return value to -EAGAIN.
Signed-off-by: Daniel Lenski <dlenski@gmail.com>
append_mobile_headers(vpninfo, buf);
}
+
+int cstp_sso_detect_done(struct openconnect_info *vpninfo,
+ const struct oc_webview_result *result)
+{
+ 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)) {
+ vpninfo->sso_cookie_value = strdup(cval);
+ break;
+ } else if (!strcmp(vpninfo->sso_error_cookie, cname)) {
+ /* XX: or should we combine both the error cookie name and its value? */
+ vpninfo->quit_reason = strdup(cval);
+ return -EINVAL;
+ }
+ }
+
+ /* Tell the webview to terminate */
+ return 0;
+}
.tcp_mainloop = cstp_mainloop,
.add_http_headers = cstp_common_headers,
.obtain_cookie = cstp_obtain_cookie,
+ .sso_detect_done = cstp_sso_detect_done,
.secure_cookie = "webvpn",
.udp_protocol = "DTLS",
#ifdef HAVE_DTLS
int openconnect_webview_load_changed(struct openconnect_info *vpninfo,
const struct oc_webview_result *result)
{
- 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 1;
- }
+ if (!vpninfo || !result)
+ return -EINVAL;
- for (i=0; result->cookies[i] != NULL; i+=2) {
- if (!strcmp(vpninfo->sso_token_cookie, result->cookies[i]))
- {
- vpninfo->sso_cookie_value = strdup(result->cookies[i+1]);
- break;
- }
- }
+ if (vpninfo->proto->sso_detect_done)
+ return (vpninfo->proto->sso_detect_done)(vpninfo, result);
- // Tell the webview to terminate
- return 0;
+ return -EOPNOTSUPP;
}
/* This does the full authentication, calling back as appropriate */
int (*obtain_cookie)(struct openconnect_info *vpninfo);
+ /* This checks if SSO authentication is complete */
+ int (*sso_detect_done)(struct openconnect_info *vpninfo, const struct oc_webview_result *result);
+
/* Establish the TCP connection (and obtain configuration) */
int (*tcp_connect)(struct openconnect_info *vpninfo);
int decompress_and_queue_packet(struct openconnect_info *vpninfo, int compr_type,
unsigned char *buf, int len);
int compress_packet(struct openconnect_info *vpninfo, int compr_type, struct pkt *this);
+int cstp_sso_detect_done(struct openconnect_info *vpninfo, const struct oc_webview_result *result);
/* auth-html.c */
xmlNodePtr htmlnode_next(xmlNodePtr top, xmlNodePtr node);