openvpn-authenticator: Return only available data

For connections which have not enabled OTP return
connection name and common_name attributes only.
This commit is contained in:
Timo Eissler
2022-06-07 12:14:12 +02:00
committed by Michael Tremer
parent 74ab6f9fc0
commit a4a42daeea

View File

@@ -286,15 +286,19 @@ class OpenVPNAuthenticator(object):
continue continue
# Return match! # Return match!
return { conn = {}
"name" : row[2], if len(row) < 45:
"common_name" : row[3], # General connection data
conn['name'] = row[2]
conn['common_name'] = row[3]
elif len(row) >= 45:
# TOTP options # TOTP options
"totp_protocol" : row[43], conn['totp_protocol'] = row[43]
"totp_status" : row[44], conn['totp_status'] = row[44]
"totp_secret" : row[45], conn['totp_secret'] = row[45]
}
return conn
def _check_totp_token(self, token, secret): def _check_totp_token(self, token, secret):
p = subprocess.run( p = subprocess.run(