From: Timo Eissler Date: Tue, 7 Jun 2022 10:14:12 +0000 (+0200) Subject: openvpn-authenticator: Return only available data X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a4a42daeeaefed48dd9b40d7001f1fc613978f85;p=people%2Fms%2Fipfire-2.x.git openvpn-authenticator: Return only available data For connections which have not enabled OTP return connection name and common_name attributes only. --- 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(