added support for totp
This commit is contained in:
+17
-5
@@ -4,6 +4,7 @@
|
|||||||
import argparse
|
import argparse
|
||||||
import asyncio
|
import asyncio
|
||||||
from colorama import just_fix_windows_console
|
from colorama import just_fix_windows_console
|
||||||
|
import pyotp
|
||||||
import json
|
import json
|
||||||
import meshctrl
|
import meshctrl
|
||||||
|
|
||||||
@@ -20,11 +21,22 @@ async def init_connection(credentials: dict) -> meshctrl.Session:
|
|||||||
Use the libmeshctrl library to initiate a Secure Websocket (wss) connection to the MeshCentral instance.
|
Use the libmeshctrl library to initiate a Secure Websocket (wss) connection to the MeshCentral instance.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
session = meshctrl.Session(
|
if configuration["totp_secret"]:
|
||||||
credentials['hostname'],
|
totp = pyotp.TOTP(configuration["totp_secret"])
|
||||||
user=credentials['username'],
|
otp = totp.now()
|
||||||
password=credentials['password']
|
|
||||||
)
|
session = meshctrl.Session(
|
||||||
|
configuration['hostname'],
|
||||||
|
user=configuration['username'],
|
||||||
|
password=configuration['password'],
|
||||||
|
token=otp
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
session = meshctrl.Session(
|
||||||
|
configuration['hostname'],
|
||||||
|
user=configuration['username'],
|
||||||
|
password=configuration['password']
|
||||||
|
)
|
||||||
await session.initialized.wait()
|
await session.initialized.wait()
|
||||||
return session
|
return session
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user