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

feature: Allow listing of acct #665

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

VivienGiraud
Copy link

This PR add usage of listing accounts given an app name.

>>> keyring list MyApp
['GitHub', 'Microsoft']

Then you will be able to access an specific account using:

>>> keyring get MyApp Microsoft
MY_PASSWORD

@VivienGiraud
Copy link
Author

Hi @mitya57 ,
Can you tell me if you could review this feature?
I working on an open source project that will rely on this functionality.
Have a pleasant day.

@mitya57
Copy link
Collaborator

mitya57 commented Jan 6, 2024

  1. I would name the function list_passwords (in plural), not list_password.
  2. Ideally we need support in all backends, not just in the macOS one.
  3. The CI is failing. In particular, you forgot to import your function in keyring/cli.py.

Note: I'm not the chief maintainer of Keyring, @jaraco is, so he has the final word.

Copy link
Owner

@jaraco jaraco left a comment

Choose a reason for hiding this comment

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

Overall, this looks good. I have a couple of comments about naming and the design.

I'm also curious - what should this project think about the unimplemented backends? Ideally, a feature like this would be launched with support in Mac, Windows, and Linux. Would you be willing to explore an implementation that works in those backends?

Finally, this change should demand some tests. Let's make sure the test suite exercises this new expectation and functionality.

@@ -100,6 +100,11 @@ def get_password(self, service: str, username: str) -> typing.Optional[str]:
"""Get password of the username for the service"""
return None

@abc.abstractmethod
def list_password(self, service: str) -> list[str]:
Copy link
Owner

Choose a reason for hiding this comment

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

How about name it list_accounts or list_users, since "username" and "account" are the terms used for these fields and "passwords" aren't involved in the result.

@@ -87,6 +87,8 @@ or with ``--help`` as so::
Password for 'username' in 'system':
$ keyring get system username
password
$ keyring list app_name
Copy link
Owner

Choose a reason for hiding this comment

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

Probably this should mention "system" and not "app_name", because "system" is what's mentioned above.

@@ -87,6 +87,8 @@ or with ``--help`` as so::
Password for 'username' in 'system':
$ keyring get system username
password
$ keyring list app_name
Copy link
Owner

Choose a reason for hiding this comment

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

We should think carefully about the "command" here. It's called "list", but "list" could mean "list users" or "list systems" or "list users and systems". I wonder if we shouldn't instead allow a generic "list" that takes a string and matches any system:password where that string is found. Let's take some time to think about other use-cases other than exact matches of a system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants