Skip to content

Commit

Permalink
fido2 list-credentials: Handle missing RP name
Browse files Browse the repository at this point in the history
The RP name is optional when enumerating RPs using the credential
management command.  Only the id is required.  This patch changes the
fido2 list-credentials subcommand to show the id instead of the name if
the name is not set.

Fixes: #352
  • Loading branch information
robin-nitrokey committed Mar 28, 2023
1 parent a66418b commit fae3e56
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions pynitrokey/cli/fido2.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,16 +236,21 @@ def list_credentials(serial, pin):
CredentialManagement.RESULT.RP_ID_HASH
)
local_print("-----------------------------------")
local_print(f"{reliable_party['name']}: ")
if "name" in reliable_party:
local_print(f"{reliable_party['name']}: ")
else:
local_print(f"{reliable_party['id']}: ")
for cred in cred_manager.enumerate_creds(reliable_party_hash):
cred_id = cred.get(CredentialManagement.RESULT.CREDENTIAL_ID)["id"]
cred_user = cred.get(CredentialManagement.RESULT.USER)
if cred_user["name"] == cred_user["displayName"]:
local_print(f"- id: {cred_id.hex()}")
local_print(f"user: {cred_user['name']}\n")
local_print(f" user: {cred_user['name']}\n")
else:
local_print(f"- id: {cred_id.hex()}")
local_print(f"user: {cred_user['displayName']} ({cred_user['name']})\n")
local_print(
f" user: {cred_user['displayName']} ({cred_user['name']})\n"
)

local_print("-----------------------------------")
local_print(
Expand Down

0 comments on commit fae3e56

Please sign in to comment.