Update fido2-manage.sh

Add extended use data (UPN)
This commit is contained in:
Token2
2024-06-10 10:15:27 +02:00
committed by GitHub
parent 709721261c
commit 500744bdcc

View File

@@ -192,25 +192,47 @@ if [[ -n $device ]]; then
exit 0 exit 0
fi fi
# Main logic
# Main logic
if $storage; then if $storage; then
$FIDO2_TOKEN_CMD -I -c "$device_string" $([[ -n $pin ]] && echo "-w $pin") $FIDO2_TOKEN_CMD -I -c "$device_string" $([[ -n $pin ]] && echo "-w $pin")
exit 0 exit 0
elif $residentKeys; then elif $residentKeys; then
if [[ -n $domain ]]; then if [[ -n $domain ]]; then
output=$($FIDO2_TOKEN_CMD -L -k "$domain" "$device_string" $([[ -n $pin ]] && echo "-w $pin")) domain_command="$FIDO2_TOKEN_CMD -L -k \"$domain\" \"$device_string\" $([[ -n $pin ]] && echo "-w $pin")"
echo "$output" | grep -oP '(\d+): (\S+) (.+)' | while read -r line; do domain_output=$(eval $domain_command)
# Process the output line by line
echo "$domain_output" | while read -r line; do
key_id=$(echo "$line" | awk '{print $1}') key_id=$(echo "$line" | awk '{print $1}')
credential_id=$(echo "$line" | awk '{print $2}') credential_id=$(echo "$line" | awk '{print $2}')
user=$(echo "$line" | grep -oP '(\S+\s+\S+).+ es256' | head -1) user_field=$(echo "$line" | awk '{print $3 , $4}')
show_message "Credential ID: $credential_id, User: $user" email_field=$(echo "$line" | awk '{print $5, $6}')
if [[ "$user_field" == "(null)" ]]; then
user_field=""
fi
# Determine if user_field is an email
if [[ "$user_field" == *"@"* ]]; then
email=$user_field
user=""
else
user=$user_field
email=$email_field
fi
show_message "Credential ID: $credential_id, User: $user $email"
done done
else else
$FIDO2_TOKEN_CMD -L -r "$device_string" $(if [[ -n $pin ]]; then echo "-w $pin"; fi) $FIDO2_TOKEN_CMD -L -r "$device_string" $(if [[ -n $pin ]]; then echo "-w $pin"; fi)
fi fi
exit 0 exit 0
fi fi
if $info; then if $info; then
command_output=$($FIDO2_TOKEN_CMD -I "$device_string") command_output=$($FIDO2_TOKEN_CMD -I "$device_string")
show_message "Device $device Information:" show_message "Device $device Information:"