Skip to contentSkip to conversation

Support client reason from auth plugin

PATCH In review Eric Thorpe 2 participants 2 messages Apr 11, 2019 – Jun 14, 2019

lore
Share & tools
lore
#0 lore raw

PATCH v2 2/2 Support client reason from auth plugin

Hi All,

This patch allows for a client reason to be returned from an auth plugin and sent to the connecting client on an auth fail. This change is backwards compatible with existing plugins and hasn't caused issues with existing plugins like the included pam plugin in our testing. The main purpose of this change is to support dynamic challenge/response from plugins, currently this is only possible from the management interface.

Example usage for this change can be found in a new plugin here modified from the included PAM plugin -
https://github.com/thesparklabs/openvpn-two-factor-extensions/tree/master/yubikey-u2f-pam-plugin

This is version two for this patch and addresses previous inadequacies pointed out.

Regards,
Eric

Signature · 6 lines
--
Eric Thorpe
SparkLabs Developer
https://www.sparklabs.com
https://twitter.com/sparklabs
[email protected]...

From 672e0163d5f6ad41e508c41fa6ea88ed07b4f4b9 Mon Sep 17 00:00:00 2001
From: Eric Thorpe <[email protected]>
Date: Wed, 10 Apr 2019 20:59:47 +1000
Subject: [PATCH] Allows a plugin to provide a client_reason for authentication
failure

---
 src/openvpn/ssl.c        |  4 +--
 src/openvpn/ssl_common.h |  4 +--
 src/openvpn/ssl_verify.c | 68 ++++++++++++++++++++++++++++------------
 src/openvpn/ssl_verify.h |  9 ++----
 4 files changed, 53 insertions(+), 32 deletions(-)
src/openvpn/ssl.c +1 -3
index 9696e9bab..884c94a23 100644
@@ -1354,10 +1354,8 @@ tls_multi_free(struct tls_multi *multi, bool clear)
 
     ASSERT(multi);
 
-#ifdef MANAGEMENT_DEF_AUTH
-    man_def_auth_set_client_reason(multi, NULL);
+    set_client_reason(multi, NULL);
 
-#endif
 #if P2MP_SERVER
     free(multi->peer_info);
 #endif
src/openvpn/ssl_common.h +2 -2
index b82a014a0..975fb983a 100644
@@ -515,13 +515,13 @@ struct tls_multi
     char *locked_cn;
     char *locked_username;
     struct cert_hash_set *locked_cert_hash_set;
-
-#ifdef ENABLE_DEF_AUTH
+    
     /*
      * An error message to send to client on AUTH_FAILED
      */
     char *client_reason;
 
+#ifdef ENABLE_DEF_AUTH
     /* Time of last call to tls_authentication_status */
     time_t tas_last;
 #endif
src/openvpn/ssl_verify.c +48 -20

116 lines not on this page · raw message

src/openvpn/ssl_verify.h +2 -7
index 3e2267aed..afcfb77be 100644
@@ -171,6 +171,8 @@ tls_common_name_hash(const struct tls_multi *multi, const char **cn, uint32_t *c
 
 #endif
 
+void set_client_reason(struct tls_multi *multi, const char *client_reason);
+
 /**
  * Verify the given username and password, using either an external script, a
  * plugin, or the management interface.
@@ -225,19 +227,12 @@ struct x509_track
  */
 #ifdef MANAGEMENT_DEF_AUTH
 bool tls_authenticate_key(struct tls_multi *multi, const unsigned int mda_key_id, const bool auth, const char *client_reason);
-
-void man_def_auth_set_client_reason(struct tls_multi *multi, const char *client_reason);
-
 #endif
 
 static inline const char *
 tls_client_reason(struct tls_multi *multi)
 {
-#ifdef ENABLE_DEF_AUTH
     return multi->client_reason;
-#else
-    return NULL;
-#endif
 }
 
 /** Remove any X509_ env variables from env_set es */
#1 lore raw

Am 11.04.19 um 04:07 schrieb Eric Thorpe:

Quoted 9 lines

Hi All,

This patch allows for a client reason to be returned from an auth plugin and sent to the connecting client on an auth fail. This change is backwards compatible with existing plugins and hasn't caused issues with existing plugins like the included pam plugin in our testing. The main purpose of this change is to support dynamic challenge/response from plugins, currently this is only possible from the management interface.

Quoted 4 lines

Example usage for this change can be found in a new plugin here modified from the included PAM plugin -
https://github.com/thesparklabs/openvpn-two-factor-extensions/tree/master/yubikey-u2f-pam-plugin

Same as for the 1/2 patch, I would like to postpone this after the auth-token set has been merged.

The patch "Sent indication that a session is expired to clients" of auth-token also does the renaming from man_def_auth_set_client_reason to auth_set_client_reason so this creates a big conflict.

Arne