feat: optional ChaCha encryption for auth.json keys - #4
Merged
Conversation
tauri.macos.conf.json holds macOSPrivateApi + transparent, but the cargo feature was enabled unconditionally, so tauri-build rejected the mismatch everywhere else and cargo test has been failing on main since v0.2.0. Co-authored-by: Gao Yu <gaoyu06@users.noreply.github.com>
Provider API keys and the JuCode OAuth token pair are stored as
ChaCha20-Poly1305 envelopes ("jcenc1:<base64>") keyed by a 32-byte random
secret.key created 0600 in the app config dir. This is obfuscation against
casual reads — backups, synced home directories, support bundles — not
protection from anything running as the user; docs/secrets.md says so.
Off by default via config.json's encrypt_secrets, because ~/.jucode/auth.json
is shared with the jucode CLI engine: the desktop drives whatever CLI version
the user has installed, and that CLI would read the envelope as an API key.
Enabling it is for people who only reach the engine through Desktop.
Reads are format-agnostic in both directions, so plaintext files load
unchanged and the next save migrates them; an envelope that won't open is
left intact so a lost key surfaces as "not logged in" rather than a corrupt
save. Values stay JSON strings, and expiry timestamps stay in the clear so
the login/refresh checks work without a key. auth.json itself is now
chmod 0600 whether or not encryption is on.
Co-authored-by: Gao Yu <gaoyu06@users.noreply.github.com>
Bundle the credential file, the config holding encrypt_secrets, and the key store into an AuthStore so the migration path can be exercised without mutating $HOME for the whole test process: plaintext loads and the next save encrypts it, flipping the switch off writes plaintext back, the default leaves the CLI-shared file in the clear, and saves land at 0600. Co-authored-by: Gao Yu <gaoyu06@users.noreply.github.com>
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.
本次改动范围
auth.json里的 API key / OAuth token 可选用 ChaCha20-Poly1305 加密(jcenc1:信封)secret.key(0600)macos-private-apifeature 导致的 cargo test 失败是否可直接上线
否。默认关闭,但加了依赖与读写路径,需确认不会误伤 CLI。
上线前是否需要 review
需要(安全向)。
review 的前置条件
docs/secrets.md:这是防随手翻文件,不是对抗本机恶意进程encrypt_secrets为 false