mirror of
https://github.com/token2/fido2-manage.git
synced 2026-04-09 10:45:39 +00:00
Update gui-mac.py
This commit is contained in:
96
gui-mac.py
96
gui-mac.py
@@ -352,25 +352,80 @@ def check_changepin_button_state():
|
|||||||
|
|
||||||
change_pin_button.config(state=change_pin_button_state)
|
change_pin_button.config(state=change_pin_button_state)
|
||||||
|
|
||||||
def open_terminal():
|
#fp management start
|
||||||
# Simulate opening a new terminal
|
|
||||||
messagebox.showinfo("Info", "Opening a new terminal.")
|
|
||||||
|
|
||||||
def delete_selected():
|
def show_message_and_lift(window, message, title="Info"):
|
||||||
# Get the selected item from the listbox
|
messagebox.showinfo(title, message)
|
||||||
|
window.lift() # Bring the window back to focus
|
||||||
|
|
||||||
|
def open_terminal(device_string, window):
|
||||||
|
selected_device = device_var.get()
|
||||||
|
show_message_and_lift(window, f"Opening a new terminal for {selected_device} with device: {device_string}")
|
||||||
|
|
||||||
|
def delete_selected(device_string, window):
|
||||||
try:
|
try:
|
||||||
selected_index = listbox.curselection()
|
selected_index = listbox.curselection()
|
||||||
|
selected_device = device_var.get()
|
||||||
if selected_index:
|
if selected_index:
|
||||||
selected_item = listbox.get(selected_index)
|
selected_item = listbox.get(selected_index)
|
||||||
messagebox.showinfo("Delete", f"Selected: {selected_item}")
|
show_message_and_lift(window, f"Device: {selected_device}\nSelected: {selected_item}\nDevice String: {device_string}")
|
||||||
else:
|
else:
|
||||||
messagebox.showwarning("Warning", "No item selected.")
|
show_message_and_lift(window, "No item selected.", "Warning")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
messagebox.showerror("Error", f"An error occurred: {e}")
|
messagebox.showerror("Error", f"An error occurred: {e}")
|
||||||
|
window.lift()
|
||||||
|
|
||||||
|
def rename_selected(device_string, window):
|
||||||
|
try:
|
||||||
|
selected_index = listbox.curselection()
|
||||||
|
selected_device = device_var.get()
|
||||||
|
if selected_index:
|
||||||
|
selected_item = listbox.get(selected_index)
|
||||||
|
show_message_and_lift(window, f"Device: {selected_device}\nSelected: {selected_item}\nDevice String: {device_string}")
|
||||||
|
else:
|
||||||
|
show_message_and_lift(window, "No item selected.", "Warning")
|
||||||
|
except Exception as e:
|
||||||
|
messagebox.showerror("Error", f"An error occurred: {e}")
|
||||||
|
window.lift()
|
||||||
|
|
||||||
|
def refresh_terminal(device_string, window):
|
||||||
|
selected_device = device_var.get()
|
||||||
|
show_message_and_lift(window, f"Refreshing the terminal for {selected_device} with device: {device_string}")
|
||||||
|
update_fingerprint_list(device_string, window)
|
||||||
|
|
||||||
|
def update_fingerprint_list(device_string, window):
|
||||||
|
try:
|
||||||
|
selected_device = device_var.get()
|
||||||
|
match = re.search(r"\[(\d+)\]", selected_device)
|
||||||
|
|
||||||
|
if match:
|
||||||
|
device_digit = match.group(1)
|
||||||
|
if not device_string:
|
||||||
|
messagebox.showerror("Error", "Invalid device selection")
|
||||||
|
window.lift()
|
||||||
|
return
|
||||||
|
|
||||||
|
if PIN is not None:
|
||||||
|
command = [FIDO2_TOKEN_CMD, "-L", "-e"]
|
||||||
|
if PIN and PIN != "0000":
|
||||||
|
command.extend(["-w", PIN])
|
||||||
|
command.append(device_string)
|
||||||
|
|
||||||
|
result = subprocess.run(command, capture_output=True, text=True)
|
||||||
|
|
||||||
|
if result.returncode == 0:
|
||||||
|
listbox.delete(0, tk.END)
|
||||||
|
fingerprints = result.stdout.strip().split('\n')
|
||||||
|
for fp in fingerprints:
|
||||||
|
listbox.insert(tk.END, fp)
|
||||||
|
else:
|
||||||
|
messagebox.showerror("Error", f"Command failed with return code {result.returncode}")
|
||||||
|
window.lift()
|
||||||
|
except Exception as e:
|
||||||
|
messagebox.showerror("Error", f"An error occurred: {e}")
|
||||||
|
window.lift()
|
||||||
|
|
||||||
def fingerprints():
|
def fingerprints():
|
||||||
"""Handle passkeys button click"""
|
|
||||||
global PIN
|
global PIN
|
||||||
|
|
||||||
selected_device = device_var.get()
|
selected_device = device_var.get()
|
||||||
@@ -385,7 +440,6 @@ def fingerprints():
|
|||||||
return
|
return
|
||||||
|
|
||||||
if PIN is not None:
|
if PIN is not None:
|
||||||
# Execute command to get resident keys (list domains)
|
|
||||||
command = [FIDO2_TOKEN_CMD, "-L", "-e"]
|
command = [FIDO2_TOKEN_CMD, "-L", "-e"]
|
||||||
if PIN and PIN != "0000":
|
if PIN and PIN != "0000":
|
||||||
command.extend(["-w", PIN])
|
command.extend(["-w", PIN])
|
||||||
@@ -395,34 +449,33 @@ def fingerprints():
|
|||||||
result = subprocess.run(command, capture_output=True, text=True)
|
result = subprocess.run(command, capture_output=True, text=True)
|
||||||
|
|
||||||
if result.returncode == 0:
|
if result.returncode == 0:
|
||||||
# Create a new window to display the fingerprints
|
|
||||||
fingerprint_window = tk.Toplevel()
|
fingerprint_window = tk.Toplevel()
|
||||||
fingerprint_window.title("Fingerprints")
|
fingerprint_window.title("Fingerprints")
|
||||||
|
|
||||||
# Add a label
|
tk.Label(fingerprint_window, text=f"List of Fingerprints for {selected_device}:").pack(pady=10)
|
||||||
tk.Label(fingerprint_window, text="List of Fingerprints:").pack(pady=10)
|
|
||||||
|
|
||||||
# Add a listbox to display fingerprints
|
|
||||||
global listbox
|
global listbox
|
||||||
listbox = tk.Listbox(fingerprint_window, width=50)
|
listbox = tk.Listbox(fingerprint_window, width=50)
|
||||||
listbox.pack(padx=10, pady=10)
|
listbox.pack(padx=10, pady=10)
|
||||||
|
|
||||||
# Parse and insert fingerprints into the listbox
|
|
||||||
fingerprints = result.stdout.strip().split('\n')
|
fingerprints = result.stdout.strip().split('\n')
|
||||||
for fp in fingerprints:
|
for fp in fingerprints:
|
||||||
listbox.insert(tk.END, fp)
|
listbox.insert(tk.END, fp)
|
||||||
|
|
||||||
# Add "Add" and "Delete" buttons
|
|
||||||
button_frame = tk.Frame(fingerprint_window)
|
button_frame = tk.Frame(fingerprint_window)
|
||||||
button_frame.pack(pady=10)
|
button_frame.pack(pady=10)
|
||||||
|
|
||||||
add_button = tk.Button(button_frame, text="Add", command=open_terminal)
|
add_button = tk.Button(button_frame, text="Add", command=lambda: open_terminal(device_string, fingerprint_window))
|
||||||
add_button.pack(side=tk.LEFT, padx=5)
|
add_button.pack(side=tk.LEFT, padx=5)
|
||||||
|
|
||||||
delete_button = tk.Button(button_frame, text="Delete", command=delete_selected)
|
delete_button = tk.Button(button_frame, text="Delete", command=lambda: delete_selected(device_string, fingerprint_window))
|
||||||
delete_button.pack(side=tk.RIGHT, padx=5)
|
delete_button.pack(side=tk.LEFT, padx=5)
|
||||||
|
|
||||||
|
rename_button = tk.Button(button_frame, text="Rename", command=lambda: rename_selected(device_string, fingerprint_window))
|
||||||
|
rename_button.pack(side=tk.LEFT, padx=5)
|
||||||
|
|
||||||
|
refresh_button = tk.Button(button_frame, text="Refresh", command=lambda: refresh_terminal(device_string, fingerprint_window))
|
||||||
|
refresh_button.pack(side=tk.LEFT, padx=5)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
messagebox.showerror("Error", f"Command failed with return code {result.returncode}")
|
messagebox.showerror("Error", f"Command failed with return code {result.returncode}")
|
||||||
@@ -430,6 +483,13 @@ def fingerprints():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
messagebox.showerror("Error", f"An error occurred: {e}")
|
messagebox.showerror("Error", f"An error occurred: {e}")
|
||||||
|
|
||||||
|
#fp management end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def on_passkeys_button_click():
|
def on_passkeys_button_click():
|
||||||
"""Handle passkeys button click"""
|
"""Handle passkeys button click"""
|
||||||
|
|||||||
Reference in New Issue
Block a user