Skip to content

Various improvment of macOS backend - #760

Open
YakBizzarro wants to merge 5 commits into
jaraco:mainfrom
YakBizzarro:macos_credential_no_username
Open

Various improvment of macOS backend#760
YakBizzarro wants to merge 5 commits into
jaraco:mainfrom
YakBizzarro:macos_credential_no_username

Conversation

@YakBizzarro

Copy link
Copy Markdown

Various improvements of the macOS backend. In particular:

  • add support for get_credential(), so that credentials can be retrieved without specifying a username
  • fix some memory leaks

More details in the individual commit messages

Fix #432, #711, #670

…ric_password`

Remove an unused parameter from a private function in the macOS backend.
Error are raised anyway just after the unused check
Add support for retriving credentials with or without providing a username.
The implementation of `find_generic_password()` was already quite complete for the
task. It has been improved by adding the username to the query (`kSecAttrAccount`)
only if the user provided a username to look for.
Moreover, the query now ask for all the attributes (kSecReturnAttributes=True)
so that both username and password can be extracted from the response.
Since the reply now is a `CFDictonary`, all the functions necessary to parse
it have been added, including one for `CFString`.

Source: https://developer.apple.com/documentation/security/searching-for-keychain-items

Fix  jaraco#432, jaraco#711
This reverts commit ca2982b.
Since now `get_credential()` is supported on all platform,
make the test more stringent.
All the CF objects that we create or copy, must be freed with `CFRelease` when done.
This commit introduce this mechanism for all objects we create and own.
It uses a try/finally pattern to ensure destruction of objects is always performed
also when exceptions are raised.
Tested with XCode `leaks` utility.

Source: https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFMemoryMgmt/CFMemoryMgmt.html

Fix jaraco#670
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.

Add support for password retrieval without username on macOS

1 participant