25 from base64
import standard_b64decode
50 secrets = {
"Test-Client":
"OS6JDNRK2BNUPQVX",
51 "Client-2":
"IXWEMP7SK2QWSHTG"}
56 script_type = os.environ[
'script_type']
57 cn = os.environ[
'common_name']
59 if script_type ==
'user-pass-verify':
62 extra =
"CR_TEXT:E,R:Please enter your TOTP code!"
72 elif script_type ==
'client-crresponse':
79 with open(sys.argv[1],
'r')
as crinput:
80 response = crinput.read()
81 response = standard_b64decode(response)
82 response = response.decode().strip()
88 totp = pyotp.TOTP(secrets[cn])
91 if totp.verify(response, valid_window=1):
96 print(f
"Unknown script type {script_type}")
101 with open(os.environ[
'auth_control_file'],
'w')
as auth_control:
102 auth_control.write(
"%d" % status)
106 with open(os.environ[
'auth_pending_file'],
'w')
as auth_pending:
107 auth_pending.write(
"%d\n%s\n%s" % (timeout, method, extra))
110 if __name__ ==
'__main__':