Skip to contentSkip to conversation

Implement parsing and sending INFO and INFO_PRE control messages

PATCH Superseded Arne Schwabe 4 participants 17 messages Nov 9, 2019 – May 20, 2020 1 message not in the archive

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/5 Implement parsing and sending INFO and INFO_PRE control messages

OpenVPN 3 implements these messages to send information during the authentication to the UI, implement these message also in OpenVPN 2.x

---
 src/openvpn/forward.c |  8 ++++++++
 src/openvpn/push.c    | 33 +++++++++++++++++++++++++++++++++
 src/openvpn/push.h    |  3 +++
 3 files changed, 44 insertions(+)
src/openvpn/forward.c +8 -0
index 8451706b..0f735384 100644
@@ -395,6 +395,14 @@ check_incoming_control_channel_dowork(struct context *c)
             {
                 server_pushed_signal(c, &buf, false, 4);
             }
+            else if (buf_string_match_head_str(&buf, "INFO_PRE"))
+            {
+                server_pushed_info(c, &buf, 8);
+            }
+            else if (buf_string_match_head_str(&buf, "INFO"))
+            {
+                server_pushed_info(c, &buf, 4);
+            }
             else
             {
                 msg(D_PUSH_ERRORS, "WARNING: Received unknown control message: %s", BSTR(&buf));
src/openvpn/push.c +33 -0
index 368b6920..ee1cb980 100644
@@ -178,6 +178,39 @@ server_pushed_signal(struct context *c, const struct buffer *buffer, const bool
     }
 }
 
+void
+server_pushed_info(struct context *c, const struct buffer *buffer,
+                   const int adv)
+{
+    const char *m = "";
+    struct buffer buf = *buffer;
+
+    if (buf_advance(&buf, adv) && buf_read_u8(&buf) == ',' && BLEN(&buf))
+    {
+        m = BSTR(&buf);
+    }
+
+#ifdef ENABLE_MANAGEMENT
+    struct gc_arena gc;
+    if (management)
+    {
+        gc = gc_new();
+
+        /*
+         * We use >INFOMSG here instead of plain >INFO since INFO is used to
+         * for management greeting and we don't want to confuse the client
+         */
+        struct buffer out = alloc_buf_gc(256, &gc);
+        buf_printf(&out, ">%s:%s", "INFOMSG", m);
+        management_notify_generic(management, BSTR(&out));
+
+        gc_free(&gc);
+    }
+    #endif
+    msg(D_PUSH, "Info command was pushed by server ('%s')", m);
+}
+
+
 #if P2MP_SERVER
 /**
  * Add an option to the given push list by providing a format string.
src/openvpn/push.h +3 -0
index 070782dd..9cf8fb34 100644
@@ -50,6 +50,9 @@ void receive_auth_failed(struct context *c, const struct buffer *buffer);
 
 void server_pushed_signal(struct context *c, const struct buffer *buffer, const bool restart, const int adv);
 
+void server_pushed_info(struct context *c, const struct buffer *buffer,
+                        const int adv);
+
 void incoming_push_message(struct context *c, const struct buffer *buffer);
 
 #if P2MP_SERVER
Signature · 1 line
2.22.0
#1 lore raw

PATCH v2 2/5 Implement support for signalling IV_SSO to server

---
 src/openvpn/ssl.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
src/openvpn/ssl.c +3 -1
index 4455ebb8..cbb87e43 100644
@@ -2355,7 +2355,9 @@ push_peer_info(struct buffer *buf, struct tls_session *session)
                 if ((((strncmp(e->string, "UV_", 3)==0
                        || strncmp(e->string, "IV_PLAT_VER=", sizeof("IV_PLAT_VER=")-1)==0)
                       && session->opt->push_peer_info_detail >= 2)
-                     || (strncmp(e->string,"IV_GUI_VER=",sizeof("IV_GUI_VER=")-1)==0))
+                     || (strncmp(e->string,"IV_GUI_VER=",sizeof("IV_GUI_VER=")-1)==0)
+                     || (strncmp(e->string,"IV_SSO=",sizeof("IV_SSO=")-1)==0)
+                     )
                     && buf_safe(&out, strlen(e->string)+1))
                 {
                     buf_printf(&out, "%s\n", e->string);
Signature · 1 line
2.22.0
#4 lore raw

PATCH v2 3/5 Implement sending response to challenge via CR_RESPONSE

In reply to Arne Schwabe

When a client announces its support to support text based challenge/response via IV_SOO=cr_text,the client needs to also be able to reply to that response.

This adds the "cr-response" management function to be able to do this. The answer should be base64 encoded.

---
 doc/management-notes.txt |  8 ++++++++
 src/openvpn/init.c       | 39 +++++++++++++++++++++++++++++++++++++++
 src/openvpn/manage.c     | 39 ++++++++++++++++++++++++++++++++++++++-
 src/openvpn/manage.h     |  1 +
 4 files changed, 86 insertions(+), 1 deletion(-)
doc/management-notes.txt +8 -0
index 17645c1d..e380ca2b 100644
@@ -806,6 +806,14 @@ To accept connecting to the host and port directly, use this command:
 
   proxy NONE
 
+COMMAND -- cr-response (OpenVPN 2.5 or higher)
+-------------------------------------------------
+Provides support for sending responses a challenge/response
+query via INFOMSG,CR_TEXT. The response should be base64 encoded:
+
+  cr-response SGFsbG8gV2VsdCE=
+
+
 COMMAND -- pk-sig (OpenVPN 2.5 or higher, management version > 1)
 COMMAND -- rsa-sig (OpenVPN 2.3 or higher, management version <= 1)
 -----------------------------------------------------------------
src/openvpn/init.c +39 -0
index 0bdb0a9c..77c1c23b 100644
@@ -288,6 +288,44 @@ ce_management_query_proxy(struct context *c)
     return ret;
 }
 
+/**
+ * This method sends a custom control channel message
+ *
+ * This will write the control message
+ *
+ *  command parm1,parm2,..
+ *  .
+ * to the control channel.
+ *
+ * @param arg           The context struct
+ * @param command       The command being sent
+ * @param parameters    the parameters to the command
+ * @return              if sending was successful
+ */
+static bool
+management_callback_send_cc_mesage(void *arg,
+                                   const char *command,
+                                   const char *parameters)
+{
+    struct context *c = (struct context *) arg;
+    size_t len = strlen(command) + 1 + sizeof(parameters) + 1;
+    if (len > PUSH_BUNDLE_SIZE)
+    {
+        return false;
+    }
+
+    struct gc_arena gc = gc_new();
+    struct buffer buf = alloc_buf_gc(len, &gc);
+    ASSERT(buf_printf(&buf, "%s", command));
+    if (parameters)
+    {
+        ASSERT(buf_printf(&buf, ",%s", parameters));
+    }
+    bool status = send_control_channel_string(c, BSTR(&buf), D_PUSH);
+
+    gc_free(&gc);
+    return status;
+}
 
 static bool
 management_callback_remote_cmd(void *arg, const char **p)
@@ -3990,6 +4028,7 @@ init_management_callback_p2p(struct context *c)
         cb.show_net = management_show_net_callback;
         cb.proxy_cmd = management_callback_proxy_cmd;
         cb.remote_cmd = management_callback_remote_cmd;
+        cb.send_cc_message = management_callback_send_cc_mesage;
 #ifdef TARGET_ANDROID
         cb.network_change = management_callback_network_change;
 #endif
src/openvpn/manage.c +38 -1
index 1d97c2b6..8dada6f2 100644
@@ -75,6 +75,7 @@ man_help(void)
     msg(M_CLIENT, "auth-retry t           : Auth failure retry mode (none,interact,nointeract).");
     msg(M_CLIENT, "bytecount n            : Show bytes in/out, update every n secs (0=off).");
     msg(M_CLIENT, "echo [on|off] [N|all]  : Like log, but only show messages in echo buffer.");
+    msg(M_CLIENT, "cr-response response   : Send a challenge response answer via CR_RESPONSE to server");
     msg(M_CLIENT, "exit|quit              : Close management session.");
     msg(M_CLIENT, "forget-passwords       : Forget passwords entered so far.");
     msg(M_CLIENT, "help                   : Print this message.");
@@ -779,6 +780,27 @@ man_net(struct management *man)
     }
 }
 
+static void
+man_send_cc_message(struct management *man, const char *message, const char *parameters)
+{
+    if (man->persist.callback.send_cc_message)
+        {
+            const bool status = (*man->persist.callback.send_cc_message)
+                (man->persist.callback.arg, message, parameters);
+            if (status)
+            {
+                msg(M_CLIENT, "SUCCESS: command succeeded");
+            }
+            else
+            {
+                msg(M_CLIENT, "ERROR: command failed");
+            }
+        }
+    else
+    {
+        msg(M_CLIENT, "ERROR: This command is not supported by the current daemon mode");
+    }
+}
 #ifdef ENABLE_PKCS11
 
 static void
@@ -1144,7 +1166,15 @@ man_load_stats(struct management *man)
 }
 
 #define MN_AT_LEAST (1<<0)
-
+/**
+ * Checks if the correct number of arguments to a management command are present
+ * and otherwise prints an error and returns false.
+ *
+ * @param p         pointer to the parameter array
+ * @param n         number of arguments required
+ * @param flags     if MN_AT_LEAST require at least n parameters and not exactly n
+ * @return          Return wether p has n (or at least n) parameters
+ */
 static bool
 man_need(struct management *man, const char **p, const int n, unsigned int flags)
 {
@@ -1460,6 +1490,13 @@ man_dispatch_command(struct management *man, struct status_output *so, const cha
             man_query_need_str(man, p[1], p[2]);
         }
     }
+    else if (streq(p[0], "cr-response"))
+    {
+        if (man_need (man, p, 1, 0))
+        {
+             man_send_cc_message (man, "CR_RESPONSE", p[1]);
+        }
+    }
     else if (streq(p[0], "net"))
     {
         man_net(man);
src/openvpn/manage.h +1 -0
index d24abe09..8acc18bf 100644
@@ -164,6 +164,7 @@ struct management_callback
     int (*kill_by_addr) (void *arg, const in_addr_t addr, const int port);
     void (*delete_event) (void *arg, event_t event);
     int (*n_clients) (void *arg);
+    bool (*send_cc_message) (void *arg, const char *message, const char *parameter);
 #ifdef MANAGEMENT_DEF_AUTH
     bool (*kill_by_cid)(void *arg, const unsigned long cid, const char *kill_msg);
     bool (*client_auth) (void *arg,
Signature · 1 line
2.22.0
#7 lore raw

PATCH v2 4/5 Implement sending SSO challenge to clients

In reply to Arne Schwabe

This implements sending AUTH_PENDING and INFO_PRE messages to clients that indicate that the clients should be continue authentication with a second factor. This can currently be out of band (openurl) or a normal challenge/response 2FA like TOTP (CR_TEXT).

---
 doc/management-notes.txt | 26 +++++++++++++++++++++++
 src/openvpn/manage.c     | 46 ++++++++++++++++++++++++++++++++++++++++
 src/openvpn/manage.h     |  3 +++
 src/openvpn/multi.c      | 19 +++++++++++++++++
 src/openvpn/push.c       | 24 +++++++++++++++++++++
 src/openvpn/push.h       |  2 ++
 6 files changed, 120 insertions(+)
doc/management-notes.txt +26 -0
index e380ca2b..4b405a9b 100644
@@ -592,6 +592,32 @@ interface to approve client connections.
 CID,KID -- client ID and Key ID.  See documentation for ">CLIENT:"
 notification for more info.
 
+COMMAND -- client-sso-auth  (OpenVPN 2.5 or higher)
+----------------------------------------------------
+
+Instruct OpenVPN server to send AUTH_PENDING and INFO_PRE signal
+a single sign on url to the client.
+
+    client-sso-auth {CID} {EXTRA}
+
+The server will send AUTH_PENDING and INFO_PRE,{EXTRA} to the client.
+The client is expected to inform the user that authentication is pending and
+display the extra information. For the SSO/SAML EXTRA would be OPEN_URL:url
+and client should ask to the user to open the URL to continue.
+
+For the OpenVPN server this is stateless operation and needs to be
+followed by a client-deny/client-auth[-nt] command (that is the result of the
+out of band authentication).
+
+Before issuing a client-sso-auth to a client instead of a
+client-auth/client-deny, the server should check the IV_SSO
+environment variable if the method is support. The currently
+defined method are crtext for challenge/response using text
+(e.g. TOTP) and openurl for opening an URL in the client to
+continue authentication. A client support both methods would set
+
+   setenv IV_SSO openurl,crtext
+
 COMMAND -- client-deny  (OpenVPN 2.1 or higher)
 -----------------------------------------------
 
src/openvpn/manage.c +46 -0

64 lines not on this page · raw message

src/openvpn/manage.h +3 -0
index 8acc18bf..f570afc6 100644
@@ -174,6 +174,9 @@ struct management_callback
                          const char *reason,
                          const char *client_reason,
                          struct buffer_list *cc_config); /* ownership transferred */
+    bool (*client_sso) (void *arg,
+                        const unsigned long cid,
+                        const char *url);
     char *(*get_peer_info) (void *arg, const unsigned long cid);
 #endif
 #ifdef MANAGEMENT_PF
src/openvpn/multi.c +19 -0
index d594dd25..692fb62a 100644
@@ -3288,6 +3288,24 @@ management_kill_by_cid(void *arg, const unsigned long cid, const char *kill_msg)
     }
 }
 
+static bool
+management_client_sso(void *arg,
+        const unsigned long cid,
+        const char *extra)
+{
+    struct multi_context *m = (struct multi_context *) arg;
+    struct multi_instance *mi = lookup_by_cid(m, cid);
+    if (mi)
+    {
+        /* sends INFO_PRE and AUTH_PENDING messages to client */
+        bool ret = send_sso_messages(&mi->context, extra);
+        multi_schedule_context_wakeup(m, mi);
+        return ret;
+    }
+    return false;
+}
+
+
 static bool
 management_client_auth(void *arg,
                        const unsigned long cid,
@@ -3395,6 +3413,7 @@ init_management_callback_multi(struct multi_context *m)
 #ifdef MANAGEMENT_DEF_AUTH
         cb.kill_by_cid = management_kill_by_cid;
         cb.client_auth = management_client_auth;
+        cb.client_sso = management_client_sso;
         cb.get_peer_info = management_get_peer_info;
 #endif
 #ifdef MANAGEMENT_PF
src/openvpn/push.c +24 -0
index ee1cb980..4b375ae3 100644
@@ -268,6 +268,30 @@ send_auth_failed(struct context *c, const char *client_reason)
     gc_free(&gc);
 }
 
+bool
+send_sso_messages(struct context *c, const char* extra)
+{
+    send_control_channel_string(c, "AUTH_PENDING", D_PUSH);
+
+    static const char info_pre[] = "INFO_PRE,";
+
+
+    size_t len = strlen(extra)+1 + sizeof(info_pre);
+    if (len > PUSH_BUNDLE_SIZE)
+    {
+        return false;
+    }
+    struct gc_arena gc = gc_new();
+
+    struct buffer buf = alloc_buf_gc(len, &gc);
+    buf_printf(&buf, info_pre);
+    buf_printf(&buf, "%s", extra);
+    send_control_channel_string(c, BSTR(&buf), D_PUSH);
+
+    gc_free(&gc);
+    return true;
+}
+
 /*
  * Send restart message from server to client.
  */
src/openvpn/push.h +2 -0
index 9cf8fb34..f814f572 100644
@@ -70,6 +70,8 @@ void remove_iroutes_from_push_route_list(struct options *o);
 
 void send_auth_failed(struct context *c, const char *client_reason);
 
+bool send_sso_messages(struct context *c, const char *url);
+
 void send_restart(struct context *c, const char *kill_msg);
 
 /**
Signature · 1 line
2.22.0
#13 lore raw

PATCH v2 5/5 Implement forwarding client CR_RESPONSE messages to management

In reply to Arne Schwabe

When signalling the client that it should do Challenge response without reconnecting (IV_SSO=crtext/INFOPRE=CR_TEXT), the server needs forward the response via the management console.

---
 doc/management-notes.txt | 26 +++++++++++++++++++++++++-
 src/openvpn/forward.c    |  4 ++++
 src/openvpn/manage.c     | 28 +++++++++++++++++++++++++++-
 src/openvpn/manage.h     |  4 ++++
 src/openvpn/push.c       | 21 +++++++++++++++++++++
 src/openvpn/push.h       |  2 ++
 6 files changed, 83 insertions(+), 2 deletions(-)
doc/management-notes.txt +25 -1
index 4b405a9b..6d29b0d6 100644
@@ -971,7 +971,7 @@ The ">CLIENT:" notification is enabled by the --management-client-auth
 OpenVPN configuration directive that gives the management interface client
 the responsibility to authenticate OpenVPN clients after their client
 certificate has been verified.  CLIENT notifications may be multi-line, and
-the sequentiality of a given CLIENT notification, its associated environmental
+the sequentially of a given CLIENT notification, its associated environmental
 variables, and the terminating ">CLIENT:ENV,END" line are guaranteed to be
 atomic.
 
@@ -1013,6 +1013,30 @@ CLIENT notification types:
 
     >CLIENT:ADDRESS,{CID},{ADDR},{PRI}
 
+(5) Single Sign On Based Challenge/Response
+
+   >CLIENT:CR_RESPONSE,{CID},{KID},{response_base64}
+   >CLIENT:ENV,name1=val1
+   >CLIENT:ENV,name2=val2
+   >CLIENT:ENV,...
+   >CLIENT:ENV,END
+
+   CR_RESPONSE notification. The >CR_RESPONSE fulfils the same purpose as the
+   CRV1 response in the traditional challenge/response. See that section below for more
+   details. Since this still uses the same cid as the original response, we do
+   not use the username and opaque session data in this response.
+
+   It is important to note that OpenVPN2 merely passes the authentication information and
+   does not do any further checks. (E.g. if a CR was issued before or if multiple CR responses
+   were sent from the client).
+
+   This interface should be be sufficient for almost all challenge/response system that
+   can be implemented with a single round and base64 encoding the response. Mechanisms that
+   need multiple rounds or more complex answers should implement a different response type
+   than CR_RESPONSE.
+
+
+
 Variables:
 
 CID --  Client ID, numerical ID for each connecting client, sequence = 0,1,2,...
src/openvpn/forward.c +4 -0
index 0f735384..48c316c9 100644
@@ -403,6 +403,10 @@ check_incoming_control_channel_dowork(struct context *c)
             {
                 server_pushed_info(c, &buf, 4);
             }
+            else if (buf_string_match_head_str(&buf, "CR_RESPONSE"))
+            {
+                receive_cr_response(c, &buf);
+            }
             else
             {
                 msg(D_PUSH_ERRORS, "WARNING: Received unknown control message: %s", BSTR(&buf));
src/openvpn/manage.c +27 -1
index c055f2ce..b3a4d5c8 100644
@@ -2908,7 +2908,7 @@ management_notify_generic(struct management *man, const char *str)
 #ifdef MANAGEMENT_DEF_AUTH
 
 static void
-man_output_peer_info_env(struct management *man, struct man_def_auth_context *mdac)
+man_output_peer_info_env(struct management *man, const struct man_def_auth_context *mdac)
 {
     char line[256];
     if (man->persist.callback.get_peer_info)
@@ -2958,6 +2958,32 @@ management_notify_client_needing_auth(struct management *management,
     }
 }
 
+void
+management_notify_client_cr_response(unsigned mda_key_id,
+        const struct man_def_auth_context *mdac,
+        const struct env_set *es,
+        const char* response)
+{
+    struct gc_arena gc;
+    if (management)
+    {
+        gc = gc_new();
+
+        struct buffer out = alloc_buf_gc(256, &gc);
+        msg(M_CLIENT, ">CLIENT:CR_RESPONSE,%lu,%u,%s",
+                mdac->cid, mda_key_id, response);
+        man_output_extra_env(management, "CLIENT");
+        if (management->connection.env_filter_level>0)
+        {
+            man_output_peer_info_env(management, mdac);
+        }
+        man_output_env(es, true, management->connection.env_filter_level, "CLIENT");
+        management_notify_generic(management, BSTR(&out));
+
+        gc_free(&gc);
+    }
+}
+
 void
 management_connection_established(struct management *management,
                                   struct man_def_auth_context *mdac,
src/openvpn/manage.h +4 -0
index f570afc6..ff6b6737 100644
@@ -432,6 +432,10 @@ void management_learn_addr(struct management *management,
                            const struct mroute_addr *addr,
                            const bool primary);
 
+void management_notify_client_cr_response(unsigned mda_key_id,
+                                          const struct man_def_auth_context *mdac,
+                                          const struct env_set *es,
+                                          const char* response);
 #endif
 
 char *management_query_pk_sig(struct management *man, const char *b64_data);
src/openvpn/push.c +21 -0
index 4b375ae3..c94076cb 100644
@@ -210,6 +210,27 @@ server_pushed_info(struct context *c, const struct buffer *buffer,
     msg(D_PUSH, "Info command was pushed by server ('%s')", m);
 }
 
+void
+receive_cr_response(struct context *c, const struct buffer *buffer)
+{
+    struct buffer buf = *buffer;
+    const char *m = "";
+
+    if (buf_advance(&buf, 11) && buf_read_u8(&buf) == ',' && BLEN(&buf))
+    {
+        m = BSTR(&buf);
+    }
+#ifdef MANAGEMENT_DEF_AUTH
+    struct tls_session *session = &c->c2.tls_multi->session[TM_ACTIVE];
+    struct man_def_auth_context *mda = session->opt->mda_context;
+    struct env_set *es = session->opt->es;
+    int key_id = session->key[KS_PRIMARY].key_id;
+
+
+    management_notify_client_cr_response(key_id, mda, es, m);
+#endif
+    msg(D_PUSH, "CR response was sent by client ('%s')", m);
+}
 
 #if P2MP_SERVER
 /**
src/openvpn/push.h +2 -0
index f814f572..75ad330c 100644
@@ -53,6 +53,8 @@ void server_pushed_signal(struct context *c, const struct buffer *buffer, const
 void server_pushed_info(struct context *c, const struct buffer *buffer,
                         const int adv);
 
+void receive_cr_response(struct context *c, const struct buffer *buffer);
+
 void incoming_push_message(struct context *c, const struct buffer *buffer);
 
 #if P2MP_SERVER
Signature · 1 line
2.22.0
Acked-by on v2 1/5
#17 lore raw
In reply to Arne Schwabe
Quoted 56 lines · Arne Schwabe

OpenVPN 3 implements these messages to send information during the authentication to the UI, implement these message also in OpenVPN 2.x

---
 src/openvpn/forward.c |  8 ++++++++
 src/openvpn/push.c    | 33 +++++++++++++++++++++++++++++++++
 src/openvpn/push.h    |  3 +++
 3 files changed, 44 insertions(+)
src/openvpn/forward.c +8 -0
index 8451706b..0f735384 100644
@@ -395,6 +395,14 @@ check_incoming_control_channel_dowork(struct context *c)
             {
                 server_pushed_signal(c, &buf, false, 4);
             }
+            else if (buf_string_match_head_str(&buf, "INFO_PRE"))
+            {
+                server_pushed_info(c, &buf, 8);
+            }
+            else if (buf_string_match_head_str(&buf, "INFO"))
+            {
+                server_pushed_info(c, &buf, 4);
+            }
             else
             {
                 msg(D_PUSH_ERRORS, "WARNING: Received unknown control message: %s", BSTR(&buf));
src/openvpn/push.c +19 -0
index 368b6920..ee1cb980 100644
@@ -178,6 +178,39 @@ server_pushed_signal(struct context *c, const struct buffer *buffer, const bool
     }
 }
 
+void
+server_pushed_info(struct context *c, const struct buffer *buffer,
+                   const int adv)
+{
+    const char *m = "";
+    struct buffer buf = *buffer;
+
+    if (buf_advance(&buf, adv) && buf_read_u8(&buf) == ',' && BLEN(&buf))
+    {
+        m = BSTR(&buf);
+    }
+
+#ifdef ENABLE_MANAGEMENT
+    struct gc_arena gc;
+    if (management)
+    {
+        gc = gc_new();
+
+        /*

src/openvpn/push.c server_pushed_signal(struct context *c, const struct buffer *buffer, const bool · line 209

Quoted 10 lines
src/openvpn/push.c +10 -0
+         * We use >INFOMSG here instead of plain >INFO since INFO is used to
+         * for management greeting and we don't want to confuse the client
+         */
+        struct buffer out = alloc_buf_gc(256, &gc);
+        buf_printf(&out, ">%s:%s", "INFOMSG", m);
+        management_notify_generic(management, BSTR(&out));
+
+        gc_free(&gc);
+    }
+    #endif

The indent of this #endif is wrong. Wouldn't harm with an "/* ENABLE_MANAGEMENT */" comment as well. This could be fixed at merge time.

Otherwise, this looks good.

Signature · 4 lines
kind regards,

David Sommerseth
OpenVPN Inc
#5 lore raw

Re: [Openvpn-devel] [PATCH v2 3/5] Implement sending response to challenge via CR_RESPONSE

In reply to Arne Schwabe
Quoted 2 lines · Arne Schwabe

When a client announces its support to support text based challenge/response via IV_SOO=cr_text,the client needs to also

Typo. IV_SOO -> IV_SSO

Quoted 4 lines

be able to reply to that response.

This adds the "cr-response" management function to be able to do this. The answer should be base64 encoded.

Could we have some kind of test/sample script demonstrating this feature? It would also help test that this feature works and also useful for regression testing later on.

Signature · 4 lines
kind regards,

David Sommerseth
OpenVPN Inc
#8 lore raw

Re: [Openvpn-devel] [PATCH v2 4/5] Implement sending SSO challenge to clients

In reply to Arne Schwabe
Quoted 6 lines · Arne Schwabe

This implements sending AUTH_PENDING and INFO_PRE messages to clients that indicate that the clients should be continue authentication with a second factor. This can currently be out of band (openurl) or a normal challenge/response 2FA like TOTP (CR_TEXT).

Quoted 8 lines
---
 doc/management-notes.txt | 26 +++++++++++++++++++++++
 src/openvpn/manage.c     | 46 ++++++++++++++++++++++++++++++++++++++++
 src/openvpn/manage.h     |  3 +++
 src/openvpn/multi.c      | 19 +++++++++++++++++
 src/openvpn/push.c       | 24 +++++++++++++++++++++
 src/openvpn/push.h       |  2 ++
 6 files changed, 120 insertions(+)

Code and management notes looks reasonable. But again, it would be good to have a way to test this properly to avoid regressions later on. Since this is also a more advanced authentication method, having good test methods is even more critical.

Signature · 4 lines
kind regards,

David Sommerseth
OpenVPN Inc
#3 lore raw

Re: [Openvpn-devel] [PATCH v2 2/5] Implement support for signalling IV_SSO to server

In reply to a message not in the archive

Sorry, I'm loosing grip of my mailing-list-fu ... Managed to reply only to Arne.

Quoted 25 lines · David Sommerseth
Quoted 11 lines · Arne Schwabe
---
 src/openvpn/ssl.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
src/openvpn/ssl.c +0 -0
index 4455ebb8..cbb87e43 100644

src/openvpn/ssl.c push_peer_info(struct buffer *buf, struct tls_session *session) · line 2363

Quoted 10 lines
src/openvpn/ssl.c +3 -1
@@ -2355,7 +2355,9 @@ push_peer_info(struct buffer *buf, struct tls_session *session)
                 if ((((strncmp(e->string, "UV_", 3)==0
                        || strncmp(e->string, "IV_PLAT_VER=", sizeof("IV_PLAT_VER=")-1)==0)
                       && session->opt->push_peer_info_detail >= 2)
-                     || (strncmp(e->string,"IV_GUI_VER=",sizeof("IV_GUI_VER=")-1)==0))
+                     || (strncmp(e->string,"IV_GUI_VER=",sizeof("IV_GUI_VER=")-1)==0)
+                     || (strncmp(e->string,"IV_SSO=",sizeof("IV_SSO=")-1)==0)
+                     )
                     && buf_safe(&out, strlen(e->string)+1))
                 {
                     buf_printf(&out, "%s\n", e->string);

Code looks good, smoke tested on RHEL-7 against a test server without any issues.

Quoted 9 lines

Test 1: openvpn --config test.conf --push-peer-info No IV_SSO entry found in server log.

Test 2: openvpn --config test.conf --push-peer-info --setenv IV_SSO 1 IV_SSO=1 was found in server log

Test 3: openvpn --config test.conf --push-peer-info setenv IV_SSX 1 No IV_SSO nor IV_SSX found in server log

Signature · 4 lines
kind regards,

David Sommerseth
OpenVPN Inc
#9 lore raw

Re: [Openvpn-devel] [PATCH v2 4/5] Implement sending SSO challenge to clients

In reply to David Sommerseth

Am 27.03.20 um 22:09 schrieb David Sommerseth:

Quoted 16 lines · Arne Schwabe
Quoted 6 lines

This implements sending AUTH_PENDING and INFO_PRE messages to clients that indicate that the clients should be continue authentication with a second factor. This can currently be out of band (openurl) or a normal challenge/response 2FA like TOTP (CR_TEXT).

Quoted 8 lines
---
 doc/management-notes.txt | 26 +++++++++++++++++++++++
 src/openvpn/manage.c     | 46 ++++++++++++++++++++++++++++++++++++++++
 src/openvpn/manage.h     |  3 +++
 src/openvpn/multi.c      | 19 +++++++++++++++++
 src/openvpn/push.c       | 24 +++++++++++++++++++++
 src/openvpn/push.h       |  2 ++
 6 files changed, 120 insertions(+)
Quoted 4 lines

Code and management notes looks reasonable. But again, it would be good to have a way to test this properly to avoid regressions later on. Since this is also a more advanced authentication method, having good test methods is even more critical.

Writing a complete framework to test management interface on the server side is something that would a huge undertaking for this simple patch.

I think Access Server is basically the only software that I am aware of that really uses the server side management interface.

So basically having this requirement right now of writing a testing suite to get this into OpenVPN will mean that we will effectively fork OpenVPN for AS.

Arne

#6 lore raw

Re: [Openvpn-devel] [PATCH v2 3/5] Implement sending response to challenge via CR_RESPONSE

In reply to Arne Schwabe

Hi,

So I'm giving this one another look again. I started now by trying to use this feature manually, to see that each step works as expected. But this time I also discovered a few other details.

Quoted 2 lines · Arne Schwabe

When a client announces its support to support text based challenge/response via IV_SOO=cr_text,the client needs to also

Just reminding of the IV_SOO -> IV_SSO typo-fix ... and it should also be 'crtext', not 'cr_text'. The former is what is used in the management notes.

The more I dive into this, I'm also not sure IV_SSO is the proper term. As it is actually defines additional authentication mechanisms, where SSO (Single Sign-on) is just one potential user of this feature. What about just using IV_AUTH? (knowing this will change the prior patches)

[...snip...]

Quoted 6 lines
doc/management-notes.txt +0 -0
index 17645c1d..e380ca2b 100644
@@ -806,6 +806,14 @@ To accept connecting to the host and port directly, use this command:
 

doc/management-notes.txt To accept connecting to the host and port directly, use this command: · line 816

Quoted 10 lines
doc/management-notes.txt +8 -0
   proxy NONE
 
+COMMAND -- cr-response (OpenVPN 2.5 or higher)
+-------------------------------------------------
+Provides support for sending responses a challenge/response
+query via INFOMSG,CR_TEXT. The response should be base64 encoded:
+
+  cr-response SGFsbG8gV2VsdCE=
+
+

Could we please have more documentation how to use to enable and use this feature properly? Similar to the examples later down for both the static and dynamic challenge protocols. This does not need to happen in this patch though, as this is also tightly connected to the next patches.

doc/management-notes.txt To accept connecting to the host and port directly, use this command: · line 818

Quoted 2 lines
doc/management-notes.txt +2 -0
+static bool
+management_callback_send_cc_mesage(void *arg,

I didn't spot this earlier, but there's a typo in the function name; it is 'message' with two 's'.

doc/management-notes.txt init_management_callback_p2p(struct context *c) · line 4031

Quoted 7 lines
doc/management-notes.txt +1 -0
 static bool
 management_callback_remote_cmd(void *arg, const char **p)
@@ -3990,6 +4028,7 @@ init_management_callback_p2p(struct context *c)
         cb.show_net = management_show_net_callback;
         cb.proxy_cmd = management_callback_proxy_cmd;
         cb.remote_cmd = management_callback_remote_cmd;
+        cb.send_cc_message = management_callback_send_cc_mesage;

Same typo here in the callback function name; which is why it compiles ;-)

Signature · 4 lines
kind regards,

David Sommerseth
OpenVPN Inc
#10 lore raw

Re: [Openvpn-devel] [PATCH v2 4/5] Implement sending SSO challenge to clients

In reply to Arne Schwabe
Quoted 4 lines · Arne Schwabe

This implements sending AUTH_PENDING and INFO_PRE messages to clients that indicate that the clients should be continue authentication with a second factor. This can currently be out of band (openurl) or a normal challenge/response 2FA like TOTP (CR_TEXT).

Can we settle on a single CR_TEXT vs CRTEXT terminology? The 3/5 patch used crtext in the documentation but cr_text in the commit message.

Quoted 15 lines
---
 doc/management-notes.txt | 26 +++++++++++++++++++++++
 src/openvpn/manage.c     | 46 ++++++++++++++++++++++++++++++++++++++++
 src/openvpn/manage.h     |  3 +++
 src/openvpn/multi.c      | 19 +++++++++++++++++
 src/openvpn/push.c       | 24 +++++++++++++++++++++
 src/openvpn/push.h       |  2 ++
 6 files changed, 120 insertions(+)
doc/management-notes.txt +0 -0
index e380ca2b..4b405a9b 100644

doc/management-notes.txt interface to approve client connections. · line 601

Quoted 10 lines
doc/management-notes.txt +7 -0
@@ -592,6 +592,32 @@ interface to approve client connections.
 CID,KID -- client ID and Key ID.  See documentation for ">CLIENT:"
 notification for more info.
 
+COMMAND -- client-sso-auth  (OpenVPN 2.5 or higher)
+----------------------------------------------------
+
+Instruct OpenVPN server to send AUTH_PENDING and INFO_PRE signal
+a single sign on url to the client.
+
+    client-sso-auth {CID} {EXTRA}

I think we should use a different naming for this than 'sso'. This is not tied to only SSO (Single Sign-On). What about:

- client-extended-auth
- client-external-auth
- client-ext-auth
- client-additional-auth
- client-xauth

As long as the name is quite generic, I'm fine with most alternatives. But it should be very generic. We have so many alternative auth methods these days:
Yubico OTP [1], TOTP/HOTP, FIDO/U2F, SAML, OAuth, Kerberos/GSSAPI, etc ...

[1] <https://developers.yubico.com/OTP/OTPs_Explained.html>

Quoted 182 lines
doc/management-notes.txt +18 -0
+The server will send AUTH_PENDING and INFO_PRE,{EXTRA} to the client.
+The client is expected to inform the user that authentication is pending and
+display the extra information. For the SSO/SAML EXTRA would be OPEN_URL:url
+and client should ask to the user to open the URL to continue.
+
+For the OpenVPN server this is stateless operation and needs to be
+followed by a client-deny/client-auth[-nt] command (that is the result of the
+out of band authentication).
+
+Before issuing a client-sso-auth to a client instead of a
+client-auth/client-deny, the server should check the IV_SSO
+environment variable if the method is support. The currently
+defined method are crtext for challenge/response using text
+(e.g. TOTP) and openurl for opening an URL in the client to
+continue authentication. A client support both methods would set
+
+   setenv IV_SSO openurl,crtext
+
 COMMAND -- client-deny  (OpenVPN 2.1 or higher)
 -----------------------------------------------
 
src/openvpn/manage.c +46 -0
index 8dada6f2..c055f2ce 100644
@@ -105,6 +105,8 @@ man_help(void)
     msg(M_CLIENT, "client-auth-nt CID KID : Authenticate client-id/key-id CID/KID");
     msg(M_CLIENT, "client-deny CID KID R [CR] : Deny auth client-id/key-id CID/KID with log reason");
     msg(M_CLIENT, "                             text R and optional client reason text CR");
+    msg(M_CLIENT, "client-sso-auth CID MSG : Instruct OpenVPN to send AUTH_PENDING and INFO_PRE msg"
+                  "                          to the client and wait for a final client-auth/client-deny");
     msg(M_CLIENT, "client-kill CID [M]    : Kill client instance CID with message M (def=RESTART)");
     msg(M_CLIENT, "env-filter [level]     : Set env-var filter level");
 #ifdef MANAGEMENT_PF
@@ -1001,6 +1003,43 @@ parse_kid(const char *str, unsigned int *kid)
     }
 }
 
+/**
+ * Will send a notification to the client that succesful authentication
+ * will require an additional step (web based SSO/2-factor auth/etc)
+ *
+ * @param man           The management interface struct
+ * @param cid_str       The CID in string form
+ * @param extra         The string to be send to the client containing
+ *                      the information of the additional steps
+ */
+static void
+man_client_sso_auth(struct management *man, const char *cid_str, const char *extra)
+{
+    unsigned long cid = 0;
+    if (parse_cid(cid_str, &cid))
+    {
+        if (man->persist.callback.client_sso)
+        {
+            bool ret = (*man->persist.callback.client_sso)
+                           (man->persist.callback.arg, cid, extra);
+
+            if (ret)
+            {
+                msg(M_CLIENT, "SUCCESS: client-sso-auth command succeeded");
+            }
+            else
+            {
+                msg(M_CLIENT, "SUCCESS: client-sso-auth command failed."
+                              " Extra paramter might be too long");
+            }
+        }
+        else
+        {
+            msg(M_CLIENT, "ERROR: The client-sso-auth command is not supported by the current daemon mode");
+        }
+    }
+}
+
 static void
 man_client_auth(struct management *man, const char *cid_str, const char *kid_str, const bool extra)
 {
@@ -1541,6 +1580,13 @@ man_dispatch_command(struct management *man, struct status_output *so, const cha
             man_client_auth(man, p[1], p[2], true);
         }
     }
+    else if (streq(p[0], "client-sso-auth"))
+    {
+        if (man_need(man, p, 2, 0))
+        {
+            man_client_sso_auth(man, p[1], p[2]);
+        }
+    }
 #ifdef MANAGEMENT_PF
     else if (streq(p[0], "client-pf"))
     {
src/openvpn/manage.h +3 -0
index 8acc18bf..f570afc6 100644
@@ -174,6 +174,9 @@ struct management_callback
                          const char *reason,
                          const char *client_reason,
                          struct buffer_list *cc_config); /* ownership transferred */
+    bool (*client_sso) (void *arg,
+                        const unsigned long cid,
+                        const char *url);
     char *(*get_peer_info) (void *arg, const unsigned long cid);
 #endif
 #ifdef MANAGEMENT_PF
src/openvpn/multi.c +18 -0
index d594dd25..692fb62a 100644
@@ -3288,6 +3288,24 @@ management_kill_by_cid(void *arg, const unsigned long cid, const char *kill_msg)
     }
 }
 
+static bool
+management_client_sso(void *arg,> +        const unsigned long cid,
+        const char *extra)
+{
+    struct multi_context *m = (struct multi_context *) arg;
+    struct multi_instance *mi = lookup_by_cid(m, cid);
+    if (mi)
+    {
+        /* sends INFO_PRE and AUTH_PENDING messages to client */
+        bool ret = send_sso_messages(&mi->context, extra);
+        multi_schedule_context_wakeup(m, mi);
+        return ret;
+    }
+    return false;
+}
+
+
 static bool
 management_client_auth(void *arg,
                        const unsigned long cid,
@@ -3395,6 +3413,7 @@ init_management_callback_multi(struct multi_context *m)
 #ifdef MANAGEMENT_DEF_AUTH
         cb.kill_by_cid = management_kill_by_cid;
         cb.client_auth = management_client_auth;
+        cb.client_sso = management_client_sso;
         cb.get_peer_info = management_get_peer_info;
 #endif
 #ifdef MANAGEMENT_PF
src/openvpn/push.c +24 -0
index ee1cb980..4b375ae3 100644
@@ -268,6 +268,30 @@ send_auth_failed(struct context *c, const char *client_reason)
     gc_free(&gc);
 }
 
+bool
+send_sso_messages(struct context *c, const char* extra)
+{
+    send_control_channel_string(c, "AUTH_PENDING", D_PUSH);
+
+    static const char info_pre[] = "INFO_PRE,";
+
+
+    size_t len = strlen(extra)+1 + sizeof(info_pre);
+    if (len > PUSH_BUNDLE_SIZE)
+    {
+        return false;
+    }
+    struct gc_arena gc = gc_new();
+
+    struct buffer buf = alloc_buf_gc(len, &gc);
+    buf_printf(&buf, info_pre);
+    buf_printf(&buf, "%s", extra);
+    send_control_channel_string(c, BSTR(&buf), D_PUSH);
+
+    gc_free(&gc);
+    return true;
+}
+
 /*
  * Send restart message from server to client.
  */
src/openvpn/push.h +0 -0
index 9cf8fb34..f814f572 100644

src/openvpn/push.h void remove_iroutes_from_push_route_list(struct options *o); · line 75

Quoted 6 lines
src/openvpn/push.h +2 -0
@@ -70,6 +70,8 @@ void remove_iroutes_from_push_route_list(struct options *o);
 
 void send_auth_failed(struct context *c, const char *client_reason);
 
+bool send_sso_messages(struct context *c, const char *url);
+
 void send_restart(struct context *c, const char *kill_msg);

Several of the function names also uses 'sso', which should be aligned to a non-sso specific function name.

Signature · 4 lines
kind regards,

David Sommerseth
OpenVPN Inc
#11 lore raw

Re: [Openvpn-devel] [PATCH v2 4/5] Implement sending SSO challenge to clients

Quoted 38 lines · David Sommerseth
Quoted 4 lines · Arne Schwabe

This implements sending AUTH_PENDING and INFO_PRE messages to clients that indicate that the clients should be continue authentication with a second factor. This can currently be out of band (openurl) or a normal challenge/response 2FA like TOTP (CR_TEXT).

Can we settle on a single CR_TEXT vs CRTEXT terminology? The 3/5 patch used crtext in the documentation but cr_text in the commit message.

Quoted 15 lines
---
 doc/management-notes.txt | 26 +++++++++++++++++++++++
 src/openvpn/manage.c     | 46 ++++++++++++++++++++++++++++++++++++++++
 src/openvpn/manage.h     |  3 +++
 src/openvpn/multi.c      | 19 +++++++++++++++++
 src/openvpn/push.c       | 24 +++++++++++++++++++++
 src/openvpn/push.h       |  2 ++
 6 files changed, 120 insertions(+)
doc/management-notes.txt +0 -0
index e380ca2b..4b405a9b 100644

doc/management-notes.txt interface to approve client connections. · line 601

Quoted 10 lines
doc/management-notes.txt +7 -0
@@ -592,6 +592,32 @@ interface to approve client connections.
 CID,KID -- client ID and Key ID.  See documentation for ">CLIENT:"
 notification for more info.
 
+COMMAND -- client-sso-auth  (OpenVPN 2.5 or higher)
+----------------------------------------------------
+
+Instruct OpenVPN server to send AUTH_PENDING and INFO_PRE signal
+a single sign on url to the client.
+
+    client-sso-auth {CID} {EXTRA}

I think we should use a different naming for this than 'sso'. This is not tied to only SSO (Single Sign-On). What about:

Quoted 5 lines

- client-extended-auth
- client-external-auth
- client-ext-auth
- client-additional-auth
- client-xauth

Another alternative popped up in my head, as CR/Challenge-Response is used a lot in this context .... client-cr-auth .... but all of them are just suggestions to avoid the 'sso' reference.

Quoted 6 lines

As long as the name is quite generic, I'm fine with most alternatives. But it should be very generic. We have so many alternative auth methods these days:
Yubico OTP [1], TOTP/HOTP, FIDO/U2F, SAML, OAuth, Kerberos/GSSAPI, etc ...

[1] <https://developers.yubico.com/OTP/OTPs_Explained.html>

Signature · 4 lines
kind regards,

David Sommerseth
OpenVPN Inc
#12 lore raw

Re: [Openvpn-devel] [PATCH v2 4/5] Implement sending SSO challenge to clients

Quoted 37 lines · David Sommerseth
Quoted 36 lines · David Sommerseth
Quoted 4 lines · Arne Schwabe

This implements sending AUTH_PENDING and INFO_PRE messages to clients that indicate that the clients should be continue authentication with a second factor. This can currently be out of band (openurl) or a normal challenge/response 2FA like TOTP (CR_TEXT).

Can we settle on a single CR_TEXT vs CRTEXT terminology? The 3/5 patch used crtext in the documentation but cr_text in the commit message.

Quoted 15 lines
---
  doc/management-notes.txt | 26 +++++++++++++++++++++++
  src/openvpn/manage.c     | 46 ++++++++++++++++++++++++++++++++++++++++
  src/openvpn/manage.h     |  3 +++
  src/openvpn/multi.c      | 19 +++++++++++++++++
  src/openvpn/push.c       | 24 +++++++++++++++++++++
  src/openvpn/push.h       |  2 ++
  6 files changed, 120 insertions(+)
doc/management-notes.txt +0 -0
index e380ca2b..4b405a9b 100644

doc/management-notes.txt interface to approve client connections. · line 601

Quoted 10 lines
doc/management-notes.txt +7 -0
@@ -592,6 +592,32 @@ interface to approve client connections.
  CID,KID -- client ID and Key ID.  See documentation for ">CLIENT:"
  notification for more info.
 
+COMMAND -- client-sso-auth  (OpenVPN 2.5 or higher)
+----------------------------------------------------
+
+Instruct OpenVPN server to send AUTH_PENDING and INFO_PRE signal
+a single sign on url to the client.
+
+    client-sso-auth {CID} {EXTRA}

I think we should use a different naming for this than 'sso'. This is not tied to only SSO (Single Sign-On). What about:

Quoted 14 lines
Quoted 5 lines

- client-extended-auth
- client-external-auth
- client-ext-auth
- client-additional-auth
- client-xauth

Another alternative popped up in my head, as CR/Challenge-Response is used a lot in this context .... client-cr-auth .... but all of them are just suggestions to avoid the 'sso' reference.

Quoted 5 lines

As long as the name is quite generic, I'm fine with most alternatives. But it should be very generic. We have so many alternative auth methods these days:
Yubico OTP [1], TOTP/HOTP, FIDO/U2F, SAML, OAuth, Kerberos/GSSAPI, etc ...

[1] <https://developers.yubico.com/OTP/OTPs_Explained.html>

+1 on avoiding the 'sso' reference  - this has nothing to do with SSO/SAML/OAuth/OpenID etc etc and I think it would be unwise to suggest that OpenVPN does something like "that" kind of SSO auth. Before we know it users will start asking how they can link their Hotmail, FB or Google account to their OpenVPN config....

JM2CW,

JJK

#14 lore raw

Re: [Openvpn-devel] [PATCH v2 5/5] Implement forwarding client CR_RESPONSE messages to management

In reply to Arne Schwabe
Quoted 28 lines · Arne Schwabe

When signalling the client that it should do Challenge response without reconnecting (IV_SSO=crtext/INFOPRE=CR_TEXT), the server needs forward the response via the management console.

---
 doc/management-notes.txt | 26 +++++++++++++++++++++++++-
 src/openvpn/forward.c    |  4 ++++
 src/openvpn/manage.c     | 28 +++++++++++++++++++++++++++-
 src/openvpn/manage.h     |  4 ++++
 src/openvpn/push.c       | 21 +++++++++++++++++++++
 src/openvpn/push.h       |  2 ++
 6 files changed, 83 insertions(+), 2 deletions(-)
doc/management-notes.txt +1 -1
index 4b405a9b..6d29b0d6 100644
@@ -971,7 +971,7 @@ The ">CLIENT:" notification is enabled by the --management-client-auth
 OpenVPN configuration directive that gives the management interface client
 the responsibility to authenticate OpenVPN clients after their client
 certificate has been verified.  CLIENT notifications may be multi-line, and
-the sequentiality of a given CLIENT notification, its associated environmental
+the sequentially of a given CLIENT notification, its associated environmental
 variables, and the terminating ">CLIENT:ENV,END" line are guaranteed to be
 atomic.
 

doc/management-notes.txt CLIENT notification types: · line 1016

Quoted 4 lines
doc/management-notes.txt +1 -0
@@ -1013,6 +1013,30 @@ CLIENT notification types:
 
     >CLIENT:ADDRESS,{CID},{ADDR},{PRI}
 
+(5) Single Sign On Based Challenge/Response

Perhaps something like "Management interface based Challenge/Response protocol"?

doc/management-notes.txt CLIENT notification types: · line 1027

Quoted 10 lines
doc/management-notes.txt +10 -0
+   >CLIENT:CR_RESPONSE,{CID},{KID},{response_base64}
+   >CLIENT:ENV,name1=val1
+   >CLIENT:ENV,name2=val2
+   >CLIENT:ENV,...
+   >CLIENT:ENV,END
+
+   CR_RESPONSE notification. The >CR_RESPONSE fulfils the same purpose as the
+   CRV1 response in the traditional challenge/response. See that section below for more
+   details. Since this still uses the same cid as the original response, we do
+   not use the username and opaque session data in this response.

It would be good to clarify that this response happens when the client uses 'cr-response' via the client management interface. And perhaps mention how it looks like on the control channel wire protocol as well. This can be seen in context of the "lacking documentation" comment in patch 3/5.

[...snip...]

Quoted 23 lines
doc/management-notes.txt +0 -0
 Variables:
 
 CID --  Client ID, numerical ID for each connecting client, sequence = 0,1,2,...
src/openvpn/forward.c +4 -0
index 0f735384..48c316c9 100644
@@ -403,6 +403,10 @@ check_incoming_control_channel_dowork(struct context *c)
             {
                 server_pushed_info(c, &buf, 4);
             }
+            else if (buf_string_match_head_str(&buf, "CR_RESPONSE"))
+            {
+                receive_cr_response(c, &buf);
+            }
             else
             {
                 msg(D_PUSH_ERRORS, "WARNING: Received unknown control message: %s", BSTR(&buf));
src/openvpn/manage.c +0 -0
index c055f2ce..b3a4d5c8 100644

src/openvpn/manage.c management_notify_generic(struct management *man, const char *str) · line 2911

Quoted 5 lines
src/openvpn/manage.c +1 -1
@@ -2908,7 +2908,7 @@ management_notify_generic(struct management *man, const char *str)
 #ifdef MANAGEMENT_DEF_AUTH
 
 static void
-man_output_peer_info_env(struct management *man, struct man_def_auth_context *mdac)
+man_output_peer_info_env(struct management *man, const struct man_def_auth_context *mdac)

Is this change strictly related to the CR_RESPONSE forwarding? If not, it should be separated into its own commit.

Quoted 59 lines
src/openvpn/manage.c +26 -0
 {
     char line[256];
     if (man->persist.callback.get_peer_info)
@@ -2958,6 +2958,32 @@ management_notify_client_needing_auth(struct management *management,
     }
 }
 
+void
+management_notify_client_cr_response(unsigned mda_key_id,
+        const struct man_def_auth_context *mdac,
+        const struct env_set *es,
+        const char* response)
+{
+    struct gc_arena gc;
+    if (management)
+    {
+        gc = gc_new();
+
+        struct buffer out = alloc_buf_gc(256, &gc);
+        msg(M_CLIENT, ">CLIENT:CR_RESPONSE,%lu,%u,%s",
+                mdac->cid, mda_key_id, response);
+        man_output_extra_env(management, "CLIENT");
+        if (management->connection.env_filter_level>0)
+        {
+            man_output_peer_info_env(management, mdac);
+        }
+        man_output_env(es, true, management->connection.env_filter_level, "CLIENT");
+        management_notify_generic(management, BSTR(&out));
+
+        gc_free(&gc);
+    }
+}
+
 void
 management_connection_established(struct management *management,
                                   struct man_def_auth_context *mdac,
src/openvpn/manage.h +4 -0
index f570afc6..ff6b6737 100644
@@ -432,6 +432,10 @@ void management_learn_addr(struct management *management,
                            const struct mroute_addr *addr,
                            const bool primary);
 
+void management_notify_client_cr_response(unsigned mda_key_id,
+                                          const struct man_def_auth_context *mdac,
+                                          const struct env_set *es,
+                                          const char* response);
 #endif
 
 char *management_query_pk_sig(struct management *man, const char *b64_data);
src/openvpn/push.c +0 -0
index 4b375ae3..c94076cb 100644
@@ -210,6 +210,27 @@ server_pushed_info(struct context *c, const struct buffer *buffer,
     msg(D_PUSH, "Info command was pushed by server ('%s')", m);
 }
 

src/openvpn/push.c server_pushed_info(struct context *c, const struct buffer *buffer, · line 222

Quoted 10 lines
src/openvpn/push.c +10 -0
+void
+receive_cr_response(struct context *c, const struct buffer *buffer)
+{
+    struct buffer buf = *buffer;
+    const char *m = "";
+
+    if (buf_advance(&buf, 11) && buf_read_u8(&buf) == ',' && BLEN(&buf))
+    {
+        m = BSTR(&buf);
+    }

This will accept an empty CR_RESPONSE from the client. Could that be an acceptable reply from the client? My initial thought is: When the server sends a challenge to the client, it should have a "meaningful" response. I struggle to see where an empty response would be meaningful.

And by "meaningful" I mean in the broadest interpretation. Invalid authentication response, invalid data (not base64 encoded, etc) is meaningful.

I'm also wondering if it would make sense to validate the base64 response as well.

To summarize all patches:

- They all look reasonable and fine, but there are a few things to improve.

- We should avoid the SSO terminology in the implementation; it can be used for a much broader authentication scope than just SSO. Patch 2/5 also needs to be revisited, despite the ACK I've already given.

- Documentation could be a bit better.

- It would be nice to have a really simple test "module" for the server side, which would just give challenges like "How much is X + Y?" where X and Y are random numbers (1-10) and doesn't really need to account for multiple clients at the same time. But I do realize the management interface can be annoying to work with from simple scripting tools.

Signature · 4 lines
kind regards,

David Sommerseth
OpenVPN Inc
#15 lore raw

Re: [Openvpn-devel] [PATCH v2 5/5] Implement forwarding client CR_RESPONSE messages to management

Quoted 5 lines

This will accept an empty CR_RESPONSE from the client. Could that be an acceptable reply from the client? My initial thought is: When the server sends a challenge to the client, it should have a "meaningful" response. I struggle to see where an empty response would be meaningful.

Enter your second TOTP to gain additional privileges. User jsut presses enter and you then only get bare minimum VPN access.

Quoted 15 lines

And by "meaningful" I mean in the broadest interpretation. Invalid authentication response, invalid data (not base64 encoded, etc) is meaningful.

I'm also wondering if it would make sense to validate the base64 response as well.

To summarize all patches:

- They all look reasonable and fine, but there are a few things to improve.

- We should avoid the SSO terminology in the implementation; it can be used for a much broader authentication scope than just SSO. Patch 2/5 also needs to be revisited, despite the ACK I've already given.

Quoted 7 lines

- Documentation could be a bit better.

- It would be nice to have a really simple test "module" for the server side, which would just give challenges like "How much is X + Y?" where X and Y are random numbers (1-10) and doesn't really need to account for multiple clients at the same time. But I do realize the management interface can be annoying to work with from simple scripting tools.

I would rather give an example using connect/auth scripts and then a script hook that can be called on receiving the CR_RESPONSE message. But I want to wait until the deferred client connect patches are in before doing that as they might touch the same code.

Implement a small e.g. python based management interface might also be possible but it would be an example that does a lot more than just that because you a bit more to have a something working with the management interface

Arne

#16 lore raw

Re: [Openvpn-devel] SSO patchset / testing server side mgmt if

Hi,

Quoted 4 lines · Arne Schwabe

Implement a small e.g. python based management interface might also be possible but it would be an example that does a lot more than just that because you a bit more to have a something working with the management interface

It would be extremely cool to have something simple to drive the management interface on the "test server" side. There's so many code paths related to management that we currently do not test in an automated way, or hardly at all.

(Of course it would have to be perl, not python :-) - seriously: as long as it works and is readable, whoever implements something gets to choose, just don't expect me to maintain anything pythonish)

gert

Signature · 6 lines
"If was one thing all people took for granted, was conviction that if you 
 feed honest figures into a computer, honest figures come out. Never doubted 
 it myself till I met a computer with a sense of humor."
                             Robert A. Heinlein, The Moon is a Harsh Mistress

Gert Doering - Munich, Germany                             [email protected]...