Skip to content

Update keyring items in place instead of delete-and-recreate - #56

Open
aberoham wants to merge 1 commit into
osodevops:mainfrom
aberoham:fix/keyring-preserve-item
Open

Update keyring items in place instead of delete-and-recreate#56
aberoham wants to merge 1 commit into
osodevops:mainfrom
aberoham:fix/keyring-preserve-item

Conversation

@aberoham

Copy link
Copy Markdown
Contributor

Fixes #51.

store_token, add_profile_to_index, and remove_profile_from_index deleted the keyring item before every set_password call. On macOS the recreation discards the item's access control list, so an "Always Allow" grant was revoked by the next silent token refresh and the keychain prompt returned within the hour.

keyring v3 set_password already updates an existing item in place (its macOS backend is create-or-update), so the delete calls are removed. The two index writers shared the same storage block and now use one write_profile_index helper.

Verified on macOS 15 against a live login: after this change, security find-generic-password -s teams-cli -a "default:token" shows an unchanged creation date and an updated modification date following teams auth refresh. Before the change the creation date moved on every write, proving the item was recreated.

cargo fmt, cargo clippy --all-targets -- -D warnings, and cargo test --bins pass.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NXWLJ9g87M3GtLSACr2gmi

store_token, add_profile_to_index, and remove_profile_from_index deleted
the keyring item before every set_password call. On macOS the recreation
discards the item's access control list, so an "Always Allow" grant was
revoked by the next silent token refresh and the keychain prompt returned
within the hour. set_password already updates an existing item in place,
which preserves the grant, so the delete calls are removed. The two index
writers shared the same storage block and now use one helper.

Verified on macOS: with this change `security find-generic-password`
shows an unchanged creation date and an updated modification date on the
token item after `teams auth refresh`; previously the item was recreated
on every write.

Fixes osodevops#51.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NXWLJ9g87M3GtLSACr2gmi
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.

store_token deletes the keychain item before every write, discarding macOS access grants

1 participant