UI Improvements
This commit is contained in:
+25
-14
@@ -16,9 +16,10 @@
|
||||
|
||||
|
||||
import logging
|
||||
|
||||
from services.agenthandler import selectAgents
|
||||
from utils.utils import colorText
|
||||
from utils.selector import Selector
|
||||
from utils.utils import colorText, get_sanitized_input
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -27,18 +28,27 @@ from services.API import AirlockAPIWrapper
|
||||
|
||||
|
||||
def generate(api: AirlockAPIWrapper):
|
||||
agents = selectAgents(api)
|
||||
purpose = input(colorText(" Please enter the purpose for the OTP: ", "white"))
|
||||
possible_durations = [15, 60, 360, 1440, 10080]
|
||||
|
||||
print(colorText("Please select a duration:", "white"))
|
||||
duration_selected = Selector.select_int(possible_durations)
|
||||
otp_dict = {}
|
||||
if duration_selected:
|
||||
for agent in agents:
|
||||
otp_code = api.otp_generate(agent.agentid, duration_selected, purpose)
|
||||
logger.info(f"Generated OTP for {agent.hostname}: {otp_code}")
|
||||
otp_dict[agent.hostname] = otp_code
|
||||
agents = selectAgents(api)
|
||||
print(colorText("Would you like to continue with these devices?","white"))
|
||||
for agent in agents:
|
||||
print(agent.hostname)
|
||||
confirm = Selector.confirm()
|
||||
if agents and confirm:
|
||||
requester = get_sanitized_input("Who is requesting the OTP: ")
|
||||
because = get_sanitized_input("Why/What work are they doing?: ")
|
||||
|
||||
purpose = f"Requester: {requester} - for : {because}"
|
||||
possible_durations = [15, 60, 360, 1440, 10080]
|
||||
|
||||
print(colorText("Please select a duration in minutes: ", "white"))
|
||||
print(colorText("15 mins, 60 mins, 360 mins(6 Hours), 1440 mins (24 Hours), 10080 mins (7 Days):", "white"))
|
||||
duration_selected = Selector.select_int(possible_durations)
|
||||
if duration_selected:
|
||||
for agent in agents:
|
||||
otp_code = api.otp_generate(agent.agentid, duration_selected, purpose)
|
||||
logger.info(f"Generated OTP for {agent.hostname}: {otp_code}")
|
||||
otp_dict[agent.hostname] = otp_code
|
||||
|
||||
return otp_dict
|
||||
|
||||
@@ -54,5 +64,6 @@ def otp_activities_by_agent(api: AirlockAPIWrapper):
|
||||
def revoke(api: AirlockAPIWrapper):
|
||||
otp_dict = otp_activities_by_agent(api)
|
||||
list_to_revoke = [entry["otpid"] for entry in otp_dict]
|
||||
for revokee in list_to_revoke:
|
||||
api.otp_revoke(revokee)
|
||||
if otp_dict and list_to_revoke:
|
||||
for revokee in list_to_revoke:
|
||||
api.otp_revoke(revokee)
|
||||
Reference in New Issue
Block a user