]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
openvpn-authenticator: Return only available data
authorTimo Eissler <timo.eissler@ipfire.org>
Tue, 7 Jun 2022 10:14:12 +0000 (12:14 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 17 Jun 2022 10:20:19 +0000 (10:20 +0000)
For connections which have not enabled OTP return
connection name and common_name attributes only.

config/ovpn/openvpn-authenticator

index f50aab0937f41e2b647f87ef00dfcd6c2e3306f8..751b58d4382ecd715b423886c050289428afc66e 100644 (file)
@@ -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(