Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fido2 list-credentials: Handle missing RP name #359

Merged
merged 2 commits into from
May 10, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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']}: ")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be better with:

Suggested change
if "name" in reliable_party:
local_print(f"{reliable_party['name']}: ")
else:
local_print(f"{reliable_party['id']}: ")
name = reliable_party.get('name', reliable_party['id'])
local_print(f"{name}: ")

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