Skip to content

Commit

Permalink
Not accessing credentials.username if credentials is an instance …
Browse files Browse the repository at this point in the history
…of `AnonymousCredential`

See #694 and #692
  • Loading branch information
ffissore committed Sep 19, 2024
1 parent 0041050 commit bd2a372
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion keyring/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,18 @@ def do_get(self):
getattr(self, f'_emit_{self.output_format}')(credential)

def _emit_json(self, credential: credentials.Credential):
if isinstance(credential, credentials.AnonymousCredential):
print(json.dumps(dict(password=credential.password)))
return
print(
json.dumps(dict(username=credential.username, password=credential.password))
)

def _emit_plain(self, credential: credentials.Credential):
if credential.username:
if (
not isinstance(credential, credentials.AnonymousCredential)
and credential.username
):
print(credential.username)
print(credential.password)

Expand Down

0 comments on commit bd2a372

Please sign in to comment.