Fix case-sensitive username comparison in WinVaultKeyring#741
Open
veeceey wants to merge 3 commits intojaraco:mainfrom
Open
Fix case-sensitive username comparison in WinVaultKeyring#741veeceey wants to merge 3 commits intojaraco:mainfrom
veeceey wants to merge 3 commits intojaraco:mainfrom
Conversation
The WinVaultKeyring backend was comparing usernames with exact case-sensitive equality, causing inconsistent behavior on Windows where usernames are case-insensitive. For example, storing a password for 'USER' and then retrieving it with 'user' would fail to find the credential. Introduce a _username_match helper for case-insensitive comparison and apply it in _resolve_credential, set_password, and delete_password. Also skip redundant compound-name creation in set_password when the same user (regardless of case) updates their password for a service. Fixes jaraco#736
mitya57
approved these changes
Feb 13, 2026
Replace the fake_read function with a dict lookup so there's no unreachable fallback return statement at line 158.
Author
|
The Windows test failures look like they might be pre-existing/infra-related rather than caused by this change. Happy to investigate further if needed though. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #736
The WinVaultKeyring backend was comparing usernames with strict case-sensitive equality (
res['UserName'] != username), which doesn't match how Windows itself handles credentials — Win32Cred treats usernames case-insensitively.This caused confusing behavior where storing a password for
USERand then retrieving it asuserwould silently fail, and subsequentset_passwordcalls with different casing would create orphaned compound entries.Changes:
_username_matchhelper that does case-insensitive comparison, handlingNonevalues correctly_resolve_credentialsoget_password/get_credentialfind credentials regardless of username casingset_passwordso updating a password for the same user with different casing just overwrites in place instead of unnecessarily creating a compound{username}@{service}entrydelete_passwordso deletion works regardless of username casingTest results:
All existing tests continue to pass. The new tests in
TestUsernameMatchandTestWinVaultCaseInsensitivecover the case-insensitive matching behavior across get, set, delete, and credential resolution.