]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/commitdiff
openvpn-authenticator: Always return general connection data
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 14 Jun 2022 15:57:03 +0000 (15:57 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 14 Jun 2022 15:57:03 +0000 (15:57 +0000)
The function returned different output when TOTP was configured and not
which is not what it should do.

This version will now try to add the TOTP configuration, or will add
nothing it if fails to do so.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
config/ovpn/openvpn-authenticator

index 5773fb40b298d04aff8d265e8244c78ddd7f1628..65844012b24dd1067e0bb9f9afe37c7f5efd2cc3 100644 (file)
@@ -294,16 +294,20 @@ class OpenVPNAuthenticator(object):
                                        continue
 
                                # Return match!
-                               conn = {}
-                               if len(row) < 45:
-                                       # General connection data
-                                       conn['name'] = row[2]
-                                       conn['common_name'] = row[3]
-                               elif len(row) >= 45:
-                                       # TOTP options
-                                       conn['totp_protocol'] = row[43]
-                                       conn['totp_status'] = row[44]
-                                       conn['totp_secret'] = row[45]
+                               conn = {
+                                       "name"        : row[2],
+                                       "common_name" : row[3],
+                               }
+
+                               # TOTP options
+                               try:
+                                       conn |= {
+                                               "totp_protocol" : row[43],
+                                               "totp_status"   : row[44],
+                                               "totp_secret"   : row[45],
+                                       }
+                               except IndexError:
+                                       pass
 
                                return conn