Skip to content

Conversation

@dacamposol
Copy link

@dacamposol dacamposol commented Jul 18, 2025

Context

This pull request introduces a new feature to the macOS backend of the keyring library, enabling users to list all generic passwords stored in the keychain.

Key Changes

New Method Added

  1. list_passwords method is added to macOS.Keyring, allowing retrieval of all generic passwords.
  2. This method uses the new api.list_generic_passwords() function.

API Enhancements

Implements list_generic_passwords() in macOS/api.py, which:

  1. Queries the keychain for all generic password items.
  2. Returns a list of dictionaries containing the service and account for each item.
  3. Adds helpers for converting CoreFoundation types (CFStringRef, CFDataRef) to Python strings for easier handling of keychain data.

Testing

A new test test_list_generic_passwords in tests/backends/test_macOS.py verifies:

  1. The password listing functionality.
  2. That passwords added by the test can be successfully found and then cleaned up.

Impact

  • User Benefit: macOS users can now programmatically list all generic passwords in their keychain using keyring’s API.
  • Testing: The feature is covered by new automated tests.
  • Backward Compatibility: Changes are additive and should not affect existing functionality.

TLDR; This PR enhances the macOS backend by adding password listing capability, improves type conversions, and provides robust tests for the new functionality.

@dacamposol
Copy link
Author

dacamposol commented Sep 1, 2025

@jaraco or @mitya57, could you take a look?

@mitya57
Copy link
Collaborator

mitya57 commented Sep 1, 2025

I don't use macOS, and don't have experience with its API, so I leave the review to @jaraco.

One thing I would ask, though, is to not mix functional changes and style changes (like replacing quotes) in the same commit.

@jaraco jaraco closed this Nov 16, 2025
@jaraco jaraco reopened this Nov 16, 2025
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.

3 participants