Implement additional two step authentication methods
cover Implement additional two step authentication methods
These patches mainly implement forwarding passing/forwarding extra messages between management interface on server and client side.
These new extra messages can be used to implement a two step authentication like TOTP (Google Authenticator) or web based out of band (like SAML).
Since this requires a tight integration on both client and server side, it is currently only supported with the management interface.
Arne Schwabe (5):
Implement parsing and sending INFO and INFO_PRE control messages Implement forwarding client CR_RESPONSE messages to management Implement support for signalling IV_SSO to server Implement sending response to challenge via CR_RESPONSE Implement sending SSO challenge to clients
doc/management-notes.txt | 74 ++++++++++++++++++++++++++++ src/openvpn/forward.c | 12 +++++ src/openvpn/init.c | 25 ++++++++++ src/openvpn/manage.c | 101 ++++++++++++++++++++++++++++++++++++++- src/openvpn/manage.h | 8 ++++ src/openvpn/multi.c | 19 ++++++++ src/openvpn/push.c | 78 ++++++++++++++++++++++++++++++ src/openvpn/push.h | 7 +++ src/openvpn/ssl.c | 4 +- 9 files changed, 325 insertions(+), 3 deletions(-)
Signature · 1 line
2.22.0
PATCH 1/5 Implement parsing and sending INFO and INFO_PRE control messages
OpenVPN out of band and auth pending authentication implements these messages to send information during the authentication to the UI, implement these message also in OpenVPN 2.x to be able to be piked up by the UI
--- 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
@@ -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
@@ -176,6 +176,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
@@ -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
Re: [Openvpn-devel] [PATCH 1/5] Implement parsing and sending INFO and INFO_PRE control messages
Quoted 12 lines · Arne Schwabe
OpenVPN out of band and auth pending authentication implements these messages to send information during the authentication to the UI, implement these message also in OpenVPN 2.x to be able to be piked up by the UI
Signed-off-by Arne Schwabe <[email protected]...>--- src/openvpn/forward.c | 8 ++++++++ src/openvpn/push.c | 33 +++++++++++++++++++++++++++++++++ src/openvpn/push.h | 3 +++ 3 files changed, 44 insertions(+)
[...snip...]
Quoted 11 lines
src/openvpn/push.c +3
-0@@ -176,6 +176,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)
src/openvpn/push.c server_pushed_signal(struct context *c, const struct buffer *buffer, const bool · line 191
Quoted 10 lines
src/openvpn/push.c +10
-0+{ +const char *m ="" ; +struct buffer buf = *buffer; + +if (buf_advance (&buf, adv) &&buf_read_u8 (&buf) ==',' &&BLEN (&buf)) + { + m =BSTR (&buf); + } + +#ifdef ENABLE_MANAGEMENT
This looks good, but the indenting of the #ifdef above is wrong; it should be at the beginning of the line.
Signature · 4 lines
kind regards, David Sommerseth OpenVPN Inc
PATCH 2/5 Implement forwarding client CR_RESPONSE messages to management
In reply to Arne SchwabeWhen 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 | 19 +++++++++++++++++++ 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, 77 insertions(+), 1 deletion(-)
doc/management-notes.txt +19 -0
@@ -979,6 +979,24 @@ 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 notifcation. 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). + + Variables: CID -- Client ID, numerical ID for each connecting client, sequence = 0,1,2,...
@@ -1175,3 +1193,4 @@ issued: ("YmFy" is the base 64 encoding of "bar" and "ODY3NTMwOQ==" is the base 64 encoding of "8675309".) +
src/openvpn/forward.c +4 -0
@@ -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
@@ -2823,7 +2823,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)
@@ -2873,6 +2873,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
@@ -428,6 +428,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
@@ -208,6 +208,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
@@ -53,6 +53,8 @@ void server_pushed_signal(struct context *c, const struct buffer *buffer, constvoid 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
Re: [Openvpn-devel] [PATCH 2/5] Implement forwarding client CR_RESPONSE messages to management
Quoted 24 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.
Signed-off-by Arne Schwabe <[email protected]...>--- doc/management-notes.txt | 19 +++++++++++++++++++ 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, 77 insertions(+), 1 deletion(-)doc/management-notes.txt +2
-0@@ -979,6 +979,24 @@ CLIENT notification types: >CLIENT:ADDRESS,{CID},{ADDR},{PRI} +(5) Single Sign On Based Challenge/Response +
doc/management-notes.txt CLIENT notification types: · line 993
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 notifcation. 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.
The difference between CR_RESPONSE and CRV1, is that the CRV1 response is passed as part of the AUTH_FAILED in the server response and the client responds back using the password field. And this causes the client to need to reconnect to the server, as the AUTH_FAILED disconnects the client.
With this approach the server and client handles the challenge/response chatter over the control channel; I like this much more as it doesn't disconnect the client and server - so it will be much faster to handle the connection setup once the authentication is done.
I see one challenge with this approach, and it is that it locks us to one specific format for the CR_RESPONSE. I think it would be appropriate to extend it with a "version" field before {CID}, so we have a chance to extend the protocol without updating much of the core OpenVPN 2.x code base. For now, it could be hard coded as version 1.
So: CLIENT:CR_RESPONSE,{VERSION},{CID},{KID},{response_base64}
I'm also wondering if this would be a reasonable approach to use to implement GSSAPI authentication support as well; where there is a back-and-forth handshake happening as well.
Quoted 4 lines
src/openvpn/manage.c +0
-0
[...snip...]
Quoted 5 lines
src/openvpn/manage.c +5
-0+management_notify_client_cr_response(unsigned mda_key_id, + const struct man_def_auth_context *mdac, + const struct env_set *es, + const char* response) +{
src/openvpn/manage.c management_notify_client_needing_auth(struct management *management, · line 2891
Quoted 10 lines
src/openvpn/manage.c +10
-0+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 )
<code_style_police>
It should be spacing around '>'.
</code_style_police>
It would also be good if we could extend these new functions with doxygen comments on what these functions work. What information they parse, what they expect of data, from where the data comes and how they respond/produce results.
Other than that, it looks good.
Signature · 4 lines
kind regards, David Sommerseth OpenVPN Inc
Re: [Openvpn-devel] [PATCH 2/5] Implement forwarding client CR_RESPONSE messages to management
Quoted 9 lines
I see one challenge with this approach, and it is that it locks us to one specific format for the
CR_RESPONSE. I think it would be appropriate to extend it with a "version" field before {CID}, so we have a chance to extend the protocol without updating much of the core OpenVPN 2.x code base. For now, it could be hard coded as version 1.So: CLIENT:CR_RESPONSE,{VERSION},{CID},{KID},{response_base64}
But instead of the old method we are not limited to using a fixed field/control command. So while CRV1 must have a version field, CR_RESPONSE just does text responses and nothing more.
Quoted 3 lines
I'm also wondering if this would be a reasonable approach to use to implement GSSAPI authentication support as well; where there is a back-and-forth handshake happening as well.
For anything that needs more than can be encoded with a base64 text, I would rather add a new response type like GSAPPI_AUTH etc.
Arne
PATCH 3/5 Implement support for signalling IV_SSO to server
In reply to Arne Schwabe--- src/openvpn/ssl.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
src/openvpn/ssl.c +3 -1
@@ -2343,7 +2343,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
Re: [Openvpn-devel] [PATCH 3/5] Implement support for signalling IV_SSO to server
Quoted 11 lines · Arne Schwabe
Signed-off-by Arne Schwabe <[email protected]...>--- src/openvpn/ssl.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)src/openvpn/ssl.c +0
-0
src/openvpn/ssl.c push_peer_info(struct buffer *buf, struct tls_session *session) · line 2351
Quoted 10 lines
src/openvpn/ssl.c +3
-1@@ -2343,7 +2343,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);
These new lines breaks the coding style of spaces around '==' and after comma in the strncmp() arguments, but so does the existing code. This needs to be fixed, but lets handle that outside of this patch set.
Signature · 4 lines
kind regards, David Sommerseth OpenVPN Inc
PATCH 4/5 Implement sending response to challenge via CR_RESPONSE
In reply to Arne SchwabeWhen 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 | 25 +++++++++++++++++++++++++ src/openvpn/manage.c | 37 ++++++++++++++++++++++++++++++++++++- src/openvpn/manage.h | 1 + 4 files changed, 70 insertions(+), 1 deletion(-)
doc/management-notes.txt +8 -0
@@ -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 +25 -0
@@ -287,6 +287,30 @@ ce_management_query_proxy(struct context *c)return ret; } +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)
@@ -3920,6 +3944,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 +36 -1
@@ -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,13 @@ man_load_stats(struct management *man) }#define MN_AT_LEAST (1<<0) - +/** +* +* @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 +1488,13 @@ man_dispatch_command(struct management *man, struct status_output *so, const chaman_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
@@ -164,6 +164,7 @@ struct management_callbackint (*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
Re: [Openvpn-devel] [PATCH 4/5] Implement sending response to challenge via CR_RESPONSE
Quoted 20 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 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.
Signed-off-by Arne Schwabe <[email protected]...>--- doc/management-notes.txt | 8 ++++++++ src/openvpn/init.c | 25 +++++++++++++++++++++++++ src/openvpn/manage.c | 37 ++++++++++++++++++++++++++++++++++++- src/openvpn/manage.h | 1 + 4 files changed, 70 insertions(+), 1 deletion(-)doc/management-notes.txt +0
-0
doc/management-notes.txt To accept connecting to the host and port directly, use this command: · line 814
Quoted 9 lines
doc/management-notes.txt +6
-0@@ -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=
I'm pondering if this response should have a version identifier as well, which probably should match the version in the CR_RESPONSE message. I'm not entirely convinced it is needed yet, but just raising it for further discussion.
I'm leaning against adding it, because it is the "UI interface" using this cr-response call via the managment interface; which results in the client side sending the CR_RESPONSE back to the server - where the client code should add that in its own response.
As said, I'm not convinced yet ... just bringing it up for a quick discussion to see if we've missed a few corner cases or not.
[...snip...]
src/openvpn/init.c ce_management_query_proxy(struct context *c) · line 293
Quoted 12 lines
src/openvpn/init.c +4
-0@@ -287,6 +287,30 @@ ce_management_query_proxy(struct context *c)return ret; } +static bool +management_callback_send_cc_mesage (void *arg, +const char *command, +const char *parameters)
This function could use a doxygen documentation tag.
Quoted 4 lines
src/openvpn/manage.c +0
-0
[...snip...]
src/openvpn/manage.c man_net(struct management *man) · line 784
Quoted 2 lines
src/openvpn/manage.c +2
-0+static void +man_send_cc_message (struct management *man,const char * message,const char * parameters)
This function could also benefit from a doxygen documentation tag.
src/openvpn/manage.c man_net(struct management *man) · line 789
Quoted 5 lines
src/openvpn/manage.c +5
-0+{ +if (man->persist.callback.send_cc_message) + { +const bool status = (*man->persist.callback.send_cc_message) + (man->persist.callback.arg, message, parameters);
This code is hard to read, due to the arguments being passed to the callback function is after a line break. Could we use a temporary/scoped function pointer which is assigned to (*man->persist.callback.send_cc_message) and used instead?
[...snip...]
src/openvpn/manage.c man_net(struct management *man) · line 801
Quoted 3 lines
src/openvpn/manage.c +3
-0+else + { +msg (M_CLIENT ,"ERROR: This command is not supported by the current daemon mode" );
Why this "current daemon mode" reference? Can't we make it a bit clearer? Like "management interface does not support responding to this challenge/response protocol", or something like that?
Quoted 10 lines
+/**
+ *+ * @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)
There's something missing here ... like a description of the function.
Signature · 4 lines
kind regards, David Sommerseth OpenVPN Inc
PATCH 5/5 Implement sending SSO challenge to clients
In reply to Arne SchwabeThis 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).
Note that this also sends a AUTH_PENDING message that signal the client to change its behaviour and continue polling with PUSH request. In OpenVPN2 this is already default behaviour, so we can ignore this message in OpenVPN2.
--- doc/management-notes.txt | 47 ++++++++++++++++++++++++++++++++++++++++ src/openvpn/manage.c | 36 ++++++++++++++++++++++++++++++ src/openvpn/manage.h | 3 +++ src/openvpn/multi.c | 19 ++++++++++++++++ src/openvpn/push.c | 24 ++++++++++++++++++++ src/openvpn/push.h | 2 ++ 6 files changed, 131 insertions(+)
doc/management-notes.txt +47 -0
@@ -592,6 +592,53 @@ 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 openurl SSO method EXTRA has the form OPEN_URL:url +and an example is: + + client-sso-auth 17 "OPENURL:https://examples.com/do_web_auth" + +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). + +The other implemented method is challenge/response (crtext). This uses +the same format as the user and password bases challenge respsonse with +AUTH_FAILED but omits the session id and username. + + client-sso-auth 18 "CR_TEXT:<flags>:<challenge_text>" + +For exmaple: + + client-sso-auth 18 "CR_TEXT:R,E:Please enter token PIN" + +The client should present the user the challenge and follow up +with cr-response command. + +See the section >CLIENT,CR_RESPONSE for the client response. + +A client should announce its support for these methods with +the IV_SSO variable seperated by comma. E.g., in the configuration file + + setenv IV_SSO openurl,crtext + +A server should check wether these methods are supported by +examining IV_SSO and otherwise fall back to classic challenge +response protocol or sending a AUTH_FAILED message that points +out missing client support. + COMMAND -- client-deny (OpenVPN 2.1 or higher) -----------------------------------------------
src/openvpn/manage.c +36 -0
@@ -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
@@ -1000,6 +1002,33 @@ parse_kid(const char *str, unsigned int *kid)return false; } } +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-deny 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)
@@ -1539,6 +1568,13 @@ man_dispatch_command(struct management *man, struct status_output *so, const chaman_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
@@ -174,6 +174,9 @@ struct management_callbackconst 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
@@ -3253,6 +3253,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,
@@ -3360,6 +3378,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
@@ -287,6 +287,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
@@ -72,6 +72,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);#endif
Signature · 1 line
2.22.0
Hi
Quoted 12 lines · Arne Schwabe
These patches mainly implement forwarding passing/forwarding extra messages between management interface on server and client side.
These new extra messages can be used to implement a two step authentication like TOTP (Google Authenticator) or web based out of band (like SAML).
Since this requires a tight integration on both client and server side, it is currently only supported with the management interface.
Quoted 6 lines
Arne Schwabe (5):
Implement parsing and sending INFO andINFO_PREcontrol messages Implement forwarding clientCR_RESPONSEmessages to management Implement support for signallingIV_SSOto server Implement sending response to challenge viaCR_RESPONSEImplement sending SSO challenge to clients
I haven't looked at the patches, but a quick question. I haven't come across any 2FA mechanisms that cannot be handled (in principle) by the current static an dynamic CR in OpenVPN. Except that some dynamic CR (e.g, U2F) will require the possibility to transmit larger messages than currently possible -- especially
the 256 byte limitation in responses from the management as those are parsed by the config-parser. And possibly the TLS channel buffer size may need to be increased.
Once those limits are extended, do we need anything more?
You mention google-authenticator OTP but that can perfectly handled as a static challenge as many do right now.
The current dynamic response implementation is a bad hack -- fail the auth with challenge embedded in the reason text and then send the response as a "password" during the next round. So is this about making a cleaner implementation? Or am I missing something more subtle?
Selva
Hi,
Quoted 23 lines · Selva Nair
Hi
Quoted 12 lines · Arne Schwabe
These patches mainly implement forwarding passing/forwarding extra messages between management interface on server and client side.
These new extra messages can be used to implement a two step authentication like TOTP (Google Authenticator) or web based out of band (like SAML).
Since this requires a tight integration on both client and server side, it is currently only supported with the management interface.
Quoted 6 lines
Arne Schwabe (5):
Implement parsing and sending INFO andINFO_PREcontrol messages Implement forwarding clientCR_RESPONSEmessages to management Implement support for signallingIV_SSOto server Implement sending response to challenge viaCR_RESPONSEImplement sending SSO challenge to clients
Quoted 3 lines
I haven't looked at the patches, but a quick question. I haven't come across any 2FA mechanisms that cannot be handled (in principle) by the current static an dynamic CR in OpenVPN.
+1. What functionality does this new mechanism add?
Tunnelblick implements 2FA through the management interface using the existing static and dynamic challenge-response mechanism. For a dynamic challenge, for example. Tunnelblick gets a response from the user in a popup window or from a user-specified script. (A script is usually used to get the response from hardware devices.)
Best regards,
Jon Bullard
Quoted 10 lines
+1. What functionality does this new mechanism add?
Tunnelblick implements 2FA through the management interface using the existing static and dynamic challenge-response mechanism. For a dynamic challenge, for example. Tunnelblick gets a response from the user in a popup window or from a user-specified script. (A script is usually used to get the response from hardware devices.)
It adds 2FA without reconnect dance and also the ability to do something like web based SSO authentication. But a server should not use these unless your client will announce support for them via IV_SSO variable.
The v2 version of the patch will describe the IV_SSO variable too.
Arne
Quoted 12 lines
I haven't looked at the patches, but a quick question. I haven't come across any 2FA mechanisms that cannot be handled (in principle) by the current static an dynamic CR in OpenVPN. Except that some dynamic CR (e.g, U2F) will require the possibility to transmit larger messages than currently possible -- especially
the 256 byte limitation in responses from the management as those are parsed by the config-parser. And possibly the TLS channel buffer size may need to be increased.Once those limits are extended, do we need anything more?
Quoted 7 lines
You mention google-authenticator OTP but that can perfectly handled as a static challenge as many do right now.
The current dynamic response implementation is a bad hack -- fail the auth with challenge embedded in the reason text and then send the response as a "password" during the next round. So is this about making a cleaner implementation? Or am I missing something more subtle?
Two things basically that play to together making it cleaner and allow web based authentication to actually not a horrible hack. WEB based SSO would work as follows:
- Clients connects
- Server get the client auth request.
- Instead of sending success/failed right way, it will send a challenge
- OPENURL:example.com/logintomyvpn
- Client will continue to wait in this not yet authenticated state
- User will login into the web page, the backend of the web notifies the VPN server about the result
- VPN will send do client auth succces/failed depending on result
- Client is connected.
Arne