mirror of
https://github.com/token2/fido2-manage.git
synced 2026-04-09 10:45:39 +00:00
Update gui1.py
This commit is contained in:
53
gui1.py
53
gui1.py
@@ -1,3 +1,26 @@
|
|||||||
|
def execute_info_command_no_pin(device_digit):
|
||||||
|
"""Execute info command without PIN - just show basic device info"""
|
||||||
|
tree.delete(*tree.get_children())
|
||||||
|
|
||||||
|
# Execute info command without PIN
|
||||||
|
info_command = [FIDO_COMMAND, "-info", "-device", device_digit]
|
||||||
|
try:
|
||||||
|
result = subprocess.run(info_command, capture_output=True, text=True)
|
||||||
|
if result.returncode == 0:
|
||||||
|
for line in result.stdout.splitlines():
|
||||||
|
if ": " in line:
|
||||||
|
key, value = line.split(": ", 1)
|
||||||
|
tree.insert("", tk.END, values=(key, value))
|
||||||
|
else:
|
||||||
|
raise subprocess.CalledProcessError(result.returncode, info_command)
|
||||||
|
except Exception as e:
|
||||||
|
messagebox.showerror(
|
||||||
|
"Error", f"Command execution failed: {e}\nOutput: {result.stderr}"
|
||||||
|
)
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
@@ -115,7 +138,7 @@ def execute_info_command(device_digit):
|
|||||||
"Warning",
|
"Warning",
|
||||||
"No PIN set for this key. You must set a PIN before managing passkeys."
|
"No PIN set for this key. You must set a PIN before managing passkeys."
|
||||||
)
|
)
|
||||||
pin_button.config(text="Set PIN", state=tk.ACTIVE, command=set_pin)
|
change_pin_button.config(text="Set PIN", state=tk.ACTIVE, command=set_pin)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if result.stderr.find("FIDO_ERR_INVALID_CBOR") != -1:
|
if result.stderr.find("FIDO_ERR_INVALID_CBOR") != -1:
|
||||||
@@ -178,19 +201,11 @@ def on_device_selected(event):
|
|||||||
|
|
||||||
# Function to check if the "passkeys" button should be enabled
|
# Function to check if the "passkeys" button should be enabled
|
||||||
def check_passkeys_button_state():
|
def check_passkeys_button_state():
|
||||||
passkeys_button_state = tk.DISABLED
|
# Enable passkeys button if device is selected
|
||||||
for child in tree.get_children():
|
if device_var.get():
|
||||||
values = tree.item(child, "values")
|
passkeys_button.config(state=tk.NORMAL)
|
||||||
if values and len(values) == 2 and values[0] == "existing rk(s)":
|
else:
|
||||||
try:
|
passkeys_button.config(state=tk.DISABLED)
|
||||||
rk_count = int(values[1])
|
|
||||||
if rk_count > 0:
|
|
||||||
passkeys_button_state = tk.NORMAL
|
|
||||||
break
|
|
||||||
except ValueError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
passkeys_button.config(state=passkeys_button_state)
|
|
||||||
|
|
||||||
|
|
||||||
# Function to check if the change PIN button should be enabled
|
# Function to check if the change PIN button should be enabled
|
||||||
@@ -213,10 +228,14 @@ def check_changepin_button_state():
|
|||||||
# Function to handle "passkeys" button click
|
# Function to handle "passkeys" button click
|
||||||
def on_passkeys_button_click():
|
def on_passkeys_button_click():
|
||||||
global PIN
|
global PIN
|
||||||
# Get the selected device and PIN
|
|
||||||
|
# Get the selected device
|
||||||
selected_device = device_var.get()
|
selected_device = device_var.get()
|
||||||
match = re.search(r"\[(\d+)\]", selected_device)
|
match = re.search(r"\[(\d+)\]", selected_device)
|
||||||
if match:
|
if not match:
|
||||||
|
messagebox.showinfo("Device Selected", "No digit found in the selected device")
|
||||||
|
return
|
||||||
|
|
||||||
device_digit = match.group(1)
|
device_digit = match.group(1)
|
||||||
|
|
||||||
# Prompt for PIN if not already set
|
# Prompt for PIN if not already set
|
||||||
@@ -283,8 +302,6 @@ def on_passkeys_button_click():
|
|||||||
messagebox.showerror(
|
messagebox.showerror(
|
||||||
"Error", f"Command execution failed: {e}\nOutput: {result.stderr}"
|
"Error", f"Command execution failed: {e}\nOutput: {result.stderr}"
|
||||||
)
|
)
|
||||||
else:
|
|
||||||
messagebox.showinfo("Device Selected", "No digit found in the selected device")
|
|
||||||
|
|
||||||
|
|
||||||
def set_pin():
|
def set_pin():
|
||||||
|
|||||||
Reference in New Issue
Block a user