From patchwork Sat Nov 9 04:13:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arne Schwabe X-Patchwork-Id: 894 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director9.mail.ord1d.rsapps.net ([172.27.255.1]) by backend30.mail.ord1d.rsapps.net with LMTP id CKsuI8zXxl1kNQAAIUCqbw for ; Sat, 09 Nov 2019 10:14:20 -0500 Received: from proxy2.mail.iad3a.rsapps.net ([172.27.255.1]) by director9.mail.ord1d.rsapps.net with LMTP id 8C0RIczXxl0/MgAAalYnBA ; Sat, 09 Nov 2019 10:14:20 -0500 Received: from smtp23.gate.iad3a ([172.27.255.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy2.mail.iad3a.rsapps.net with LMTP id YN3sG8zXxl2ZYgAABcWvHw ; Sat, 09 Nov 2019 10:14:20 -0500 X-Spam-Threshold: 95 X-Spam-Score: 0 X-Spam-Flag: NO X-Virus-Scanned: OK X-Orig-To: openvpnslackdevel@openvpn.net X-Originating-Ip: [216.105.38.7] Authentication-Results: smtp23.gate.iad3a.rsapps.net; iprev=pass policy.iprev="216.105.38.7"; spf=pass smtp.mailfrom="openvpn-devel-bounces@lists.sourceforge.net" smtp.helo="lists.sourceforge.net"; dkim=fail (signature verification failed) header.d=sourceforge.net; dkim=fail (signature verification failed) header.d=sf.net; dmarc=none (p=nil; dis=none) header.from=rfc2549.org X-Suspicious-Flag: YES X-Classification-ID: 9a2b56b0-0303-11ea-aee7-52540033eb40-1-1 Received: from [216.105.38.7] ([216.105.38.7:49268] helo=lists.sourceforge.net) by smtp23.gate.iad3a.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 3F/4C-19801-BC7D6CD5; Sat, 09 Nov 2019 10:14:20 -0500 Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1iTSQQ-0002LH-30; Sat, 09 Nov 2019 15:13:18 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1iTSQP-0002LA-Hb for openvpn-devel@lists.sourceforge.net; Sat, 09 Nov 2019 15:13:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=References:In-Reply-To:Message-Id:Date:Subject:To: From:Sender:Reply-To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=yEkaeJGfegDFdLeKd/K+fDPPkodZfiCytqsBWippRzA=; b=Y0cF0urOgUZ5yULQu0Vpi/D5zU I0LccqHF65XN5DaFlh1ta5TljWIgpq9d9DJVcK/t5mhbABDhVlWMu2EI6vPENh14AQUwgPxZ85K7m GIiIaGBRRoGe1Y9AYHLyStITkuZIPJHKLEog6WMuypCeiyf5A5K9ek00lwkCFB1MlD0o=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=References:In-Reply-To:Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc :MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=yEkaeJGfegDFdLeKd/K+fDPPkodZfiCytqsBWippRzA=; b=l55l6ReXXXt2YFYoJwx3GPrBZ9 VhOYxMieio3OnqgOwp0hybX5n8nx18+KVBRrddkIry1a3zW9fnKE+UMb+8EhIAPb031fgQ+D+9RPa tKE5bNLJHU7lcVR5p2GoDHgyrI6zj4nT4RYDeU5O/H4wwkZP/zlJUysGm8W3nzcWuKSo=; Received: from mail.blinkt.de ([192.26.174.232]) by sfi-mx-3.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2) id 1iTSQL-009Whb-M8 for openvpn-devel@lists.sourceforge.net; Sat, 09 Nov 2019 15:13:17 +0000 Received: from kamera.blinkt.de ([2001:638:502:390:20c:29ff:fec8:535c]) by mail.blinkt.de with smtp (Exim 4.92.3 (FreeBSD)) (envelope-from ) id 1iTSQF-000Q0E-0d for openvpn-devel@lists.sourceforge.net; Sat, 09 Nov 2019 16:13:07 +0100 Received: (nullmailer pid 18653 invoked by uid 10006); Sat, 09 Nov 2019 15:13:06 -0000 From: Arne Schwabe To: openvpn-devel@lists.sourceforge.net Date: Sat, 9 Nov 2019 16:13:05 +0100 Message-Id: <20191109151306.18597-4-arne@rfc2549.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191109151306.18597-1-arne@rfc2549.org> References: <20191109151306.18597-1-arne@rfc2549.org> X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-Headers-End: 1iTSQL-009Whb-M8 Subject: [Openvpn-devel] [PATCH v2 4/5] Implement sending SSO challenge to clients X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox 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). Signed-off-by: Arne Schwabe --- 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(+) diff --git a/doc/management-notes.txt b/doc/management-notes.txt index e380ca2b..4b405a9b 100644 --- a/doc/management-notes.txt +++ b/doc/management-notes.txt @@ -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) ----------------------------------------------- diff --git a/src/openvpn/manage.c b/src/openvpn/manage.c index 8dada6f2..c055f2ce 100644 --- a/src/openvpn/manage.c +++ b/src/openvpn/manage.c @@ -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")) { diff --git a/src/openvpn/manage.h b/src/openvpn/manage.h index 8acc18bf..f570afc6 100644 --- a/src/openvpn/manage.h +++ b/src/openvpn/manage.h @@ -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 diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c index d594dd25..692fb62a 100644 --- a/src/openvpn/multi.c +++ b/src/openvpn/multi.c @@ -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 diff --git a/src/openvpn/push.c b/src/openvpn/push.c index ee1cb980..4b375ae3 100644 --- a/src/openvpn/push.c +++ b/src/openvpn/push.c @@ -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. */ diff --git a/src/openvpn/push.h b/src/openvpn/push.h index 9cf8fb34..f814f572 100644 --- a/src/openvpn/push.h +++ b/src/openvpn/push.h @@ -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); /**