Repository navigation
fix(dg): keep a master key on logout and the sync key when the keychain fails - #771
Merged
Merged
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 38 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
PastaPastaPasta
force-pushed
the
fix/dg-key-safety-wave9
branch
from
November 27, 2026 15:21
4720e6b to
cd53f03
Compare
…in fails `dg auth logout` deleted dg's key file and keychain entries outright, so a `--full-key` file (or an older dg's master key in the keychain) was lost. It now copies an identity key that holds a master key or recovery words, or that it could not open to check, to `<name>.bak-<UTC time>` (0600) or a `.bak-` keychain entry before removing it, prints where, and reports the copies as `keptAt`. It holds the identity lock while it removes, and trusts the key it opened only while the (regular) key file still holds the bytes it opened. A key it cannot read or copy stays in place. When the OS keychain failed to take the settings-sync key, `Storer::write` gave up. It now reads the entry again: with none there, the key goes to the sealed `.key.sync` file (which the loader reads when the keychain has no entry or errors) and dg says so; an entry that would hide the file, or one that cannot be read, still stops it. Closes #768 Co-Authored-By: Claude Opus 5.5 <[email protected]>
PastaPastaPasta
force-pushed
the
fix/dg-key-safety-wave9
branch
from
November 27, 2026 15:24
cd53f03 to
af53fcc
Compare
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.
Problem
dg auth logoutdeleted dg's main-slot key file and keychain entries outright. Adg auth login --full-keyfile (or a master key an older dg put in the keychain) was gone, with no copy.Storer::writestopped forSlot::Syncinstead of falling back to a file, so a wallet sign-in left the settings-sync key unstored.Fix
Logout keeps master keys. Before removing an identity key (main, pending, or the keychain entry
--identitynames),store::removecopies it if it:The copy goes to
<name>.bak-<UTC time>(0600, via the existingkeep_file) or to a.bak-<UTC time>keychain entry (the same patternkeep_keychain_entryuses). Logout prints one line per copy and addskeptAtto--json(schema regenerated).While removing,
removeholds the identity lock. It trusts the key logout opened only while the key file (a regular file only, never a pipe) still holds the same bytes. A key it can't read or copy stays where it is, and logout fails, listing any copies already made. Limited keys and the sync key are removed as before.I chose a backup over refusing: logout still does its job (the default identity is cleared and dg's slots are emptied), and the master key isn't lost.
Sync key fallback (#768). After any keychain failure for the sync key, dg reads the entry again:
.key.syncfile;user_sync::key::loadreads the file whenever the keychain has no entry or errors, so the fallback file is found. When the keychain failed, the passphrase prompt now gives that as the reason instead of "there is no OS keychain here".User-visible lines
kept a copy at <path>: it holds this identity's master key (--identityuses it; delete it once you keep the master key elsewhere)kept a copy at <path>: dg could not open it to check that it holds no master key (delete it once you no longer need it)note: the OS keychain failed (<error>), so the settings-sync key is kept in <path> (dg and git read it when DASH_FORGE_PASSPHRASE is set)Compat
No format changes. The backups use the existing names and formats, which older dg can already read through
--identity. Sign-ins with a working keychain, or no keychain, behave as before.Closes #768
🤖 Generated with Claude Code