From a4a42daeeaefed48dd9b40d7001f1fc613978f85 Mon Sep 17 00:00:00 2001 From: Timo Eissler Date: Tue, 7 Jun 2022 12:14:12 +0200 Subject: [PATCH] openvpn-authenticator: Return only available data For connections which have not enabled OTP return connection name and common_name attributes only. --- config/ovpn/openvpn-authenticator | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/config/ovpn/openvpn-authenticator b/config/ovpn/openvpn-authenticator index f50aab0937..751b58d438 100644 --- a/config/ovpn/openvpn-authenticator +++ b/config/ovpn/openvpn-authenticator @@ -286,15 +286,19 @@ class OpenVPNAuthenticator(object): continue # Return match! - return { - "name" : row[2], - "common_name" : row[3], - + conn = {} + if len(row) < 45: + # General connection data + conn['name'] = row[2] + conn['common_name'] = row[3] + elif len(row) >= 45: # TOTP options - "totp_protocol" : row[43], - "totp_status" : row[44], - "totp_secret" : row[45], - } + conn['totp_protocol'] = row[43] + conn['totp_status'] = row[44] + conn['totp_secret'] = row[45] + + return conn + def _check_totp_token(self, token, secret): p = subprocess.run( -- 2.39.5